From 7f5876f62a54730468522ec30c2696918965a488 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Sun, 16 Sep 2018 23:44:26 -0500 Subject: [PATCH] Totals and New Players Added totals to /list Added the "Welcome to the server!" message --- .../xyz/etztech/qol/commands/ListCommand.java | 18 ++++++++++++++---- .../etztech/qol/listeners/LoginListener.java | 12 ++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/main/java/xyz/etztech/qol/commands/ListCommand.java b/src/main/java/xyz/etztech/qol/commands/ListCommand.java index 809a5e2..41ac428 100644 --- a/src/main/java/xyz/etztech/qol/commands/ListCommand.java +++ b/src/main/java/xyz/etztech/qol/commands/ListCommand.java @@ -28,7 +28,9 @@ public class ListCommand implements CommandExecutor { list.put(group, new ArrayList<>()); } - for (Player player : Bukkit.getServer().getOnlinePlayers()) { + Collection players = Bukkit.getServer().getOnlinePlayers(); + + for (Player player : players) { for (String group : groups) { if (player.hasPermission("qol.list." + group)) { List names = list.get(group); @@ -38,18 +40,26 @@ public class ListCommand implements CommandExecutor { } } } - StringBuilder message = new StringBuilder(); + StringBuilder message = new StringBuilder(ChatColor.GOLD + "===== Player List (" + + ChatColor.YELLOW + players.size() + ChatColor.GOLD + ") ====="); for (String key : list.keySet()) { List parts = Arrays.asList(key.split("_")); for (int i = 0; i < parts.size(); i++) { parts.set(i, StringUtils.capitalize(parts.get(i))); } + List names = list.get(key); message.append(ChatColor.GOLD) .append(StringUtils.join(parts, " ")) - .append(": ") + + .append(" (") .append(ChatColor.YELLOW) - .append(StringUtils.join(list.get(key), ", ")) + .append(names.size()) + .append(ChatColor.GOLD) + .append("): ") + + .append(ChatColor.YELLOW) + .append(StringUtils.join(names, ", ")) .append("\n"); } diff --git a/src/main/java/xyz/etztech/qol/listeners/LoginListener.java b/src/main/java/xyz/etztech/qol/listeners/LoginListener.java index c40778d..6a76ec1 100644 --- a/src/main/java/xyz/etztech/qol/listeners/LoginListener.java +++ b/src/main/java/xyz/etztech/qol/listeners/LoginListener.java @@ -1,6 +1,7 @@ package xyz.etztech.qol.listeners; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -32,6 +33,17 @@ public class LoginListener implements Listener { event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "The server is full!"); } } + + // First login + if (!player.hasPlayedBefore()) { + for (Player p : Bukkit.getServer().getOnlinePlayers()) { + if (p != player) { + p.sendMessage(ChatColor.YELLOW + player.getName() + " is new here!"); + } else { + p.sendMessage(ChatColor.YELLOW + "Welcome, " + p.getName() + "! Check out /rules and then /apply!"); + } + } + } } }