fn: Fix new skin not loading in npc-update-scheduler

This commit is contained in:
Oliver
2025-04-24 13:27:08 +02:00
parent 039141c44e
commit bbd720a90d

View File

@@ -28,6 +28,7 @@ import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcData; import de.oliver.fancynpcs.api.NpcData;
import de.oliver.fancynpcs.api.NpcManager; import de.oliver.fancynpcs.api.NpcManager;
import de.oliver.fancynpcs.api.actions.types.*; import de.oliver.fancynpcs.api.actions.types.*;
import de.oliver.fancynpcs.api.skins.SkinData;
import de.oliver.fancynpcs.api.skins.SkinManager; import de.oliver.fancynpcs.api.skins.SkinManager;
import de.oliver.fancynpcs.commands.CloudCommandManager; import de.oliver.fancynpcs.commands.CloudCommandManager;
import de.oliver.fancynpcs.listeners.*; import de.oliver.fancynpcs.listeners.*;
@@ -296,15 +297,20 @@ public class FancyNpcs extends JavaPlugin implements FancyNpcsPlugin {
npcThread.scheduleAtFixedRate(() -> { npcThread.scheduleAtFixedRate(() -> {
List<Npc> npcs = new ArrayList<>(npcManager.getAllNpcs()); List<Npc> npcs = new ArrayList<>(npcManager.getAllNpcs());
for (Npc npc : npcs) { for (Npc npc : npcs) {
String skinID = npc.getData().getSkinData().getIdentifier();
boolean skinUpdated = npc.getData().getSkinData() != null && boolean skinUpdated = npc.getData().getSkinData() != null &&
!npc.getData().getSkinData().getIdentifier().isEmpty() && !skinID.isEmpty() &&
SkinUtils.isPlaceholder(npc.getData().getSkinData().getIdentifier()); SkinUtils.isPlaceholder(skinID);
boolean displayNameUpdated = npc.getData().getDisplayName() != null && boolean displayNameUpdated = npc.getData().getDisplayName() != null &&
!npc.getData().getDisplayName().isEmpty() && !npc.getData().getDisplayName().isEmpty() &&
SkinUtils.isPlaceholder(npc.getData().getDisplayName()); SkinUtils.isPlaceholder(npc.getData().getDisplayName());
if (skinUpdated || displayNameUpdated) { if (skinUpdated || displayNameUpdated) {
SkinData skinData = skinManager.getByIdentifier(skinID, npc.getData().getSkinData().getVariant());
skinData.setIdentifier(skinID);
npc.getData().setSkinData(skinData);
npc.removeForAll(); npc.removeForAll();
npc.create(); npc.create();
npc.spawnForAll(); npc.spawnForAll();