Dieser Commit ist enthalten in:
Ursprung
ae2a1d5779
Commit
5c55bdacde
@ -22,11 +22,16 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.Servertype;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
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 java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ArenaCommand extends SWCommand {
|
||||
|
||||
public ArenaCommand() {
|
||||
@ -34,8 +39,7 @@ public class ArenaCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void arenaJoin(ProxiedPlayer player, String... serverInfo) {
|
||||
ServerInfo server = ProxyServer.getInstance().getServerInfo(String.join(" ", serverInfo));
|
||||
public void arenaJoin(ProxiedPlayer player, ServerInfo server) {
|
||||
Subserver subserver = Subserver.getSubserver(server);
|
||||
if(server == null || subserver == null || subserver.getType() != Servertype.ARENA) {
|
||||
ChatSender.of(player).system("ARENA_NOT_FOUND");
|
||||
@ -44,4 +48,22 @@ public class ArenaCommand extends SWCommand {
|
||||
|
||||
TpCommand.teleport(player, server);
|
||||
}
|
||||
|
||||
@ClassMapper(ServerInfo.class)
|
||||
public TypeMapper<ServerInfo> serverInfoTypeMapper() {
|
||||
return new TypeMapper<ServerInfo>() {
|
||||
@Override
|
||||
public ServerInfo map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return ProxyServer.getInstance().getServerInfo(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
||||
return ProxyServer.getInstance().getServersCopy().values().stream().filter(server -> {
|
||||
Subserver subserver = Subserver.getSubserver(server);
|
||||
return subserver != null && subserver.getType() == Servertype.ARENA;
|
||||
}).map(ServerInfo::getName).collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren