SteamWar/BungeeCore
Archiviert
13
2

Update IgnoreCommand
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-06-14 21:56:04 +02:00
Ursprung 8823368f0d
Commit 4fc0e69a47

Datei anzeigen

@ -22,28 +22,26 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.IgnoreSystem; import de.steamwar.bungeecore.sql.IgnoreSystem;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
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;
public class IgnoreCommand extends BasicCommand { import java.util.stream.Collectors;
public class IgnoreCommand extends SWCommand {
public IgnoreCommand() { public IgnoreCommand() {
super("ignore", null); super("ignore", null);
} }
@Override @Register(description = "USAGE_IGNORE")
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer p, @Mapper("player") String toIgnore) {
if(args.length < 1) {
Message.send("USAGE_IGNORE", sender);
return;
}
if (!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer p = (ProxiedPlayer) sender;
SteamwarUser user = SteamwarUser.get(p.getUniqueId()); SteamwarUser user = SteamwarUser.get(p.getUniqueId());
SteamwarUser target = SteamwarUser.get(args[0]); SteamwarUser target = SteamwarUser.get(toIgnore);
if(target == null){ if(target == null){
Message.send("UNKNOWN_PLAYER", p); Message.send("UNKNOWN_PLAYER", p);
return; return;
@ -60,4 +58,9 @@ public class IgnoreCommand extends BasicCommand {
IgnoreSystem.ignore(user, target); IgnoreSystem.ignore(user, target);
Message.send("IGNORE_MESSAGE", p, target.getUserName()); Message.send("IGNORE_MESSAGE", p, target.getUserName());
} }
@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()));
}
} }