2021-05-11 14:10:45 +02:00
|
|
|
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.*;
|
|
|
|
|
2021-05-11 14:10:45 +02:00
|
|
|
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;
|
|
|
|
}
|
2021-05-11 14:10:45 +02:00
|
|
|
|
2021-05-11 14:12:19 +02:00
|
|
|
public boolean isHand() {
|
2021-08-24 07:23:44 +02:00
|
|
|
return !armor;
|
2021-05-11 14:12:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isArmor() {
|
2021-08-24 07:23:44 +02:00
|
|
|
return armor;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int armorSlot() {
|
|
|
|
return armorSlot;
|
2021-05-11 14:12:19 +02:00
|
|
|
}
|
|
|
|
|
2021-07-27 09:40:57 +02:00
|
|
|
public static EquipmentSlot fromAttributeSlot(@NotNull AttributeSlot attributeSlot) {
|
2021-05-11 14:10:45 +02:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|