Fixed on-login health issue

This commit is contained in:
Jules 2024-02-20 13:37:29 +01:00
parent 0fd1f6bbce
commit 13e808ba37
2 changed files with 7 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.data.sql.SQLDataSource;
import io.lumine.mythic.lib.metrics.bukkit.Metrics;
import io.lumine.mythic.lib.util.MMOPlugin;
import io.lumine.mythic.lib.version.SpigotPlugin;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.attribute.AttributeModifier;
@ -54,14 +55,13 @@ import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventPriority;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.logging.Level;
public class MMOCore extends JavaPlugin {
public class MMOCore extends MMOPlugin {
public static MMOCore plugin;
public final WaypointManager waypointManager = new WaypointManager();
public final SoundManager soundManager = new SoundManager();

View File

@ -132,7 +132,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
public long lastDropEvent;
public PlayerData(MMOPlayerData mmoData) {
super(mmoData);
super(MMOCore.plugin, mmoData);
questData = new PlayerQuests(this);
playerStats = new PlayerStats(this);
@ -192,8 +192,10 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
* missing from the database and it gives full health to the player. If the
* player is dead however, it must not account for that subtle edge case.
*/
if (isOnline() && !getPlayer().isDead())
getPlayer().setHealth(MMOCoreUtils.fixResource(getHealth(), getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
if (isOnline() && !getPlayer().isDead()) {
final double effectiveHealth = Math.max(getPlayer().getHealth(), getHealth());
getPlayer().setHealth(MMOCoreUtils.fixResource(effectiveHealth, getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
}
// Finally mark synchronized
super.markAsSynchronized();