Merge pull request 'Update RankCommand' (#396) from CommandRank into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #396 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
6bcafde70c
@ -23,32 +23,36 @@ import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
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.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RankCommand extends BasicCommand {
|
||||
public class RankCommand extends SWCommand {
|
||||
|
||||
public RankCommand() {
|
||||
super("rank", null);
|
||||
super("rank");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
@Register
|
||||
public void ownRank(ProxiedPlayer player) {
|
||||
rank(player, player.getName());
|
||||
}
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (args.length > 0) {
|
||||
SteamwarUser nUser = SteamwarUser.get(args[0]);
|
||||
if (nUser == null) {
|
||||
@Register
|
||||
public void rank(ProxiedPlayer player, @Mapper("player") String s) {
|
||||
SteamwarUser user = SteamwarUser.get(s);
|
||||
if (user == null) {
|
||||
Message.send("RANK_PLAYER_NOT_FOUND", player);
|
||||
return;
|
||||
}
|
||||
Message.send("RANK_PLAYER_FOUND", player, nUser.getUserName());
|
||||
user = nUser;
|
||||
if (!player.getName().equals(s)) {
|
||||
Message.send("RANK_PLAYER_FOUND", player, user.getUserName());
|
||||
}
|
||||
for(ArenaMode mode : ArenaMode.getAllModes()) {
|
||||
if (!mode.isRanked())
|
||||
@ -67,4 +71,9 @@ public class RankCommand extends BasicCommand {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren