diff --git a/changelog.md b/changelog.md index a6afc69..45f9ccb 100644 --- a/changelog.md +++ b/changelog.md @@ -14,6 +14,7 @@ These changes will (most likely) be included in the next version. - A new `ready` state is now available for arena sign templates. Signs are in this state when all players in the lobby have readied up, but the arena has not yet started due to a start delay timer. Check the wiki for details. - Arena signs now support dynamic list entry variables for 4 different player lists. As an example, `` results in the name of a player in the lobby who hasn't readied up yet. This is useful for visualizing who is holding up the lobby. Check the wiki for details. - Elytra are now supported chest pieces in class chests. +- Elytra and Netherite armor pieces now correctly auto-equip if specified in the generic `armor` node in classes in the config-file. - Boss names now support color codes. - The Root Target ability now uses potion effects (slowness, slow falling, and negative jump boost) instead of repeated teleports. This should make for a smoother root experience. - Config-files with missing `pet-items` nodes no longer errors. A missing `pet-items` node in `global-settings` is treated as empty, i.e. no pet items will be registered. diff --git a/src/main/java/com/garbagemule/MobArena/things/Equippable.java b/src/main/java/com/garbagemule/MobArena/things/Equippable.java index dfa99d8..b25659b 100644 --- a/src/main/java/com/garbagemule/MobArena/things/Equippable.java +++ b/src/main/java/com/garbagemule/MobArena/things/Equippable.java @@ -1,45 +1,13 @@ package com.garbagemule.MobArena.things; -import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import java.util.EnumSet; - class Equippable { @FunctionalInterface interface Wrapper { ItemStackThing wrap(ItemStack stack); } - private static EnumSet helmets = EnumSet.of( - Material.LEATHER_HELMET, - Material.IRON_HELMET, - Material.CHAINMAIL_HELMET, - Material.GOLDEN_HELMET, - Material.DIAMOND_HELMET - ); - private static EnumSet chestplates = EnumSet.of( - Material.LEATHER_CHESTPLATE, - Material.IRON_CHESTPLATE, - Material.CHAINMAIL_CHESTPLATE, - Material.GOLDEN_CHESTPLATE, - Material.DIAMOND_CHESTPLATE - ); - private static EnumSet leggings = EnumSet.of( - Material.LEATHER_LEGGINGS, - Material.IRON_LEGGINGS, - Material.CHAINMAIL_LEGGINGS, - Material.GOLDEN_LEGGINGS, - Material.DIAMOND_LEGGINGS - ); - private static EnumSet boots = EnumSet.of( - Material.LEATHER_BOOTS, - Material.IRON_BOOTS, - Material.CHAINMAIL_BOOTS, - Material.GOLDEN_BOOTS, - Material.DIAMOND_BOOTS - ); - static Wrapper getWrapperByPrefix(String prefix) { if (prefix.equals("helmet")) { return HelmetThing::new; @@ -60,17 +28,19 @@ class Equippable { } static Wrapper guessWrapperFromItemStack(ItemStack stack) { - Material type = stack.getType(); - if (helmets.contains(type)) { + String name = stack.getType().name(); + String[] parts = name.split("_"); + String suffix = parts[parts.length - 1]; + if (suffix.equals("HELMET")) { return HelmetThing::new; } - if (chestplates.contains(type)) { + if (suffix.equals("CHESTPLATE") || name.equals("ELYTRA")) { return ChestplateThing::new; } - if (leggings.contains(type)) { + if (suffix.equals("LEGGINGS")) { return LeggingsThing::new; } - if (boots.contains(type)) { + if (suffix.equals("BOOTS")) { return BootsThing::new; } return null;