2
2
3
3
import com .destroystokyo .paper .event .player .PlayerArmorChangeEvent ;
4
4
import de .tr7zw .changeme .nbtapi .NBT ;
5
+ import me .xginko .aef .utils .models .Lazy ;
5
6
import me .xginko .aef .utils .reflection .ReflectionUtil ;
6
7
import net .kyori .adventure .text .Component ;
7
8
import net .kyori .adventure .text .minimessage .MiniMessage ;
@@ -25,7 +26,7 @@ public final class ItemUtil {
25
26
26
27
public static final boolean MAP_SET_TRACKING_POS_AVAILABLE ;
27
28
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 ;
29
30
30
31
static {
31
32
MAP_SET_TRACKING_POS_AVAILABLE
@@ -36,15 +37,20 @@ public final class ItemUtil {
36
37
&& ReflectionUtil .hasMethod (MiniMessage .class , "miniMessage" )
37
38
&& ReflectionUtil .hasMethod (BookMeta .class , "pages" );
38
39
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
+ });
44
50
}
45
51
46
52
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 );
48
54
}
49
55
50
56
/**
0 commit comments