From 5dce54b2156392e965ff9d10d7d7af964e61f822 Mon Sep 17 00:00:00 2001 From: TimeBather Date: Fri, 6 Dec 2024 23:21:25 +0800 Subject: [PATCH] fix: located menu manager --- .../core/menu/locator/LocatedMenuManager.java | 2 +- .../ServerChunkMenuLocatorManager.java | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/kasuga/lib/core/menu/locator/LocatedMenuManager.java b/src/main/java/kasuga/lib/core/menu/locator/LocatedMenuManager.java index 2c0cf43d..3921b85c 100644 --- a/src/main/java/kasuga/lib/core/menu/locator/LocatedMenuManager.java +++ b/src/main/java/kasuga/lib/core/menu/locator/LocatedMenuManager.java @@ -47,7 +47,7 @@ public void asClient(List uuids){ if(uuids.isEmpty()){ break; } - menu.asClient(uuids.remove(0)); + menu.asClient(newUuids.remove(0)); } } diff --git a/src/main/java/kasuga/lib/core/menu/locator/ServerChunkMenuLocatorManager.java b/src/main/java/kasuga/lib/core/menu/locator/ServerChunkMenuLocatorManager.java index 9ceff476..7a432347 100644 --- a/src/main/java/kasuga/lib/core/menu/locator/ServerChunkMenuLocatorManager.java +++ b/src/main/java/kasuga/lib/core/menu/locator/ServerChunkMenuLocatorManager.java @@ -72,14 +72,17 @@ public static void transfer(IChunkBasedLocator menuLocator, ChunkPos oldChunk, C List oldPlayers = players.get(oldChunk); List newPlayers = players.get(newChunk); - oldPlayers - .stream() - .filter(player -> !newPlayers.contains(player)) - .forEach(player -> menuLocator.sendDownTo(player.connection.getConnection())); - - newPlayers - .stream() - .filter(player -> !oldPlayers.contains(player)) - .forEach(player -> menuLocator.sendUpTo(player.connection.getConnection())); + + if(oldPlayers != null) + oldPlayers + .stream() + .filter(player -> newPlayers == null ? true : !newPlayers.contains(player)) + .forEach(player -> menuLocator.sendDownTo(player.connection.getConnection())); + + if(newPlayers != null) + newPlayers + .stream() + .filter(player -> oldPlayers == null ? true : !oldPlayers.contains(player)) + .forEach(player -> menuLocator.sendUpTo(player.connection.getConnection())); } }