use of cloud.commandframework.annotations.CommandDescription in project ProxyQueues by JLyne.
the class Commands method kick.
@CommandMethod("queue kick <player>")
@CommandDescription("Kick the specified player from any queue they are in")
@CommandPermission(Constants.BASE_PERM + "kick")
public void kick(CommandSource sender, @Argument("player") Player player) {
ProxyQueuesImpl proxyQueues = ProxyQueuesImpl.getInstance();
UUID uuid = player.getUniqueId();
Optional<ProxyQueue> currentQueue = queueHandler.getCurrentQueue(uuid);
if (currentQueue.isEmpty()) {
proxyQueues.sendMessage(sender, MessageType.ERROR, "errors.target-no-queue", Collections.singletonMap("player", player.getUsername()));
return;
}
queueHandler.kickPlayer(uuid);
proxyQueues.sendMessage(sender, MessageType.INFO, "commands.kick-success", Map.of("player", player.getUsername(), "server", currentQueue.get().getServer().getServerInfo().getName()));
}
use of cloud.commandframework.annotations.CommandDescription in project ProxyQueues by JLyne.
the class Commands method serverInfo.
@CommandMethod("queue info server <server>")
@CommandDescription("Shows information about the specified server's queue")
@CommandPermission(Constants.BASE_PERM + "info")
public void serverInfo(CommandSource sender, @Argument("server") RegisteredServer server) {
ProxyQueue queue = queueHandler.getQueue(server);
ProxyQueuesImpl proxyQueues = ProxyQueuesImpl.getInstance();
if (queue == null) {
proxyQueues.sendMessage(sender, MessageType.ERROR, "errors.server-no-queue", Collections.singletonMap("server", server.getServerInfo().getName()));
return;
}
int playersRequired = queue.getPlayersRequired(), normalMax = queue.getMaxSlots(QueueType.NORMAL), priorityMax = queue.getMaxSlots(QueueType.PRIORITY), staffMax = queue.getMaxSlots(QueueType.STAFF), normalSize = queue.getQueueSize(QueueType.NORMAL), prioritySize = queue.getQueueSize(QueueType.PRIORITY), staffSize = queue.getQueueSize(QueueType.STAFF), connectedSize = queue.getConnectedCount(), priorityConnectedSize = queue.getConnectedCount(QueueType.PRIORITY), staffConnectedSize = queue.getConnectedCount(QueueType.STAFF);
normalSize += prioritySize;
normalSize += staffSize;
QueuePlayer[] normalPlayers = queue.getTopPlayers(QueueType.NORMAL, 3);
QueuePlayer[] priorityPlayers = queue.getTopPlayers(QueueType.PRIORITY, 3);
QueuePlayer[] staffPlayers = queue.getTopPlayers(QueueType.STAFF, 3);
proxyQueues.sendMessage(sender, MessageType.INFO, "commands.info-server-response", Map.ofEntries(entry("server", server.getServerInfo().getName()), entry("size", String.valueOf(normalSize)), entry("priority_size", String.valueOf(prioritySize)), entry("staff_size", String.valueOf(staffSize)), entry("connected_size", String.valueOf(connectedSize)), entry("priority_connected_size", String.valueOf(priorityConnectedSize)), entry("staff_connected_size", String.valueOf(staffConnectedSize)), entry("required", String.valueOf(playersRequired)), entry("max", String.valueOf(normalMax)), entry("priority_max", String.valueOf(priorityMax)), entry("global_max", String.valueOf(staffMax)), entry("staff_first", staffPlayers[0] != null ? staffPlayers[0].getPlayer().getUsername() : "n/a"), entry("staff_second", staffPlayers[1] != null ? staffPlayers[1].getPlayer().getUsername() : "n/a"), entry("staff_third", staffPlayers[2] != null ? staffPlayers[2].getPlayer().getUsername() : "n/a"), entry("priority_first", priorityPlayers[0] != null ? priorityPlayers[0].getPlayer().getUsername() : "n/a"), entry("priority_second", priorityPlayers[1] != null ? priorityPlayers[1].getPlayer().getUsername() : "n/a"), entry("priority_third", priorityPlayers[2] != null ? priorityPlayers[2].getPlayer().getUsername() : "n/a"), entry("first", normalPlayers[0] != null ? normalPlayers[0].getPlayer().getUsername() : "n/a"), entry("second", normalPlayers[1] != null ? normalPlayers[1].getPlayer().getUsername() : "n/a"), entry("third", normalPlayers[2] != null ? normalPlayers[2].getPlayer().getUsername() : "n/a")));
}
use of cloud.commandframework.annotations.CommandDescription in project ProxyQueues by JLyne.
the class Commands method join.
@CommandMethod("queue join <server>")
@CommandDescription("Join the queue for a server")
@CommandPermission(Constants.BASE_PERM + "join")
public void join(CommandSource sender, @Argument("server") RegisteredServer server) {
ProxyQueue queue = queueHandler.getQueue(server);
ProxyQueuesImpl proxyQueues = ProxyQueuesImpl.getInstance();
if (queue == null || !queue.isActive()) {
proxyQueues.sendMessage(sender, MessageType.ERROR, "errors.server-no-queue", Collections.singletonMap("server", server.getServerInfo().getName()));
return;
}
Optional<ServerConnection> currentServer = ((Player) sender).getCurrentServer();
if (currentServer.isPresent() && currentServer.get().getServer().equals(server)) {
proxyQueues.sendMessage(sender, MessageType.ERROR, "errors.player-same-server", Collections.singletonMap("server", server.getServerInfo().getName()));
return;
}
queueHandler.clearPlayer((Player) sender);
queue.addPlayer((Player) sender);
}
use of cloud.commandframework.annotations.CommandDescription in project ProxyQueues by JLyne.
the class Commands method leave.
@CommandMethod("queue leave")
@CommandDescription("Leave the current queue you are in")
@CommandPermission(Constants.BASE_PERM + "leave")
public void leave(CommandSource sender) {
ProxyQueuesImpl proxyQueues = ProxyQueuesImpl.getInstance();
Player player = (Player) sender;
Optional<ProxyQueue> currentQueue = queueHandler.getCurrentQueue(player);
if (currentQueue.isEmpty()) {
proxyQueues.sendMessage(sender, MessageType.ERROR, "errors.player-no-queue");
return;
}
queueHandler.clearPlayer(player, false);
}
use of cloud.commandframework.annotations.CommandDescription in project ProxyQueues by JLyne.
the class Commands method clear.
@CommandMethod("queue clear <server>")
@CommandDescription("Clear the queue for the specified server, removing all players currently in the queue")
@CommandPermission(Constants.BASE_PERM + "clear")
public void clear(CommandSource sender, @Argument("server") RegisteredServer server) {
ProxyQueue queue = queueHandler.getQueue(server);
ProxyQueuesImpl proxyQueues = ProxyQueuesImpl.getInstance();
if (queue == null) {
proxyQueues.sendMessage(sender, MessageType.ERROR, "errors.server-no-queue", Collections.singletonMap("server", server.getServerInfo().getName()));
return;
}
queue.clear();
proxyQueues.sendMessage(sender, MessageType.INFO, "commands.clear-success", Collections.singletonMap("server", server.getServerInfo().getName()));
}
Aggregations