diff --git a/common/src/main/java/net/william278/husksync/command/UserDataCommand.java b/common/src/main/java/net/william278/husksync/command/UserDataCommand.java index 791bdb4d..66f14eda 100644 --- a/common/src/main/java/net/william278/husksync/command/UserDataCommand.java +++ b/common/src/main/java/net/william278/husksync/command/UserDataCommand.java @@ -2,6 +2,7 @@ package net.william278.husksync.command; import net.william278.husksync.HuskSync; import net.william278.husksync.data.DataSaveCause; +import net.william278.husksync.data.UserData; import net.william278.husksync.player.OnlineUser; import net.william278.husksync.util.DataDumper; import org.jetbrains.annotations.NotNull; @@ -173,8 +174,13 @@ public class UserDataCommand extends CommandBase implements TabCompletable { .ifPresent(player::sendMessage); return; } - plugin.getDatabase().setUserData(user, data.get().userData(), - DataSaveCause.BACKUP_RESTORE); + + // Restore users with a minimum of one health (prevent restoring players with <=0 health) + final UserData userData = data.get().userData(); + userData.getStatus().ifPresent(status -> status.health = Math.max(1, status.health)); + + // Set the users data and send a message + plugin.getDatabase().setUserData(user, userData, DataSaveCause.BACKUP_RESTORE); plugin.getRedisManager().sendUserDataUpdate(user, data.get().userData()).join(); plugin.getLocales().getLocale("data_restored", user.username,