Move and encapsulate "ignored" collection

This commit is contained in:
P0nk
2021-12-21 21:42:57 +01:00
parent 75a9a9718d
commit acde0696b1
4 changed files with 41 additions and 17 deletions

View File

@@ -25,14 +25,14 @@ package client.command.commands.gm3;
import client.Character;
import client.Client;
import client.autoban.AutobanFactory;
import client.command.Command;
import net.packet.logging.MonitoredChrLogger;
import net.server.Server;
import tools.PacketCreator;
public class IgnoreCommand extends Command {
{
setDescription("Toggle enable/disable ignore a player in packet logs and autoban.");
setDescription("Toggle ignore a character from auto-ban alerts.");
}
@Override
@@ -47,14 +47,10 @@ public class IgnoreCommand extends Command {
player.message("Player '" + params[0] + "' could not be found on this world.");
return;
}
boolean monitored_ = MonitoredChrLogger.ignored.contains(victim.getId());
if (monitored_) {
MonitoredChrLogger.ignored.remove(victim.getId());
} else {
MonitoredChrLogger.ignored.add(victim.getId());
}
player.yellowMessage(victim.getName() + " is " + (!monitored_ ? "now being ignored." : "no longer being ignored."));
String message_ = player.getName() + (!monitored_ ? " has started ignoring " : " has stopped ignoring ") + victim.getName() + ".";
boolean ignored = AutobanFactory.toggleIgnored(victim.getId());
player.yellowMessage(victim.getName() + " is " + (ignored ? "now being ignored." : "no longer being ignored."));
String message_ = player.getName() + (ignored ? " has started ignoring " : " has stopped ignoring ") + victim.getName() + ".";
Server.getInstance().broadcastGMMessage(c.getWorld(), PacketCreator.serverNotice(5, message_));
}

View File

@@ -25,19 +25,19 @@ package client.command.commands.gm3;
import client.Character;
import client.Client;
import client.autoban.AutobanFactory;
import client.command.Command;
import net.packet.logging.MonitoredChrLogger;
public class IgnoredCommand extends Command {
{
setDescription("Show all players being ignored in logs.");
setDescription("Show all characters being ignored in auto-ban alerts.");
}
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
for (Integer cid : MonitoredChrLogger.ignored) {
player.yellowMessage(Character.getNameById(cid) + " is being ignored.");
for (int chrId : AutobanFactory.getIgnoredChrIds()) {
player.yellowMessage(Character.getNameById(chrId) + " is being ignored.");
}
}
}