SteamWar/BungeeCore
Archiviert
13
2

Update RankCommand
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2022-06-16 11:08:12 +02:00
Ursprung 8a21d5c93d
Commit 21f020e13d

Datei anzeigen

@ -23,32 +23,36 @@ import de.steamwar.bungeecore.ArenaMode;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.UserElo; import de.steamwar.bungeecore.sql.UserElo;
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.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
public class RankCommand extends BasicCommand { public class RankCommand extends SWCommand {
public RankCommand() { public RankCommand() {
super("rank", null); super("rank");
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void ownRank(ProxiedPlayer player) {
if(!(sender instanceof ProxiedPlayer)) rank(player, player.getName());
return; }
ProxiedPlayer player = (ProxiedPlayer) sender; @Register
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); public void rank(ProxiedPlayer player, @Mapper("player") String s) {
if (args.length > 0) { SteamwarUser user = SteamwarUser.get(s);
SteamwarUser nUser = SteamwarUser.get(args[0]); if (user == null) {
if (nUser == null) { Message.send("RANK_PLAYER_NOT_FOUND", player);
Message.send("RANK_PLAYER_NOT_FOUND", player); return;
return; }
} if (!player.getName().equals(s)) {
Message.send("RANK_PLAYER_FOUND", player, nUser.getUserName()); Message.send("RANK_PLAYER_FOUND", player, user.getUserName());
user = nUser;
} }
for(ArenaMode mode : ArenaMode.getAllModes()) { for(ArenaMode mode : ArenaMode.getAllModes()) {
if (!mode.isRanked()) if (!mode.isRanked())
@ -67,4 +71,9 @@ public class RankCommand extends BasicCommand {
Message.send("RANK_EMBLEM", player, UserElo.getEmblemProgression(player, mode.getChatName(), user.getId())); Message.send("RANK_EMBLEM", player, UserElo.getEmblemProgression(player, mode.getChatName(), user.getId()));
} }
} }
@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()));
}
} }