diff --git a/src/main/java/kamkeel/npcs/controllers/ProfileController.java b/src/main/java/kamkeel/npcs/controllers/ProfileController.java index 769cdb237..5ff9d1919 100644 --- a/src/main/java/kamkeel/npcs/controllers/ProfileController.java +++ b/src/main/java/kamkeel/npcs/controllers/ProfileController.java @@ -416,38 +416,39 @@ public class ProfileController { if (!profile.slots.containsKey(newSlotId)) { return ProfileOperation.error(MSG_SLOT_NOT_EXIST); } - // Region-based check: if enabled, ensure the player is within an allowed region. - if (ConfigMain.RegionProfileSwitching && profile.player != null) { - boolean allowed = hasPermission(profile.player, PROFILE_REGION_BYPASS); - if(!allowed){ - int playerDim = profile.player.dimension; - int playerX = (int) profile.player.posX; - int playerY = (int) profile.player.posY; - int playerZ = (int) profile.player.posZ; - for (List region : ConfigMain.RestrictedProfileRegions) { - if(region.size() == 7) { - int dim = region.get(0); - int x1 = Math.min(region.get(1), region.get(4)); - int y1 = Math.min(region.get(2), region.get(5)); - int z1 = Math.min(region.get(3), region.get(6)); - int x2 = Math.max(region.get(1), region.get(4)); - int y2 = Math.max(region.get(2), region.get(5)); - int z2 = Math.max(region.get(3), region.get(6)); - if(playerDim == dim && - playerX >= x1 && playerX <= x2 && - playerY >= y1 && playerY <= y2 && - playerZ >= z1 && playerZ <= z2) { - allowed = true; - break; + + if(profile.player != null){ + // Region-based check: if enabled, ensure the player is within an allowed region. + if (ConfigMain.RegionProfileSwitching) { + boolean allowed = hasPermission(profile.player, PROFILE_REGION_BYPASS); + if(!allowed){ + int playerDim = profile.player.dimension; + int playerX = (int) profile.player.posX; + int playerY = (int) profile.player.posY; + int playerZ = (int) profile.player.posZ; + for (List region : ConfigMain.RestrictedProfileRegions) { + if(region.size() == 7) { + int dim = region.get(0); + int x1 = Math.min(region.get(1), region.get(4)); + int y1 = Math.min(region.get(2), region.get(5)); + int z1 = Math.min(region.get(3), region.get(6)); + int x2 = Math.max(region.get(1), region.get(4)); + int y2 = Math.max(region.get(2), region.get(5)); + int z2 = Math.max(region.get(3), region.get(6)); + if(playerDim == dim && + playerX >= x1 && playerX <= x2 && + playerY >= y1 && playerY <= y2 && + playerZ >= z1 && playerZ <= z2) { + allowed = true; + break; + } } } } + if (!allowed) { + return ProfileOperation.error(MSG_REGION_NOT_ALLOWED); + } } - if (!allowed) { - return ProfileOperation.error(MSG_REGION_NOT_ALLOWED); - } - } - if (profile.player != null) { List dataList = new ArrayList<>(profileTypes.values()); dataList.sort(Comparator.comparingInt(IProfileData::getSwitchPriority)); for (IProfileData pd : dataList) { @@ -455,17 +456,17 @@ public class ProfileController { return pd.verifySwitch(profile.player); } } - } - if (profile.player != null) { saveSlotData(profile.player); - } - profile.currentID = newSlotId; - if (profile.player != null) { + profile.currentID = newSlotId; + loadSlotData(profile.player); PlayerData pdata = PlayerData.get(profile.player); pdata.profileSlot = newSlotId; pdata.save(); + } else { + return ProfileOperation.error(MSG_PLAYER_NOT_FOUND); } + return ProfileOperation.success(MSG_CHANGE_SUCCESS); } @@ -525,20 +526,6 @@ public class ProfileController { return result; } - public static ProfileOperation removeSlot(UUID uuid, int slotId) { - Profile profile = getProfile(uuid); - if(profile == null) - return ProfileOperation.error(MSG_PLAYER_NOT_FOUND); - ProfileOperation result = removeSlotInternal(profile, slotId); - if(result.getResult() == EnumProfileOperation.SUCCESS) { - if(profile.player != null) - save(profile.player, profile); - else - saveOffline(profile, uuid); - } - return result; - } - public static ProfileOperation removeSlot(String username, int slotId) { Profile profile = getProfile(username); if(profile == null) @@ -567,20 +554,6 @@ public class ProfileController { return result; } - public static ProfileOperation changeSlot(UUID uuid, int newSlotId) { - Profile profile = getProfile(uuid); - if(profile == null) - return ProfileOperation.error(MSG_PLAYER_NOT_FOUND); - ProfileOperation result = changeSlotInternal(profile, newSlotId); - if(result.getResult() == EnumProfileOperation.SUCCESS) { - if(profile.player != null) - save(profile.player, profile); - else - saveOffline(profile, uuid); - } - return result; - } - public static ProfileOperation changeSlot(String username, int newSlotId) { Profile profile = getProfile(username); if(profile == null) diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java b/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java index 44ec2c744..3e6431a53 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java @@ -124,10 +124,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo // Create top buttons. private void setupTopButtons() { + // Show General Display Information GuiMenuTopButton playerTab = new GuiMenuTopButton(-10, guiLeft + 4, guiTop - 10, playerName); - playerTab.active = false; - playerTab.enabled = false; - playerTab.packedFGColour = CustomNpcResourceListener.DefaultTextColor; GuiMenuTopButton btnQuest = new GuiMenuTopButton(10, playerTab.xPosition + playerTab.getButtonWidth(), guiTop - 10, "quest.quests"); GuiMenuTopButton btnDialog = new GuiMenuTopButton(11, btnQuest.xPosition + btnQuest.getWidth(), guiTop - 10, "dialog.dialogs"); @@ -137,6 +135,7 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo // Close button. GuiMenuTopButton close = new GuiMenuTopButton(-5, guiLeft + xSize - 22, guiTop - 10, "X"); + playerTab.active = (currentTab == -10); btnQuest.active = (currentTab == 10); btnDialog.active = (currentTab == 11); btnTransport.active = (currentTab == 12); @@ -414,7 +413,6 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo int paddingTopBottom = 25; int scrollHeight = getScrollHeight(); int paddedLeft = getPaddedLeft(); - int availableWidth = getAvailableWidth(); int widthPadding = 1; GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); @@ -436,7 +434,6 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo } GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPopAttrib(); - // Compact mode for Dialog/Transport uses one scroll => no divider. } ////////////////////////////////////////////////////////////////////////////////