9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-23 17:09:25 +00:00
This commit is contained in:
XiaoMoMi
2024-11-11 15:37:37 +08:00
parent 0fd7ac1a79
commit 144b358768
4 changed files with 17 additions and 4 deletions

View File

@@ -402,4 +402,11 @@ public interface CNPlayer {
* @return team view * @return team view
*/ */
TeamView teamView(); TeamView teamView();
/**
* Check if the player is initialized
*
* @return initialized or not
*/
boolean isInitialized();
} }

View File

@@ -52,6 +52,11 @@ public class BukkitCNPlayer extends AbstractCNPlayer {
this.player = new WeakReference<>(player); this.player = new WeakReference<>(player);
} }
@Override
public boolean isInitialized() {
return player != null;
}
@Override @Override
public Player player() { public Player player() {
return player.get(); return player.get();

View File

@@ -207,6 +207,7 @@ public class BukkitPlatform implements Platform {
// for skin plugin compatibility // for skin plugin compatibility
registerPacketConsumer((player, event, packet) -> { registerPacketConsumer((player, event, packet) -> {
try { try {
if (!player.isInitialized()) return;
UUID pUUID = player.uuid(); UUID pUUID = player.uuid();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<UUID> uuids = (List<UUID>) Reflections.field$ClientboundPlayerInfoRemovePacket$profileIds.get(packet); List<UUID> uuids = (List<UUID>) Reflections.field$ClientboundPlayerInfoRemovePacket$profileIds.get(packet);
@@ -228,7 +229,6 @@ public class BukkitPlatform implements Platform {
try { try {
EnumSet<?> enums = (EnumSet<?>) Reflections.field$ClientboundPlayerInfoUpdatePacket$actions.get(packet); EnumSet<?> enums = (EnumSet<?>) Reflections.field$ClientboundPlayerInfoUpdatePacket$actions.get(packet);
if (enums == null) return; if (enums == null) return;
UUID pUUID = player.uuid();
boolean add_player = enums.contains(Reflections.enum$ClientboundPlayerInfoUpdatePacket$Action$ADD_PLAYER); boolean add_player = enums.contains(Reflections.enum$ClientboundPlayerInfoUpdatePacket$Action$ADD_PLAYER);
boolean update_gamemode = enums.contains(Reflections.enum$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_GAME_MODE); boolean update_gamemode = enums.contains(Reflections.enum$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_GAME_MODE);
if (add_player || update_gamemode) { if (add_player || update_gamemode) {
@@ -239,8 +239,9 @@ public class BukkitPlatform implements Platform {
if (uuid == null) continue; if (uuid == null) continue;
// for skin plugin compatibility // for skin plugin compatibility
if (add_player && uuid.equals(pUUID)) { if (add_player && player.isInitialized()) {
if (player.isTempPreviewing() || player.isToggleablePreviewing() || CustomNameplates.getInstance().getUnlimitedTagManager().isAlwaysShow()) { UUID pUUID = player.uuid();
if (uuid.equals(pUUID) && (player.isTempPreviewing() || player.isToggleablePreviewing() || CustomNameplates.getInstance().getUnlimitedTagManager().isAlwaysShow())) {
Tracker tracker = player.addPlayerToTracker(player); Tracker tracker = player.addPlayerToTracker(player);
tracker.setScale(player.scale()); tracker.setScale(player.scale());
tracker.setCrouching(player.isCrouching()); tracker.setCrouching(player.isCrouching());

View File

@@ -1,6 +1,6 @@
# Project settings # Project settings
# Rule: [major update].[feature update].[bug fix] # Rule: [major update].[feature update].[bug fix]
project_version=3.0.10 project_version=3.0.10.1
config_version=32 config_version=32
project_group=net.momirealms project_group=net.momirealms