SteamWar/BungeeCore
Archiviert
13
2

Update KickCommand
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2022-06-15 20:04:43 +02:00
Ursprung 8a21d5c93d
Commit 19616aef84

Datei anzeigen

@ -21,48 +21,40 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.ArrayList; import java.util.stream.Collectors;
public class KickCommand extends BasicCommand { public class KickCommand extends SWCommand {
public KickCommand() { public KickCommand() {
super("kick", "bungeecore.kick"); super("kick", "bungeecore.kick");
} }
@Override @Register(description = "KICK_USAGE")
public void execute(CommandSender sender, String[] args) { public void genericCommand(CommandSender sender, @Mapper("player") String player, String... message) {
if(args.length == 0){ ProxiedPlayer target = ProxyServer.getInstance().getPlayer(player);
Message.send("KICK_USAGE", sender);
return;
}
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
if(target == null){ if(target == null){
Message.send("KICK_OFFLINE", sender); Message.send("KICK_OFFLINE", sender);
return; return;
} }
if(args.length == 1){ if (message.length == 0) {
target.disconnect(Message.parseToComponent("KICK_NORMAL", true, target)); target.disconnect(Message.parseToComponent("KICK_NORMAL", true, target));
} else { } else {
StringBuilder msgBuilder = new StringBuilder(); target.disconnect(BungeeCore.stringToText(BungeeCore.CHAT_PREFIX + "§c" + String.join(" ", message)));
msgBuilder.append(BungeeCore.CHAT_PREFIX).append("§c");
for (int i = 1; i < args.length; i++){
msgBuilder.append(args[i]).append(" ");
}
target.disconnect(BungeeCore.stringToText(msgBuilder.toString()));
} }
Message.send("KICK_CONFIRM", sender, target.getName()); Message.send("KICK_CONFIRM", sender, target.getName());
} }
@Override @Mapper(value = "player", local = true)
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) { public TypeMapper<String> playerTypeMapper() {
if(args.length == 1) return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
return allPlayers(args[0]);
return new ArrayList<>();
} }
} }