Totals and New Players

Added totals to /list
Added the "Welcome <new player> to the server!" message
master
Etzelia 2018-09-16 23:44:26 -05:00
parent 2f897efa42
commit 7f5876f62a
2 changed files with 26 additions and 4 deletions

View File

@ -28,7 +28,9 @@ public class ListCommand implements CommandExecutor {
list.put(group, new ArrayList<>());
}
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers();
for (Player player : players) {
for (String group : groups) {
if (player.hasPermission("qol.list." + group)) {
List<String> 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<String> parts = Arrays.asList(key.split("_"));
for (int i = 0; i < parts.size(); i++) {
parts.set(i, StringUtils.capitalize(parts.get(i)));
}
List<String> 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");
}

View File

@ -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!");
}
}
}
}
}