diff --git a/src/main/java/kamkeel/npcs/controllers/ProfileController.java b/src/main/java/kamkeel/npcs/controllers/ProfileController.java index ceb138285..47de460df 100644 --- a/src/main/java/kamkeel/npcs/controllers/ProfileController.java +++ b/src/main/java/kamkeel/npcs/controllers/ProfileController.java @@ -518,8 +518,7 @@ public class ProfileController implements IProfileHandler { if (EventHooks.onProfileChange(handler, scriptPlayer, profile, newSlotId, prevSlot, false)) return ProfileOperation.error(MSG_CANCELLED); - - saveSlotData(profile.player); + saveSlotData(profile.player, profile, prevSlot); profile.currentSlotId = newSlotId; loadSlotData(profile.player); @@ -627,17 +626,16 @@ public class ProfileController implements IProfileHandler { return result; } - public void saveSlotData(EntityPlayer player) { - if (player == null || !activeProfiles.containsKey(player.getUniqueID())) + private void saveSlotData(EntityPlayer player, Profile profile, int slotId) { + if (player == null || profile == null) return; - Profile profile = activeProfiles.get(player.getUniqueID()); if (profile.isLocked()) { return; } - ISlot slot = profile.getSlots().get(profile.getCurrentSlotId()); + ISlot slot = profile.getSlots().get(slotId); if (slot == null) { - slot = new Slot(profile.getCurrentSlotId(), "Slot " + profile.getCurrentSlotId()); - profile.getSlots().put(profile.getCurrentSlotId(), slot); + slot = new Slot(slotId, "Slot " + slotId); + profile.getSlots().put(slotId, slot); } for (IProfileData profileData : profileTypes.values()) { NBTTagCompound cloned = (NBTTagCompound) profileData.getCurrentNBT(player).copy(); @@ -646,6 +644,13 @@ public class ProfileController implements IProfileHandler { slot.setLastLoaded(System.currentTimeMillis()); } + public void saveSlotData(EntityPlayer player) { + if (player == null || !activeProfiles.containsKey(player.getUniqueID())) + return; + Profile profile = activeProfiles.get(player.getUniqueID()); + saveSlotData(player, profile, profile.getCurrentSlotId()); + } + public void loadSlotData(EntityPlayer player) { if (player == null || !activeProfiles.containsKey(player.getUniqueID())) return;