9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-19 15:09:19 +00:00

feat: add config options to prevent damage while in the wardrobe

This commit is contained in:
LoJoSho
2024-01-17 12:45:04 -06:00
parent e2d334db9d
commit b3e0acbcbd
3 changed files with 18 additions and 1 deletions

View File

@@ -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<String, Wardrobe> 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);

View File

@@ -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();
}
}

View File

@@ -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