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();