Add getPlayerNames Method

This commit is contained in:
RayzsYT committed 2024-07-11 02:38:22 +02:00
1 parent b55e79a379
commit be2c4347fc
3 files changed
+18

No files matched your search

@@ -115,6 +115,12 @@ public class BukkitLoader extends JavaPlugin {
}
}
public static List<String> getPlayerNames() {
List<String> result = new LinkedList<>();
Bukkit.getServer().getOnlinePlayers().forEach(player -> result.add(player.getName()));
return result;
}
public static UUID getUUIDByName(String playerName) {
Player player = Bukkit.getServer().getPlayer(playerName);
return player != null ? player.getUniqueId() : null;
@@ -100,6 +100,12 @@ public class BungeeLoader extends Plugin {
}
}
public static List<String> getPlayerNames() {
List<String> result = new LinkedList<>();
ProxyServer.getInstance().getPlayers().forEach(player -> result.add(player.getName()));
return result;
}
public static UUID getUUIDByName(String playerName) {
ProxiedPlayer proxiedPlayer = ProxyServer.getInstance().getPlayer(playerName);
return proxiedPlayer != null ? proxiedPlayer.getUniqueId() : null;
@@ -108,6 +108,12 @@ public class VelocityLoader {
}).delay(1, TimeUnit.SECONDS).schedule();
}
public static List<String> getPlayerNames() {
List<String> result = new LinkedList<>();
server.getAllPlayers().forEach(player -> result.add(player.getUsername()));
return result;
}
public static UUID getUUIDByName(String playerName) {
if (!server.getPlayer(playerName).isPresent()) return null;
return server.getPlayer(playerName).get().getUniqueId();