From dd1b354af208d2105d55e68884bdac47ef3f6195 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 13 Jun 2020 19:30:21 +0200 Subject: [PATCH] =?UTF-8?q?Hide=20vanished=20player=20from=20Visitors=20me?= =?UTF-8?q?n=C3=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/songoda/skyblock/menus/Visitors.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/menus/Visitors.java b/src/main/java/com/songoda/skyblock/menus/Visitors.java index e7187130..6ac98c1f 100644 --- a/src/main/java/com/songoda/skyblock/menus/Visitors.java +++ b/src/main/java/com/songoda/skyblock/menus/Visitors.java @@ -159,24 +159,28 @@ public class Visitors { Set islandVisitors = islandManager.getVisitorsAtIsland(island); Map sortedIslandVisitors = new TreeMap<>(); + for (UUID islandVisitorList : islandVisitors) { + Player targetPlayer = Bukkit.getPlayer(islandVisitorList); + if(targetPlayer != null && player.canSee(targetPlayer)){ // Remove vanished players + sortedIslandVisitors.put( + playerDataManager.getPlayerData(Bukkit.getServer().getPlayer(islandVisitorList)).getVisitTime(), + islandVisitorList); + } + } + nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), configLoad.getString("Menu.Visitors.Item.Exit.Displayname"), null, null, null, null), 0, 8); nInv.addItem( nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Visitors.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Visitors.Item.Statistics.Lore"), - new Placeholder[]{new Placeholder("%visitors", "" + islandVisitors.size())}, null, null), + new Placeholder[]{new Placeholder("%visitors", "" + sortedIslandVisitors.size())}, null, null), 4); nInv.addItem( nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), configLoad.getString("Menu.Visitors.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17); - for (UUID islandVisitorList : islandVisitors) { - sortedIslandVisitors.put( - playerDataManager.getPlayerData(Bukkit.getServer().getPlayer(islandVisitorList)).getVisitTime(), - islandVisitorList); - } islandVisitors.clear();