22
33import com .destroystokyo .paper .event .player .PlayerArmorChangeEvent ;
44import de .tr7zw .changeme .nbtapi .NBT ;
5+ import me .xginko .aef .utils .models .Lazy ;
56import me .xginko .aef .utils .reflection .ReflectionUtil ;
67import net .kyori .adventure .text .Component ;
78import net .kyori .adventure .text .minimessage .MiniMessage ;
@@ -25,7 +26,7 @@ public final class ItemUtil {
2526
2627 public static final boolean MAP_SET_TRACKING_POS_AVAILABLE ;
2728 private static final boolean USE_MINIMSG_BOOKMETA ;
28- private static final Map <PlayerArmorChangeEvent .SlotType , EquipmentSlot > EQUIPMENT_SLOT_MAP ;
29+ private static final Lazy < Map <PlayerArmorChangeEvent .SlotType , EquipmentSlot > > EQUIPMENT_SLOT_MAP ;
2930
3031 static {
3132 MAP_SET_TRACKING_POS_AVAILABLE
@@ -36,15 +37,20 @@ public final class ItemUtil {
3637 && ReflectionUtil .hasMethod (MiniMessage .class , "miniMessage" )
3738 && ReflectionUtil .hasMethod (BookMeta .class , "pages" );
3839
39- EQUIPMENT_SLOT_MAP = new EnumMap <>(PlayerArmorChangeEvent .SlotType .class );
40- EQUIPMENT_SLOT_MAP .put (PlayerArmorChangeEvent .SlotType .HEAD , EquipmentSlot .HEAD );
41- EQUIPMENT_SLOT_MAP .put (PlayerArmorChangeEvent .SlotType .CHEST , EquipmentSlot .CHEST );
42- EQUIPMENT_SLOT_MAP .put (PlayerArmorChangeEvent .SlotType .LEGS , EquipmentSlot .LEGS );
43- EQUIPMENT_SLOT_MAP .put (PlayerArmorChangeEvent .SlotType .FEET , EquipmentSlot .FEET );
40+ EQUIPMENT_SLOT_MAP
41+ = Lazy .of (() -> {
42+ Map <PlayerArmorChangeEvent .SlotType , EquipmentSlot >
43+ slotMap = new EnumMap <>(PlayerArmorChangeEvent .SlotType .class );
44+ slotMap .put (PlayerArmorChangeEvent .SlotType .HEAD , EquipmentSlot .HEAD );
45+ slotMap .put (PlayerArmorChangeEvent .SlotType .CHEST , EquipmentSlot .CHEST );
46+ slotMap .put (PlayerArmorChangeEvent .SlotType .LEGS , EquipmentSlot .LEGS );
47+ slotMap .put (PlayerArmorChangeEvent .SlotType .FEET , EquipmentSlot .FEET );
48+ return slotMap ;
49+ });
4450 }
4551
4652 public static EquipmentSlot getEquipmentSlot (PlayerArmorChangeEvent .SlotType slotType ) {
47- return EQUIPMENT_SLOT_MAP .getOrDefault (slotType , EquipmentSlot .HAND );
53+ return EQUIPMENT_SLOT_MAP .get (). getOrDefault (slotType , EquipmentSlot .HAND );
4854 }
4955
5056 /**
0 commit comments