Add /netstat
This commit is contained in:
parent
6ae95648c7
commit
5aaa846f49
@ -63,6 +63,7 @@ import mineplex.core.twofactor.TwoFactorAuth;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.server.command.NetStatCommand;
|
||||
import mineplex.hub.server.ui.game.QuickShop;
|
||||
import mineplex.hub.server.ui.lobby.LobbyShop;
|
||||
import mineplex.hub.server.ui.server.ServerSelectionShop;
|
||||
@ -77,6 +78,7 @@ public class ServerManager extends MiniPlugin
|
||||
JOIN_FULL,
|
||||
JOIN_ALWAYS,
|
||||
FEATURE_SERVER,
|
||||
NET_STAT_COMMAND
|
||||
}
|
||||
|
||||
private static final long SELECT_SERVER_COOLDOWN = TimeUnit.SECONDS.toMillis(2);
|
||||
@ -84,7 +86,6 @@ public class ServerManager extends MiniPlugin
|
||||
private static final String MPS_PREFIX = "MPS";
|
||||
|
||||
private final CoreClientManager _clientManager;
|
||||
private final DonationManager _donationManager;
|
||||
private final Portal _portal;
|
||||
private final ServerStatusManager _statusManager;
|
||||
private final HubManager _hubManager;
|
||||
@ -139,7 +140,6 @@ public class ServerManager extends MiniPlugin
|
||||
super("Matchmaker");
|
||||
|
||||
_clientManager = require(CoreClientManager.class);
|
||||
_donationManager = require(DonationManager.class);
|
||||
_portal = require(Portal.class);
|
||||
_statusManager = require(ServerStatusManager.class);
|
||||
_hubManager = require(HubManager.class);
|
||||
@ -176,9 +176,11 @@ public class ServerManager extends MiniPlugin
|
||||
_serverNPCTeleport.put(npcName, location);
|
||||
});
|
||||
|
||||
_quickShop = new QuickShop(this, _clientManager, _donationManager, "Quick Menu");
|
||||
_lobbyShop = new LobbyShop(this, _clientManager, _donationManager, "Lobby Menu");
|
||||
_serverShop = new ServerSelectionShop(this, _clientManager, _donationManager, "Server Menu");
|
||||
DonationManager donationManager = require(DonationManager.class);
|
||||
|
||||
_quickShop = new QuickShop(this, _clientManager, donationManager, "Quick Menu");
|
||||
_lobbyShop = new LobbyShop(this, _clientManager, donationManager, "Lobby Menu");
|
||||
_serverShop = new ServerSelectionShop(this, _clientManager, donationManager, "Server Menu");
|
||||
|
||||
NewNPCManager npcManager = require(NewNPCManager.class);
|
||||
npcManager.spawnNPCs("GAME_", this::addNPCInfo);
|
||||
@ -193,6 +195,13 @@ public class ServerManager extends MiniPlugin
|
||||
PermissionGroup.TRAINEE.setPermission(Perm.JOIN_ALWAYS, true, true);
|
||||
PermissionGroup.CONTENT.setPermission(Perm.FEATURE_SERVER, true, true);
|
||||
PermissionGroup.BUILDER.setPermission(Perm.FEATURE_SERVER, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.NET_STAT_COMMAND, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new NetStatCommand(this));
|
||||
}
|
||||
|
||||
private void addNPCInfo(NPC npc)
|
||||
@ -543,6 +552,26 @@ public class ServerManager extends MiniPlugin
|
||||
return servers == null ? Collections.emptyList() : servers.values();
|
||||
}
|
||||
|
||||
public GameServer getServer(String name)
|
||||
{
|
||||
for (Map<String, GameServer> servers : _gameServers.values())
|
||||
{
|
||||
GameServer server = servers.get(name);
|
||||
|
||||
if (server != null)
|
||||
{
|
||||
return server;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, Map<String, GameServer>> getServers()
|
||||
{
|
||||
return _gameServers;
|
||||
}
|
||||
|
||||
public ServerGroup getServerGroupByPrefix(String prefix)
|
||||
{
|
||||
return _serverGroupsByName.values().stream()
|
||||
|
@ -0,0 +1,33 @@
|
||||
package mineplex.hub.server.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.hub.server.GameServer;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
import mineplex.hub.server.ServerManager.Perm;
|
||||
|
||||
public class NetGroupCommand extends CommandBase<ServerManager>
|
||||
{
|
||||
|
||||
NetGroupCommand(ServerManager plugin)
|
||||
{
|
||||
super(plugin, Perm.NET_STAT_COMMAND, "groups");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Plugin.getServers().forEach((group, map) ->
|
||||
{
|
||||
int players = map.values().stream()
|
||||
.mapToInt(gameServer -> gameServer.getServer().getPlayerCount())
|
||||
.sum();
|
||||
int servers = map.values().size();
|
||||
|
||||
caller.sendMessage(F.main(Plugin.getName(), F.name(group) + " - " + F.count(players) + " Players on " + F.count(servers) + " Servers."));
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package mineplex.hub.server.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.game.status.GameInfo;
|
||||
import mineplex.hub.server.GameServer;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
import mineplex.hub.server.ServerManager.Perm;
|
||||
|
||||
public class NetInfoCommand extends CommandBase<ServerManager>
|
||||
{
|
||||
|
||||
NetInfoCommand(ServerManager plugin)
|
||||
{
|
||||
super(plugin, Perm.NET_STAT_COMMAND, "info");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Enter a server name you muppet."));
|
||||
return;
|
||||
}
|
||||
|
||||
GameServer server = Plugin.getServer(args[0]);
|
||||
|
||||
if (server == null)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), F.color(args[0], C.cGold) + " is not a valid server."));
|
||||
return;
|
||||
}
|
||||
|
||||
GameInfo info = server.getInfo();
|
||||
|
||||
if (info == null)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), F.color(args[0], C.cGold) + " exists but does not have valid GameInfo."));
|
||||
}
|
||||
else
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), server.getInfo().toString()));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package mineplex.hub.server.command;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
import mineplex.hub.server.ServerManager.Perm;
|
||||
|
||||
public class NetStatCommand extends MultiCommandBase<ServerManager>
|
||||
{
|
||||
|
||||
public NetStatCommand(ServerManager plugin)
|
||||
{
|
||||
super(plugin, Perm.NET_STAT_COMMAND, "netstat");
|
||||
|
||||
AddCommand(new NetInfoCommand(plugin));
|
||||
AddCommand(new NetGroupCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Command List:"));
|
||||
caller.sendMessage(F.help("/" + _aliasUsed + " info <server>", "Gets the info of a particular server as JSON.", ChatColor.DARK_RED));
|
||||
caller.sendMessage(F.help("/" + _aliasUsed + " groups", "Lists all server groups with their player and server counts.", ChatColor.DARK_RED));
|
||||
}
|
||||
}
|
@ -221,8 +221,6 @@ public class ServerSelectionPage extends ShopPageBase<ServerManager, ServerSelec
|
||||
String votingColour = null, votingStatus = null, votingOn = null;
|
||||
String motd;
|
||||
|
||||
getPlugin().log(info.toString());
|
||||
|
||||
switch (info.getStatus())
|
||||
{
|
||||
case WAITING:
|
||||
|
@ -14,7 +14,7 @@ public class MapCommand extends CommandBase<ArcadeManager>
|
||||
|
||||
public MapCommand(ArcadeManager plugin)
|
||||
{
|
||||
super(plugin, Perm.MAP_COMMAND, "whatmap");
|
||||
super(plugin, Perm.MAP_COMMAND, "whatmap", "mapinfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user