Add ListCommand
Dieser Commit ist enthalten in:
Ursprung
09214a0212
Commit
e9297fab47
@ -121,6 +121,7 @@ public class BungeeCore extends Plugin {
|
|||||||
new UnIgnoreCommand();
|
new UnIgnoreCommand();
|
||||||
new PollresultCommand();
|
new PollresultCommand();
|
||||||
new ResourcereloadCommand();
|
new ResourcereloadCommand();
|
||||||
|
new ListCommand();
|
||||||
|
|
||||||
if(!EVENT_MODE){
|
if(!EVENT_MODE){
|
||||||
new WebregisterCommand();
|
new WebregisterCommand();
|
||||||
|
71
src/de/steamwar/bungeecore/commands/ListCommand.java
Normale Datei
71
src/de/steamwar/bungeecore/commands/ListCommand.java
Normale Datei
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.Servertype;
|
||||||
|
import de.steamwar.bungeecore.Subserver;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.connection.Server;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class ListCommand extends BasicCommand {
|
||||||
|
|
||||||
|
public ListCommand() {
|
||||||
|
super("list", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private final TreeMap<String, List<ProxiedPlayer>> playerMap = new TreeMap<>();
|
||||||
|
|
||||||
|
private synchronized void updateCustomTablist(){
|
||||||
|
//Calculate server-player-map
|
||||||
|
playerMap.clear();
|
||||||
|
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
||||||
|
Server pserver = player.getServer();
|
||||||
|
if (pserver == null) //Happens temporarily
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ServerInfo server = pserver.getInfo();
|
||||||
|
String serverName = server.getName();
|
||||||
|
|
||||||
|
Subserver subserver = Subserver.getSubserver(server);
|
||||||
|
if (subserver != null && subserver.getType() == Servertype.BAUSERVER) {
|
||||||
|
playerMap.computeIfAbsent("Bau", s -> new ArrayList<>()).add(player);
|
||||||
|
} else {
|
||||||
|
playerMap.computeIfAbsent(serverName, s -> new ArrayList<>()).add(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
playerMap.forEach((server, players) -> players.sort((proxiedPlayer, t1) -> proxiedPlayer.getName().compareToIgnoreCase(t1.getName())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender commandSender, String[] strings) {
|
||||||
|
updateCustomTablist();
|
||||||
|
for (String server : playerMap.navigableKeySet()) {
|
||||||
|
commandSender.sendMessage("§e" + server + "§8: §7" + playerMap.get(server).stream().map(CommandSender::getName).collect(Collectors.joining(", ")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren