From 4fc0e69a472ba3bc0860cdbb3965e534582b58cc Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 14 Jun 2022 21:56:04 +0200 Subject: [PATCH] Update IgnoreCommand --- .../bungeecore/commands/IgnoreCommand.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/IgnoreCommand.java b/src/de/steamwar/bungeecore/commands/IgnoreCommand.java index 9151fdef..0c11ee0c 100644 --- a/src/de/steamwar/bungeecore/commands/IgnoreCommand.java +++ b/src/de/steamwar/bungeecore/commands/IgnoreCommand.java @@ -22,28 +22,26 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.sql.IgnoreSystem; 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.connection.ProxiedPlayer; -public class IgnoreCommand extends BasicCommand { +import java.util.stream.Collectors; + +public class IgnoreCommand extends SWCommand { public IgnoreCommand() { super("ignore", null); } - @Override - public void execute(CommandSender sender, String[] args) { - if(args.length < 1) { - Message.send("USAGE_IGNORE", sender); - return; - } - - if (!(sender instanceof ProxiedPlayer)) - return; - ProxiedPlayer p = (ProxiedPlayer) sender; + @Register(description = "USAGE_IGNORE") + public void genericCommand(ProxiedPlayer p, @Mapper("player") String toIgnore) { SteamwarUser user = SteamwarUser.get(p.getUniqueId()); - SteamwarUser target = SteamwarUser.get(args[0]); + SteamwarUser target = SteamwarUser.get(toIgnore); if(target == null){ Message.send("UNKNOWN_PLAYER", p); return; @@ -60,4 +58,9 @@ public class IgnoreCommand extends BasicCommand { IgnoreSystem.ignore(user, target); Message.send("IGNORE_MESSAGE", p, target.getUserName()); } + + @Mapper(value = "player", local = true) + public TypeMapper playerTypeMapper() { + return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList())); + } }