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 55e82ef4..ae78e774 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java @@ -33,6 +33,8 @@ public class WardrobeSettings { 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 DAMAGE_KICK_PATH = "damage-kicked"; + private static final String PREVENT_DAMAGE_PATH = "prevent-damage"; private static final String WARDROBE_MENU_OPTIONS = "menu-options"; private static final String WARDROBE_ENTER_OPEN_MENU_PATH = "enter-open-menu"; @@ -87,6 +89,10 @@ public class WardrobeSettings { @Getter private static boolean forceExitGamemode; @Getter + private static boolean damagedKicked; + @Getter + private static boolean preventDamage; + @Getter private static GameMode exitGamemode; private static HashMap wardrobes; @Getter @@ -121,6 +127,8 @@ public class WardrobeSettings { equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean(); returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false); tryCosmeticsInWardrobe = source.node(TRY_COSMETICS_WARDROBE).getBoolean(false); + damagedKicked = source.node(DAMAGE_KICK_PATH).getBoolean(false); + preventDamage = source.node(PREVENT_DAMAGE_PATH).getBoolean(true); ConfigurationNode menuOptionsNode = source.node(WARDROBE_MENU_OPTIONS); enterOpenMenu = menuOptionsNode.node(WARDROBE_ENTER_OPEN_MENU_PATH).getBoolean(false); diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerGameListener.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerGameListener.java index fb19b6c4..1aa72922 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerGameListener.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerGameListener.java @@ -11,6 +11,7 @@ import com.comphenix.protocol.wrappers.Pair; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.api.events.PlayerCosmeticPostEquipEvent; import com.hibiscusmc.hmccosmetics.config.Settings; +import com.hibiscusmc.hmccosmetics.config.WardrobeSettings; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType; @@ -195,7 +196,11 @@ public class PlayerGameListener implements Listener { } } if (user.isInWardrobe()) { - user.leaveWardrobe(); + if (WardrobeSettings.isPreventDamage()) { + event.setCancelled(true); + return; + } + if (WardrobeSettings.isDamagedKicked()) user.leaveWardrobe(); } } diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml index 110b8f41..1f68a6a0 100644 --- a/common/src/main/resources/config.yml +++ b/common/src/main/resources/config.yml @@ -115,6 +115,10 @@ wardrobe: 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 + # If HMCC should prevent a player from being damaged while being in the wardrobe + prevent-damage: true + # If a player is damaged in a wardrobe, and if it's set to true, it'll kick them from the wardrobe (prevent-damage must be false) + damage-kicked: false menu-options: enter-open-menu: false # If the menu should open when a player enters a wardrobe