diff --git a/api/src/main/java/net/momirealms/customnameplates/api/CustomNameplates.java b/api/src/main/java/net/momirealms/customnameplates/api/CustomNameplates.java index 0496cc2..2af4ba6 100644 --- a/api/src/main/java/net/momirealms/customnameplates/api/CustomNameplates.java +++ b/api/src/main/java/net/momirealms/customnameplates/api/CustomNameplates.java @@ -70,7 +70,7 @@ public abstract class CustomNameplates implements NameplatesPlugin { protected MainTask mainTask; protected SchedulerTask scheduledMainTask; protected ConcurrentHashMap onlinePlayerMap = new ConcurrentHashMap<>(); - protected Int2ObjectOpenHashMap entityIDFastLookup = new Int2ObjectOpenHashMap<>(); + protected ConcurrentHashMap entityIDFastLookup = new ConcurrentHashMap<>(); protected AdvanceManager advanceManager; protected BackgroundManager backgroundManager; protected EventManager eventManager; diff --git a/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/BukkitPlatform.java b/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/BukkitPlatform.java index 3caa8a0..c6a481b 100644 --- a/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/BukkitPlatform.java +++ b/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/BukkitPlatform.java @@ -19,6 +19,8 @@ package net.momirealms.customnameplates.bukkit; import it.unimi.dsi.fastutil.ints.IntList; import me.clip.placeholderapi.PlaceholderAPI; +import net.kyori.adventure.platform.bukkit.BukkitAudiences; +import net.kyori.adventure.text.Component; import net.momirealms.customnameplates.api.CNPlayer; import net.momirealms.customnameplates.api.ConfigManager; import net.momirealms.customnameplates.api.CustomNameplates; @@ -103,6 +105,9 @@ public class BukkitPlatform implements Platform { // some plugins would send null to clear the actionbar, what a bad solution Object component = Optional.ofNullable(Reflections.field$ClientboundSetActionBarTextPacket$text.get(packet)).orElse(Reflections.instance$Component$empty); Object contents = Reflections.method$Component$getContents.invoke(component); + if (contents == null) { + return; + } if (Reflections.clazz$ScoreContents.isAssignableFrom(contents.getClass())) { //String name = scoreContentNameFunction.apply(Reflections.field$ScoreContents$name.get(contents)); String objective = (String) Reflections.field$ScoreContents$objective.get(contents); @@ -305,7 +310,7 @@ public class BukkitPlatform implements Platform { Object attributeHolder = Reflections.field$ClientboundUpdateAttributesPacket$AttributeSnapshot$attribute.get(attributeSnapshot); Object attribute = Reflections.method$Holder$value.invoke(attributeHolder); String id = (String) Reflections.field$Attribute$id.get(attribute); - if (id.equals("attribute.name.generic.scale")) { + if (id.equals("attribute.name.generic.scale") || id.equals("attribute.name.scale")) { double baseValue = (double) Reflections.field$ClientboundUpdateAttributesPacket$AttributeSnapshot$base.get(attributeSnapshot); @SuppressWarnings("unchecked") Collection modifiers = (Collection) Reflections.field$ClientboundUpdateAttributesPacket$AttributeSnapshot$modifiers.get(attributeSnapshot); diff --git a/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/util/Reflections.java b/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/util/Reflections.java index 9712feb..3f29b9e 100644 --- a/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/util/Reflections.java +++ b/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/util/Reflections.java @@ -274,7 +274,7 @@ public class Reflections { try { Field field = ReflectionUtils.getDeclaredField( clazz$ClientboundBossEventPacket, - "f", "REMOVE_OPERATION"); + VersionHelper.isVersionNewerThan1_20_5() ? "g" : "f", "REMOVE_OPERATION"); field.setAccessible(true); instance$ClientboundBossEventPacket$REMOVE_OPERATION = requireNonNull(field.get(null)); } catch (IllegalAccessException e) {