From cf050718c86b72137ac1ba32fd9514a3dc853c12 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Wed, 13 Dec 2023 16:07:20 +0800 Subject: [PATCH] bruh --- .../network/listeners/SpawnPacketHandler.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/xiamomc/morph/backends/server/renderer/network/listeners/SpawnPacketHandler.java b/src/main/java/xiamomc/morph/backends/server/renderer/network/listeners/SpawnPacketHandler.java index 68c38bdd..0092681a 100644 --- a/src/main/java/xiamomc/morph/backends/server/renderer/network/listeners/SpawnPacketHandler.java +++ b/src/main/java/xiamomc/morph/backends/server/renderer/network/listeners/SpawnPacketHandler.java @@ -133,8 +133,9 @@ private void scheduleRefreshPlayerDisplay(Player player, String disguiseName) if (registryParameters != null) { logger.info("Triggering refresh!"); - refreshStateForPlayer(player, - new DisplayParameters(outcomingProfile, disguiseName, registryParameters.bukkitType(), registryParameters.singleWatcher())); + GameProfile finalOutcomingProfile = outcomingProfile; + this.addSchedule(() -> refreshStateForPlayer(player, + new DisplayParameters(finalOutcomingProfile, disguiseName, registryParameters.bukkitType(), registryParameters.singleWatcher()))); } return null; @@ -287,19 +288,21 @@ private void refreshStateForPlayer(@Nullable Player player, @NotNull DisplayPara //然后发包创建实体 //确保gameProfile非空 //如果没有profile,那么随机一个并计划刷新 - if (displayType == org.bukkit.entity.EntityType.PLAYER) + if (displayType == org.bukkit.entity.EntityType.PLAYER && gameProfile == null) { - if (gameProfile == null) + var targetPlayer = Bukkit.getPlayerExact(parameters.playerDisguiseName()); + + var cachedProfile = targetPlayer == null + ? PlayerSkinProvider.getInstance().getCachedProfile(parameters.playerDisguiseName()) + : NmsRecord.ofPlayer(targetPlayer).gameProfile; + + if (cachedProfile == null) { - var cachedProfile = PlayerSkinProvider.getInstance().getCachedProfile(parameters.playerDisguiseName()); - if (cachedProfile == null) - { - scheduleRefreshPlayerDisplay(player, parameters.playerDisguiseName()); - gameProfile = new GameProfile(Util.NIL_UUID, parameters.playerDisguiseName()); - } - else - gameProfile = cachedProfile; + scheduleRefreshPlayerDisplay(player, parameters.playerDisguiseName()); + gameProfile = new GameProfile(Util.NIL_UUID, parameters.playerDisguiseName()); } + else + gameProfile = cachedProfile; } var parametersFinal = new DisplayParameters(gameProfile, parameters.playerDisguiseName(), parameters.bukkitType(), parameters.watcher());