From 8df17d2f023b600972d4159708d6473f2f395e1e Mon Sep 17 00:00:00 2001 From: fullwall Date: Fri, 12 May 2023 01:09:45 +0800 Subject: [PATCH] WIP fix for tp cross-world --- .../src/main/java/net/citizensnpcs/EventListen.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/EventListen.java b/main/src/main/java/net/citizensnpcs/EventListen.java index 8f0eaa82e..e5739e557 100644 --- a/main/src/main/java/net/citizensnpcs/EventListen.java +++ b/main/src/main/java/net/citizensnpcs/EventListen.java @@ -411,21 +411,20 @@ public class EventListen implements Listener { toRespawn.values().remove(event.getNPC()); } - @EventHandler(ignoreCancelled = true) + @EventHandler public void onPlayerChangedWorld(PlayerChangedWorldEvent event) { skinUpdateTracker.removePlayer(event.getPlayer().getUniqueId()); + skinUpdateTracker.updatePlayer(event.getPlayer(), 20, true); if (CitizensAPI.getNPCRegistry().getNPC(event.getPlayer()) == null) return; - NMS.removeFromServerPlayerList(event.getPlayer()); + Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> { + NMS.replaceTracker(event.getPlayer()); + NMS.removeFromServerPlayerList(event.getPlayer()); + }, 1); // on teleport, player NPCs are added to the server player list. this is // undesirable as player NPCs are not real players and confuse plugins. } - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerChangeWorld(PlayerChangedWorldEvent event) { - skinUpdateTracker.updatePlayer(event.getPlayer(), 20, true); - } - @EventHandler(ignoreCancelled = true) public void onPlayerCreateNPC(PlayerCreateNPCEvent event) { checkCreationEvent(event);