use of com.velocitypowered.api.proxy.ServerConnection 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);
}
Aggregations