Minestom/src/main/java/net/minestom/server/entity/EquipmentSlot.java

54 lines
1.3 KiB
Java
Raw Normal View History

package net.minestom.server.entity;
import net.minestom.server.item.attribute.AttributeSlot;
import org.jetbrains.annotations.NotNull;
2021-08-24 07:23:44 +02:00
import static net.minestom.server.utils.inventory.PlayerInventoryUtils.*;
public enum EquipmentSlot {
2021-08-24 07:23:44 +02:00
MAIN_HAND(false, -1),
OFF_HAND(false, -1),
BOOTS(true, BOOTS_SLOT),
LEGGINGS(true, LEGGINGS_SLOT),
CHESTPLATE(true, CHESTPLATE_SLOT),
HELMET(true, HELMET_SLOT);
private final boolean armor;
private final int armorSlot;
EquipmentSlot(boolean armor, int armorSlot) {
this.armor = armor;
this.armorSlot = armorSlot;
}
public boolean isHand() {
2021-08-24 07:23:44 +02:00
return !armor;
}
public boolean isArmor() {
2021-08-24 07:23:44 +02:00
return armor;
}
public int armorSlot() {
return armorSlot;
}
2021-07-27 09:40:57 +02:00
public static EquipmentSlot fromAttributeSlot(@NotNull AttributeSlot attributeSlot) {
switch (attributeSlot) {
case MAINHAND:
return MAIN_HAND;
case OFFHAND:
return OFF_HAND;
case FEET:
return BOOTS;
case LEGS:
return LEGGINGS;
case CHEST:
return CHESTPLATE;
case HEAD:
return HELMET;
}
throw new IllegalStateException("Something weird happened");
}
}