mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Add cross server list tracking and handling
This commit is contained in:
1 parent
fa85860c22
commit
0e9527ce2a
7 files changed
+170
-12
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package me.william278.huskhomes2;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class CrossServerListHandler {
|
||||
|
||||
// A HashMap mapping all the HuskHomes servers on the Bungee Network
|
||||
// (with the same Cluster ID) with their list of players
|
||||
private static final HashMap<String,HashSet<String>> playerList = new HashMap<>();
|
||||
|
||||
// Returns a HashSet of all players on the Network
|
||||
public static HashSet<String> getGlobalPlayerList() {
|
||||
HashSet<String> players = getOtherServerPlayerList();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
players.add(p.getName());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
public static HashSet<String> getOtherServerPlayerList() {
|
||||
HashSet<String> players = new HashSet<>();
|
||||
for (String server : playerList.keySet()) {
|
||||
players.addAll(playerList.get(server));
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
public static void updateHashset(String server, HashSet<String> players) {
|
||||
playerList.put(server, players);
|
||||
}
|
||||
|
||||
public static void requestHashsetUpdate() {
|
||||
PluginMessageHandler.requestPlayerLists();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user