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;
|
|
|
|
|
2022-05-07 17:19:51 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
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);
|
|
|
|
|
2022-05-07 17:19:51 +02:00
|
|
|
private static final List<EquipmentSlot> ARMORS = List.of(BOOTS, LEGGINGS, CHESTPLATE, HELMET);
|
|
|
|
|
2021-08-24 07:23:44 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-05-07 17:19:51 +02:00
|
|
|
public static @NotNull List<@NotNull EquipmentSlot> armors() {
|
|
|
|
return ARMORS;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static @NotNull EquipmentSlot fromAttributeSlot(@NotNull AttributeSlot attributeSlot) {
|
2021-10-22 01:55:55 +02:00
|
|
|
return switch (attributeSlot) {
|
|
|
|
case MAINHAND -> MAIN_HAND;
|
|
|
|
case OFFHAND -> OFF_HAND;
|
|
|
|
case FEET -> BOOTS;
|
|
|
|
case LEGS -> LEGGINGS;
|
|
|
|
case CHEST -> CHESTPLATE;
|
|
|
|
case HEAD -> HELMET;
|
|
|
|
};
|
2021-05-11 14:10:45 +02:00
|
|
|
}
|
|
|
|
}
|