Fixed health bonuses not working in MMOInv when logging in

This commit is contained in:
Jules 2024-04-18 15:04:23 -07:00
parent c78cafd402
commit ed76008a4f
4 changed files with 14 additions and 8 deletions

View File

@ -119,7 +119,9 @@ public class PlayerData extends SynchronizedDataHolder implements Closeable {
}
public void updateInventory() {
if (!isOnline()) return;
// Cannot update inventory unless online and fully sync
if (!isOnline() || !getMMOPlayerData().hasFullySynchronized()) return;
/*
* Very important, clear particle data AFTER canceling the runnable

View File

@ -5,6 +5,7 @@ import net.Indyuce.mmoitems.api.ConfigFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.function.Supplier;
import java.util.logging.Level;
/**
@ -20,7 +21,7 @@ public class LanguageFile extends ConfigFile {
}
@NotNull
public String computeTranslation(String path, Provider<String> defaultTranslation) {
public String computeTranslation(String path, Supplier<String> defaultTranslation) {
@Nullable String found = getConfig().getString(path);
if (found == null) {
change = true;

View File

@ -1,6 +0,0 @@
package net.Indyuce.mmoitems.util;
@FunctionalInterface
public interface Provider<T> {
T get();
}

View File

@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.listener;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.event.PlayerAttackEvent;
import io.lumine.mythic.lib.api.event.SynchronizedDataLoadEvent;
import io.lumine.mythic.lib.api.event.armorequip.ArmorEquipEvent;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
@ -54,6 +55,14 @@ public class PlayerListener implements Listener {
new DelayedDeathDowngrade(event).runTaskLater(MMOItems.plugin, 3L);
}
@EventHandler
public void fullSync(SynchronizedDataLoadEvent event) {
if (event.syncIsFull()) {
final PlayerData playerData = PlayerData.get(event.getHolder().getUniqueId());
playerData.updateInventory();
}
}
/**
* Prevent players from dropping items which are bound to them with a
* Soulbound. Items are cached inside a map waiting for the player to