Hide vanished player from Visitors menù

This commit is contained in:
Fabrizio La Rosa 2020-06-13 19:30:21 +02:00
parent 1927f5c633
commit dd1b354af2

View File

@ -159,24 +159,28 @@ public class Visitors {
Set<UUID> islandVisitors = islandManager.getVisitorsAtIsland(island);
Map<Integer, UUID> 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();