From ce1f652d5381e60d3a2b87090715bbb4bcc9d530 Mon Sep 17 00:00:00 2001 From: Kam Date: Fri, 21 Feb 2025 17:23:51 -0500 Subject: [PATCH] Fix Slot Creation Quest Syncing --- .../npcs/controllers/ProfileController.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/kamkeel/npcs/controllers/ProfileController.java b/src/main/java/kamkeel/npcs/controllers/ProfileController.java index 3cfac441c..2f02a68a2 100644 --- a/src/main/java/kamkeel/npcs/controllers/ProfileController.java +++ b/src/main/java/kamkeel/npcs/controllers/ProfileController.java @@ -389,10 +389,11 @@ public class ProfileController implements IProfileController { } Slot newSlot = new Slot(newSlotId, "Slot " + newSlotId); newSlot.setLastLoaded(System.currentTimeMillis()); - if(profile.player != null) - verifySlotQuests(profile.player); - profile.getSlots().put(newSlotId, newSlot); + if(profile.player != null){ + verifySlotQuests(profile.player); + save(profile.player, profile); + } return ProfileOperation.success(MSG_NEW_SLOT_CREATED); } @@ -708,7 +709,7 @@ public class ProfileController implements IProfileController { playerData = PlayerData.get(player); } else { Slot slot = (Slot) profile.getSlots().get(slotID); - return getSlotPlayerData(player, slot); + playerData = getSlotPlayerData(player, slot); } return playerData; } @@ -719,7 +720,11 @@ public class ProfileController implements IProfileController { PlayerData playerData = new PlayerData(); playerData.player = player; - playerData.setNBT(slot.getComponentData(new CNPCData().getTagName())); + + NBTTagCompound compound = slot.getComponentData(new CNPCData().getTagName()); + if(compound == null) + compound = new NBTTagCompound(); + playerData.setNBT(compound); return playerData; } @@ -752,8 +757,10 @@ public class ProfileController implements IProfileController { for (ISlot slot : profile.getSlots().values()) { IPlayerData data = getSlotPlayerData(player, slot.getId()); if (data != null) { + PlayerData playerData = (PlayerData) data; PlayerQuestData questData = (PlayerQuestData) data.getQuestData(); questData.finishedQuests.putAll(universalFinished); + slot.setComponentData(new CNPCData().getTagName(), playerData.getNBT()); } } }