mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-05 16:49:39 +00:00
#597: Implemented Material#getEquipmentSlot() method
This commit is contained in:
parent
b302317a95
commit
9477fa26f2
1 changed files with 58 additions and 0 deletions
|
@ -79,6 +79,7 @@ import org.bukkit.block.data.type.TripwireHook;
|
||||||
import org.bukkit.block.data.type.TurtleEgg;
|
import org.bukkit.block.data.type.TurtleEgg;
|
||||||
import org.bukkit.block.data.type.Wall;
|
import org.bukkit.block.data.type.Wall;
|
||||||
import org.bukkit.block.data.type.WallSign;
|
import org.bukkit.block.data.type.WallSign;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -8615,4 +8616,61 @@ public enum Material implements Keyed {
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the best suitable slot for this Material.
|
||||||
|
*
|
||||||
|
* For most items this will be {@link EquipmentSlot#HAND}.
|
||||||
|
*
|
||||||
|
* @return the best EquipmentSlot for this Material
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public EquipmentSlot getEquipmentSlot() {
|
||||||
|
Validate.isTrue(isItem(), "The Material is not an item!");
|
||||||
|
switch (this) {
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="getEquipmentSlot">
|
||||||
|
case CARVED_PUMPKIN:
|
||||||
|
case CHAINMAIL_HELMET:
|
||||||
|
case CREEPER_HEAD:
|
||||||
|
case DIAMOND_HELMET:
|
||||||
|
case DRAGON_HEAD:
|
||||||
|
case GOLDEN_HELMET:
|
||||||
|
case IRON_HELMET:
|
||||||
|
case LEATHER_HELMET:
|
||||||
|
case NETHERITE_HELMET:
|
||||||
|
case PLAYER_HEAD:
|
||||||
|
case SKELETON_SKULL:
|
||||||
|
case TURTLE_HELMET:
|
||||||
|
case WITHER_SKELETON_SKULL:
|
||||||
|
case ZOMBIE_HEAD:
|
||||||
|
return EquipmentSlot.HEAD;
|
||||||
|
case CHAINMAIL_CHESTPLATE:
|
||||||
|
case DIAMOND_CHESTPLATE:
|
||||||
|
case ELYTRA:
|
||||||
|
case GOLDEN_CHESTPLATE:
|
||||||
|
case IRON_CHESTPLATE:
|
||||||
|
case LEATHER_CHESTPLATE:
|
||||||
|
case NETHERITE_CHESTPLATE:
|
||||||
|
return EquipmentSlot.CHEST;
|
||||||
|
case CHAINMAIL_LEGGINGS:
|
||||||
|
case DIAMOND_LEGGINGS:
|
||||||
|
case GOLDEN_LEGGINGS:
|
||||||
|
case IRON_LEGGINGS:
|
||||||
|
case LEATHER_LEGGINGS:
|
||||||
|
case NETHERITE_LEGGINGS:
|
||||||
|
return EquipmentSlot.LEGS;
|
||||||
|
case CHAINMAIL_BOOTS:
|
||||||
|
case DIAMOND_BOOTS:
|
||||||
|
case GOLDEN_BOOTS:
|
||||||
|
case IRON_BOOTS:
|
||||||
|
case LEATHER_BOOTS:
|
||||||
|
case NETHERITE_BOOTS:
|
||||||
|
return EquipmentSlot.FEET;
|
||||||
|
case SHIELD:
|
||||||
|
return EquipmentSlot.OFF_HAND;
|
||||||
|
default:
|
||||||
|
return EquipmentSlot.HAND;
|
||||||
|
// </editor-fold>
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue