SteamWar/BungeeCore
Archiviert
13
2

Update JoinmeCommand
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2023-01-21 22:28:46 +01:00
Ursprung 647702c0b0
Commit a15cf2c94e

Datei anzeigen

@ -21,11 +21,18 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.sql.BauweltMember;
import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
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 JoinmeCommand extends SWCommand {
public JoinmeCommand() {
@ -40,11 +47,8 @@ public class JoinmeCommand extends SWCommand {
}
@Register
public void genericCommand(ProxiedPlayer player, ProxiedPlayer target) {
if(target == null || !target.isConnected()){
Message.send("JOINME_PLAYER_OFFLINE", player);
return;
}else if(target.equals(player)){
public void genericCommand(ProxiedPlayer player, @Validator ProxiedPlayer target) {
if (target.equals(player)){
Message.send("JOINME_PLAYER_SELF", player);
return;
}
@ -78,4 +82,28 @@ public class JoinmeCommand extends SWCommand {
player.connect(server);
}
}
@ClassMapper(ProxiedPlayer.class)
public TypeMapper<ProxiedPlayer> playerMapper() {
return new TypeMapper<ProxiedPlayer>() {
@Override
public ProxiedPlayer map(CommandSender commandSender, String[] previousArguments, String s) {
return ProxyServer.getInstance().getPlayer(s);
}
@Override
public boolean validate(CommandSender sender, ProxiedPlayer value, MessageSender messageSender) {
if (value == null || !value.isConnected()) {
messageSender.send("JOINME_PLAYER_OFFLINE", sender);
return false;
}
return true;
}
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
return ProxyServer.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList());
}
};
}
}