geforkt von SteamWar/BungeeCore
Merge pull request 'Update RankCommand' (#396) from CommandRank into master
Reviewed-on: SteamWar/BungeeCore#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.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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren