9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-23 00:49:35 +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
*/
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);
}
@Override
public boolean isInitialized() {
return player != null;
}
@Override
public Player player() {
return player.get();

View File

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

View File

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