Merge pull request 'Update KickCommand' (#386) from CommandKick into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #386 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
045b693c92
@ -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<>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren