SteamWar/BungeeCore
Archiviert
13
2

Update JoinmeCommand ProxiedPlayer Validator
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Fix typos in TeamCommand
Dieser Commit ist enthalten in:
yoyosource 2023-02-17 15:27:20 +01:00
Ursprung dd8d65ff9d
Commit 9dd3cb7697
2 geänderte Dateien mit 9 neuen und 27 gelöschten Zeilen

Datei anzeigen

@ -21,18 +21,13 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.sql.BauweltMember; import de.steamwar.bungeecore.sql.BauweltMember;
import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator;
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.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.Collection;
import java.util.stream.Collectors;
public class JoinmeCommand extends SWCommand { public class JoinmeCommand extends SWCommand {
public JoinmeCommand() { public JoinmeCommand() {
@ -87,26 +82,13 @@ public class JoinmeCommand extends SWCommand {
} }
@ClassMapper(ProxiedPlayer.class) @ClassMapper(ProxiedPlayer.class)
public TypeMapper<ProxiedPlayer> playerMapper() { public TypeValidator<ProxiedPlayer> playerMapper() {
return new TypeMapper<ProxiedPlayer>() { return (sender, value, messageSender) -> {
@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()) { if (value == null || !value.isConnected()) {
messageSender.send("JOINME_PLAYER_OFFLINE", sender); messageSender.send("JOINME_PLAYER_OFFLINE", sender);
return false; return false;
} }
return true; return true;
}
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
return ProxyServer.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList());
}
}; };
} }
} }

Datei anzeigen

@ -114,7 +114,7 @@ public class TeamCommand extends SWCommand {
} }
@Register(value = "create", description = "TEAM_CREATE_USAGE") @Register(value = "create", description = "TEAM_CREATE_USAGE")
public void create(ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGHT") String kuerzel, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGHT") String name){ public void create(ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGTH") String name){
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if(unwantedInTeam(player, user)) if(unwantedInTeam(player, user))
@ -299,7 +299,7 @@ public class TeamCommand extends SWCommand {
} }
@Register(value = "changekurzel", description = "TEAM_KUERZEL_USAGE") @Register(value = "changekurzel", description = "TEAM_KUERZEL_USAGE")
public void changekuerzel(ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGHT") String kuerzel){ public void changekuerzel(ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel){
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if(notLeader(player, user)) if(notLeader(player, user))