Commits
Jakub Zacek authored and md_5 committed 9477fa26f2d
72 72 | import org.bukkit.block.data.type.StructureBlock; |
73 73 | import org.bukkit.block.data.type.Switch; |
74 74 | import org.bukkit.block.data.type.TNT; |
75 75 | import org.bukkit.block.data.type.TechnicalPiston; |
76 76 | import org.bukkit.block.data.type.TrapDoor; |
77 77 | import org.bukkit.block.data.type.Tripwire; |
78 78 | import org.bukkit.block.data.type.TripwireHook; |
79 79 | import org.bukkit.block.data.type.TurtleEgg; |
80 80 | import org.bukkit.block.data.type.Wall; |
81 81 | import org.bukkit.block.data.type.WallSign; |
82 + | import org.bukkit.inventory.EquipmentSlot; |
82 83 | import org.bukkit.material.MaterialData; |
83 84 | import org.jetbrains.annotations.NotNull; |
84 85 | import org.jetbrains.annotations.Nullable; |
85 86 | |
86 87 | /** |
87 88 | * An enum of all material IDs accepted by the official server and client |
88 89 | */ |
89 90 | public enum Material implements Keyed { |
90 91 | //<editor-fold desc="Materials" defaultstate="collapsed"> |
91 92 | AIR(9648, 0), |
8608 8609 | case MILK_BUCKET: |
8609 8610 | return BUCKET; |
8610 8611 | case DRAGON_BREATH: |
8611 8612 | case HONEY_BOTTLE: |
8612 8613 | return GLASS_BOTTLE; |
8613 8614 | default: |
8614 8615 | return null; |
8615 8616 | // </editor-fold> |
8616 8617 | } |
8617 8618 | } |
8619 + | |
8620 + | /** |
8621 + | * Get the best suitable slot for this Material. |
8622 + | * |
8623 + | * For most items this will be {@link EquipmentSlot#HAND}. |
8624 + | * |
8625 + | * @return the best EquipmentSlot for this Material |
8626 + | */ |
8627 + | |
8628 + | public EquipmentSlot getEquipmentSlot() { |
8629 + | Validate.isTrue(isItem(), "The Material is not an item!"); |
8630 + | switch (this) { |
8631 + | // <editor-fold defaultstate="collapsed" desc="getEquipmentSlot"> |
8632 + | case CARVED_PUMPKIN: |
8633 + | case CHAINMAIL_HELMET: |
8634 + | case CREEPER_HEAD: |
8635 + | case DIAMOND_HELMET: |
8636 + | case DRAGON_HEAD: |
8637 + | case GOLDEN_HELMET: |
8638 + | case IRON_HELMET: |
8639 + | case LEATHER_HELMET: |
8640 + | case NETHERITE_HELMET: |
8641 + | case PLAYER_HEAD: |
8642 + | case SKELETON_SKULL: |
8643 + | case TURTLE_HELMET: |
8644 + | case WITHER_SKELETON_SKULL: |
8645 + | case ZOMBIE_HEAD: |
8646 + | return EquipmentSlot.HEAD; |
8647 + | case CHAINMAIL_CHESTPLATE: |
8648 + | case DIAMOND_CHESTPLATE: |
8649 + | case ELYTRA: |
8650 + | case GOLDEN_CHESTPLATE: |
8651 + | case IRON_CHESTPLATE: |
8652 + | case LEATHER_CHESTPLATE: |
8653 + | case NETHERITE_CHESTPLATE: |
8654 + | return EquipmentSlot.CHEST; |
8655 + | case CHAINMAIL_LEGGINGS: |
8656 + | case DIAMOND_LEGGINGS: |
8657 + | case GOLDEN_LEGGINGS: |
8658 + | case IRON_LEGGINGS: |
8659 + | case LEATHER_LEGGINGS: |
8660 + | case NETHERITE_LEGGINGS: |
8661 + | return EquipmentSlot.LEGS; |
8662 + | case CHAINMAIL_BOOTS: |
8663 + | case DIAMOND_BOOTS: |
8664 + | case GOLDEN_BOOTS: |
8665 + | case IRON_BOOTS: |
8666 + | case LEATHER_BOOTS: |
8667 + | case NETHERITE_BOOTS: |
8668 + | return EquipmentSlot.FEET; |
8669 + | case SHIELD: |
8670 + | return EquipmentSlot.OFF_HAND; |
8671 + | default: |
8672 + | return EquipmentSlot.HAND; |
8673 + | // </editor-fold> |
8674 + | } |
8675 + | } |
8618 8676 | } |