From 04810b91efdefd6702691c4aa0e24e619adeac7a Mon Sep 17 00:00:00 2001 From: LoJoSho Date: Tue, 23 May 2023 11:11:24 -0500 Subject: [PATCH] feat: add ability to select any cosmetic in wardrobe, resolves #55 --- .../hibiscusmc/hmccosmetics/config/WardrobeSettings.java | 7 +++++++ .../com/hibiscusmc/hmccosmetics/user/CosmeticUser.java | 1 + .../hmccosmetics/user/manager/UserWardrobeManager.java | 4 +--- common/src/main/resources/config.yml | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java index 45fbff69..92ab5333 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java @@ -32,6 +32,7 @@ public class WardrobeSettings { private static final String VIEWER_LOCATION_PATH = "viewer-location"; private static final String LEAVE_LOCATION_PATH = "leave-location"; private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin"; + private static final String TRY_COSMETICS_WARDROBE = "unchecked-wardrobe-cosmetics"; private static final String RETURN_LAST_LOCATION = "return-last-location"; private static final String GAMEMODE_OPTIONS_PATH = "gamemode-options"; private static final String FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled"; @@ -61,6 +62,7 @@ public class WardrobeSettings { private static int despawnDelay; private static float bossbarProgress; private static boolean applyCosmeticsOnClose; + private static boolean tryCosmeticsInWardrobe; private static boolean equipPumpkin; private static boolean returnLastLocation; private static boolean enabledBossbar; @@ -91,6 +93,7 @@ public class WardrobeSettings { applyCosmeticsOnClose = source.node(APPLY_COSMETICS_ON_CLOSE).getBoolean(); equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean(); returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false); + tryCosmeticsInWardrobe = source.node(TRY_COSMETICS_WARDROBE).getBoolean(false); ConfigurationNode gamemodeNode = source.node(GAMEMODE_OPTIONS_PATH); forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false); @@ -267,6 +270,10 @@ public class WardrobeSettings { return exitGamemode; } + public static boolean isTryCosmeticsInWardrobe() { + return tryCosmeticsInWardrobe; + } + /** * Sets where the NPC/Mannequin will spawn in the wardrobe * @param newLocation diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java index 5f9add77..b5244c07 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java @@ -376,6 +376,7 @@ public class CosmeticUser { public boolean canEquipCosmetic(Cosmetic cosmetic) { if (!cosmetic.requiresPermission()) return true; + if (isInWardrobe() && WardrobeSettings.isTryCosmeticsInWardrobe()) return true; if (getPlayer().hasPermission(cosmetic.getPermission())) return true; return false; } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java index f73c95c9..a59bd4d0 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java @@ -215,9 +215,7 @@ public class UserWardrobeManager { // For Wardrobe Temp Cosmetics for (Cosmetic cosmetic : user.getCosmetics()) { - if (cosmetic.requiresPermission()) { - if (!player.hasPermission(cosmetic.getPermission())) user.removeCosmeticSlot(cosmetic.getSlot()); - } + if (!user.canEquipCosmetic(cosmetic)) user.removeCosmeticSlot(cosmetic.getSlot()); } user.updateCosmetic(); diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml index 52910a5d..2ccdabf9 100644 --- a/common/src/main/resources/config.yml +++ b/common/src/main/resources/config.yml @@ -71,6 +71,8 @@ wardrobe: equip-pumpkin: false # Rather than having a set exit location, this will send the player back to where they entered the wardrobe. Not recommended for WG regions return-last-location: false + # If players in wardrobes should be able to equip any cosmetic, regardless of permission (Cosmetics they do not have access to will be removed when they leave the wardrobe) + unchecked-wardrobe-cosmetics: false gamemode-options: exit-gamemode-enabled: false # Setting this to false will set the gamemode the player came in as. True sets to exit-gamemode gamemode