Dieser Commit ist enthalten in:
Ursprung
8a21d5c93d
Commit
19616aef84
@ -21,48 +21,40 @@ package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
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.ProxyServer;
|
||||
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() {
|
||||
super("kick", "bungeecore.kick");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(args.length == 0){
|
||||
Message.send("KICK_USAGE", sender);
|
||||
return;
|
||||
}
|
||||
|
||||
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
|
||||
@Register(description = "KICK_USAGE")
|
||||
public void genericCommand(CommandSender sender, @Mapper("player") String player, String... message) {
|
||||
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(player);
|
||||
if(target == null){
|
||||
Message.send("KICK_OFFLINE", sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length == 1){
|
||||
if (message.length == 0) {
|
||||
target.disconnect(Message.parseToComponent("KICK_NORMAL", true, target));
|
||||
}else{
|
||||
StringBuilder msgBuilder = new StringBuilder();
|
||||
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()));
|
||||
} else {
|
||||
target.disconnect(BungeeCore.stringToText(BungeeCore.CHAT_PREFIX + "§c" + String.join(" ", message)));
|
||||
}
|
||||
Message.send("KICK_CONFIRM", sender, target.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
||||
if(args.length == 1)
|
||||
return allPlayers(args[0]);
|
||||
return new ArrayList<>();
|
||||
@Mapper(value = "player", local = true)
|
||||
public TypeMapper<String> playerTypeMapper() {
|
||||
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren