Fixed issue #869 about health not syncing between servers.

This commit is contained in:
Ka0rX 2023-06-25 21:41:05 +01:00
parent a7af0e1ca7
commit 59ad3259cc
7 changed files with 12 additions and 30 deletions

View File

@ -6,6 +6,7 @@ import io.lumine.mythic.lib.api.stat.StatInstance;
import io.lumine.mythic.lib.api.stat.modifier.StatModifier;
import io.lumine.mythic.lib.data.SynchronizedDataHolder;
import io.lumine.mythic.lib.player.cooldown.CooldownMap;
import io.lumine.mythic.lib.util.Closeable;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.ConfigMessage;
import net.Indyuce.mmocore.api.SoundEvent;
@ -25,7 +26,6 @@ import net.Indyuce.mmocore.api.player.stats.PlayerStats;
import net.Indyuce.mmocore.api.quest.PlayerQuests;
import net.Indyuce.mmocore.api.quest.trigger.StatTrigger;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.Indyuce.mmocore.api.util.Closable;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.experience.EXPSource;
import net.Indyuce.mmocore.experience.ExperienceObject;
@ -69,7 +69,7 @@ import java.util.*;
import java.util.logging.Level;
import java.util.stream.Collectors;
public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerData, Closable, ExperienceTableClaimer, ClassDataContainer {
public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerData, Closeable, ExperienceTableClaimer, ClassDataContainer {
/**
* Can be null, the {@link #getProfess()} method will return the

View File

@ -1,15 +1,14 @@
package net.Indyuce.mmocore.api.quest;
import io.lumine.mythic.lib.util.Closeable;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.Closable;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import net.Indyuce.mmocore.api.quest.objective.Objective;
public abstract class ObjectiveProgress implements Closable {
public abstract class ObjectiveProgress implements Closeable {
private final Objective objective;
private final QuestProgress questProgress;

View File

@ -3,9 +3,9 @@ package net.Indyuce.mmocore.api.quest;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.lumine.mythic.lib.util.Closeable;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.Closable;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.boss.BarColor;
@ -21,7 +21,7 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.logging.Level;
public class PlayerQuests implements Closable {
public class PlayerQuests implements Closeable {
private final PlayerData playerData;
private final Map<String, Long> finished = new HashMap<>();

View File

@ -1,15 +0,0 @@
package net.Indyuce.mmocore.api.util;
/**
* Indicates that a class temporarily registers something
* such as a Bukkit event, which needs to be unregistered
* when the class is finally garbage collected.
*/
public interface Closable {
/**
* Method that must be called before the class
* is garbage collected
*/
void close();
}

View File

@ -123,13 +123,11 @@ public class MMOCoreDataSynchronizer extends SQLDataSynchronizer<PlayerData> {
* These should be loaded after to make sure that the
* MAX_MANA, MAX_STAMINA & MAX_STELLIUM stats are already loaded.
*/
getData().setHealth(result.getDouble("health"));
double health = result.getDouble("health");
getData().setMana(result.getDouble("mana"));
getData().setStamina(result.getDouble("stamina"));
getData().setStellium(result.getDouble("stellium"));
if (getData().isOnline()) {
double health = getData().getHealth();
health = health == 0 ? getData().getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() : health;
health = Math.max(Math.min(health, getData().getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()), 0);
getData().getPlayer().setHealth(health);

View File

@ -1,16 +1,16 @@
package net.Indyuce.mmocore.player;
import io.lumine.mythic.lib.util.Closeable;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.event.PlayerCombatEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.Closable;
import net.Indyuce.mmocore.command.PvpModeCommand;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.Nullable;
public class CombatHandler implements Closable {
public class CombatHandler implements Closeable {
private final PlayerData player;
private long lastEntry = System.currentTimeMillis(), lastHit = System.currentTimeMillis(), invulnerableTill;

View File

@ -1,15 +1,15 @@
package net.Indyuce.mmocore.skill.binding;
import io.lumine.mythic.lib.player.skill.PassiveSkill;
import io.lumine.mythic.lib.util.Closeable;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.trigger.SkillModifierTrigger;
import net.Indyuce.mmocore.api.util.Closable;
import net.Indyuce.mmocore.skill.ClassSkill;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class BoundSkillInfo implements Closable {
public class BoundSkillInfo implements Closeable {
private final SkillSlot skillSlot;
private final PlayerData playerData;
private final ClassSkill classSkill;