Skip to content

Commit dc90874

Browse files
committed
fix build fail and init slotmap lazily
1 parent 15e86f1 commit dc90874

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/AnarchyExploitFixes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import me.xginko.aef.config.Translation;
99
import me.xginko.aef.modules.AEFModule;
1010
import me.xginko.aef.utils.LocaleUtil;
11-
import me.xginko.aef.utils.VersionChecker;
11+
import me.xginko.aef.utils.models.VersionChecker;
1212
import me.xginko.aef.utils.enums.Platform;
1313
import me.xginko.aef.utils.permissions.AEFPermission;
1414
import me.xginko.aef.utils.permissions.PermissionHandler;

shared/src/main/java/me/xginko/aef/utils/ItemUtil.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent;
44
import de.tr7zw.changeme.nbtapi.NBT;
5+
import me.xginko.aef.utils.models.Lazy;
56
import me.xginko.aef.utils.reflection.ReflectionUtil;
67
import net.kyori.adventure.text.Component;
78
import 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

Comments
 (0)