diff --git a/build.gradle.kts b/build.gradle.kts index 0584c8ed..c0ba2460 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "com.hibiscusmc" -version = "2.7.0-DEV" +version = "2.7.2-DEV" allprojects { apply(plugin = "java") diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java index 83f701c2..8de84420 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java @@ -113,9 +113,7 @@ public class CosmeticCommand implements CommandExecutor { if (!textColor.contains("#") && Hooks.isActiveHook("HMCColor")) { HMCColorConfig.Colors colors = HMCColorContextKt.getHmcColor().getConfig().getColors().get(textColor); if (colors != null) { - String hmccolor = colors.getBaseColor().getColor(); - if (hmccolor.contains("#")) color = HMCCServerUtils.hex2Rgb(hmccolor); - else color = HMCCServerUtils.rgbToRgb(hmccolor); + color = colors.getBaseColor().getColor(); } } else { color = HMCCServerUtils.hex2Rgb(textColor); 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/gui/special/DyeMenu.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenu.java index d101a39a..dfc50dd6 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenu.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenu.java @@ -31,7 +31,7 @@ public class DyeMenu { ItemStack originalItem = user.getUserCosmeticItem(cosmetic); if (originalItem == null || !cosmetic.isDyable()) return; - Gui gui = HMCColorApi.INSTANCE.colorMenu(); + Gui gui = HMCColorApi.createColorMenu(player); gui.updateTitle(Hooks.processPlaceholders(player, Settings.getDyeMenuName())); gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem)); gui.setDefaultTopClickAction(event -> { 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/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java index 48a16193..7c9c5f42 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 @@ -31,10 +31,7 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.UUID; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; public class UserWardrobeManager { @@ -202,7 +199,8 @@ public class UserWardrobeManager { List outsideViewers = HMCCPacketManager.getViewers(viewingLocation); outsideViewers.remove(player); - if (player != null) MessagesUtil.sendMessage(player, "closed-wardrobe"); + if (player == null) return; + MessagesUtil.sendMessage(player, "closed-wardrobe"); Runnable run = () -> { this.active = false; @@ -252,9 +250,17 @@ public class UserWardrobeManager { player.teleport(Objects.requireNonNullElseGet(exitLocation, () -> player.getWorld().getSpawnLocation()), PlayerTeleportEvent.TeleportCause.PLUGIN); - if (WardrobeSettings.isEquipPumpkin()) { - PacketManager.equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, player.getInventory().getHelmet(), viewer); + HashMap items = new HashMap<>(); + for (EquipmentSlot slot : EquipmentSlot.values()) { + ItemStack item = player.getInventory().getItem(slot); + items.put(slot, item); } + /* + if (WardrobeSettings.isEquipPumpkin()) { + items.put(EquipmentSlot.HEAD, player.getInventory().getHelmet()); + } + */ + HMCCPacketManager.equipmentSlotUpdate(player.getEntityId(), items, viewer); if (WardrobeSettings.isEnabledBossbar()) { Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player); diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml index 2f64023d..cd252978 100644 --- a/common/src/main/resources/config.yml +++ b/common/src/main/resources/config.yml @@ -118,6 +118,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 diff --git a/lib/HMCColor-0.8-all.jar b/lib/HMCColor-0.8-all.jar deleted file mode 100644 index f27d9834..00000000 Binary files a/lib/HMCColor-0.8-all.jar and /dev/null differ diff --git a/lib/HMCColor-0.8.6.jar b/lib/HMCColor-0.8.6.jar new file mode 100644 index 00000000..a5e4b23a Binary files /dev/null and b/lib/HMCColor-0.8.6.jar differ