diff --git a/src/cc/co/evenprime/bukkit/nocheat/actions/Action.java b/src/cc/co/evenprime/bukkit/nocheat/actions/Action.java index 3643fe66..002f1720 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/actions/Action.java +++ b/src/cc/co/evenprime/bukkit/nocheat/actions/Action.java @@ -9,9 +9,9 @@ package cc.co.evenprime.bukkit.nocheat.actions; public abstract class Action { public final int firstAfter; - public final int repeat; + public final boolean repeat; - public Action(int firstAfter, int repeat) { + public Action(int firstAfter, boolean repeat) { this.firstAfter = firstAfter; this.repeat = repeat; } diff --git a/src/cc/co/evenprime/bukkit/nocheat/actions/CancelAction.java b/src/cc/co/evenprime/bukkit/nocheat/actions/CancelAction.java index 5c6909fd..2af5361d 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/actions/CancelAction.java +++ b/src/cc/co/evenprime/bukkit/nocheat/actions/CancelAction.java @@ -9,7 +9,7 @@ public class CancelAction extends Action { public final static CancelAction cancel = new CancelAction(); - private CancelAction() { super(1, 1); } + private CancelAction() { super(1, true); } public String getName() { return "cancel"; diff --git a/src/cc/co/evenprime/bukkit/nocheat/actions/CustomAction.java b/src/cc/co/evenprime/bukkit/nocheat/actions/CustomAction.java index 4575cf06..ca9c89e0 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/actions/CustomAction.java +++ b/src/cc/co/evenprime/bukkit/nocheat/actions/CustomAction.java @@ -10,7 +10,7 @@ public class CustomAction extends Action { public final String command; - public CustomAction(int firstAfter, int repeat, String command) { + public CustomAction(int firstAfter, boolean repeat, String command) { super(firstAfter, repeat); this.command = command; } diff --git a/src/cc/co/evenprime/bukkit/nocheat/actions/LogAction.java b/src/cc/co/evenprime/bukkit/nocheat/actions/LogAction.java index 63905f5c..8ca270e3 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/actions/LogAction.java +++ b/src/cc/co/evenprime/bukkit/nocheat/actions/LogAction.java @@ -12,13 +12,13 @@ public class LogAction extends Action { public final Level level; // Log messages are shown after 1 violation and don't get repeated - public final static LogAction loglow = new LogAction(1, 0, Level.INFO); - public final static LogAction logmed = new LogAction(1, 0, Level.WARNING); - public final static LogAction loghigh = new LogAction(1, 0, Level.SEVERE); + public final static LogAction loglow = new LogAction(1, false, Level.INFO); + public final static LogAction logmed = new LogAction(1, false, Level.WARNING); + public final static LogAction loghigh = new LogAction(1, false, Level.SEVERE); public final static LogAction[] log = { loglow, logmed, loghigh }; - public LogAction(int firstAfter, int repeat, Level level) { + public LogAction(int firstAfter, boolean repeat, Level level) { super(firstAfter, repeat); this.level = level; } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/AirbuildCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/AirbuildCheck.java index 26a3c178..306b76ee 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/AirbuildCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/AirbuildCheck.java @@ -82,7 +82,7 @@ public class AirbuildCheck extends Check { // Execute actions in order for(Action a : actions) { if(a.firstAfter >= violations) { - if(a.firstAfter == violations || (a.repeat > 0 && (violations - a.firstAfter) % a.repeat == 0)) { + if(a.firstAfter == violations || a.repeat) { if(a instanceof LogAction) { final Location l = event.getBlockPlaced().getLocation(); String logMessage = "Airbuild: "+event.getPlayer().getName()+" tried to place block " + event.getBlockPlaced().getType() + " in the air at " + l.getBlockX() + "," + l.getBlockY() +"," + l.getBlockZ(); diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java index ad1f8752..36b6c999 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java @@ -454,7 +454,7 @@ public class MovingCheck extends Check { for(Action a : actions) { if(a.firstAfter >= violations) { - if(a.firstAfter == violations || (a.repeat > 0 && (violations - a.firstAfter) % a.repeat == 0)) { + if(a.firstAfter == violations || a.repeat) { if(a instanceof LogAction) { // prepare log message if necessary String log = String.format(logMessage, player.getName(), from.getWorld().getName(), to.getWorld().getName(), from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ()); diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/SpeedhackCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/SpeedhackCheck.java index 30249bcb..7d1baa8f 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/SpeedhackCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/SpeedhackCheck.java @@ -129,7 +129,7 @@ public class SpeedhackCheck extends Check { for(Action a : actions) { if(a.firstAfter >= violations) { - if(a.firstAfter == violations || (a.repeat > 0 && (violations - a.firstAfter) % a.repeat == 0)) { + if(a.firstAfter == violations || a.repeat) { if(a instanceof LogAction) { String log = String.format(logMessage, event.getPlayer().getName(), data.eventsSinceLastCheck*2, limits[0]); plugin.log(((LogAction)a).level, log); diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/CustomActionOption.java b/src/cc/co/evenprime/bukkit/nocheat/config/CustomActionOption.java index 2ff871ca..24846676 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/CustomActionOption.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/CustomActionOption.java @@ -5,7 +5,7 @@ import cc.co.evenprime.bukkit.nocheat.actions.CustomAction; public class CustomActionOption extends ChildOption { private int firstAfter; - private int repeat; + private boolean repeat; private String command; @@ -19,33 +19,33 @@ public class CustomActionOption extends ChildOption { private void parseCommand(String command) { - if(command.matches("\\[[0-9]*,[0-9]*\\] .*")) { + if(command.matches("\\[[0-9]*,[a-z]*\\] .*")) { String s[] = command.split(" ", 2); String s2[] = s[0].replace("[", "").replace("]", "").split(","); this.firstAfter = Integer.parseInt(s2[0]); - this.repeat = Integer.parseInt(s2[1]); + this.repeat = Boolean.parseBoolean(s2[1]); this.command = s[1]; } else if(command.matches("\\[[0-9]*\\] .*")) { String s[] = command.split(" ", 2); this.firstAfter = Integer.parseInt(s[0].replace("[", "").replace("]", "")); - this.repeat = 1; + this.repeat = true; this.command = s[1]; } else { this.command = command; this.firstAfter = 1; - this.repeat = 1; + this.repeat = true; } } @Override public String getValue() { - if(firstAfter <= 1) { + if(firstAfter <= 1 && repeat) { return command; } - else if(repeat <= 0) { + else if(repeat) { return "["+firstAfter+"] "+ command; } else { @@ -66,12 +66,12 @@ public class CustomActionOption extends ChildOption { this.command = command; } - public void setRepeatValue(int value) { + public void setRepeatValue(boolean value) { this.repeat = value; } - public int getRepeatValue() { + public boolean getRepeatValue() { return repeat; } diff --git a/src/cc/co/evenprime/bukkit/nocheat/wizard/gui/ChildOptionGuiFactory.java b/src/cc/co/evenprime/bukkit/nocheat/wizard/gui/ChildOptionGuiFactory.java index de79cc40..28216552 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/wizard/gui/ChildOptionGuiFactory.java +++ b/src/cc/co/evenprime/bukkit/nocheat/wizard/gui/ChildOptionGuiFactory.java @@ -79,26 +79,16 @@ public class ChildOptionGuiFactory { } }); - final JTextField repeat = new JTextField(String.valueOf(option.getRepeatValue())); + final JCheckBox repeat = new JCheckBox(); + repeat.setSelected(option.getRepeatValue()); - repeat.setColumns(3); - - repeat.setInputVerifier(new InputVerifier() { + repeat.addActionListener(new ActionListener() { @Override - public boolean verify(JComponent arg0) { - int value; - try { - value = Integer.parseInt(repeat.getText()); - option.setRepeatValue(value); - return true; - } - catch(Exception e) { - JOptionPane.showMessageDialog(repeat, "Illegal value for this field"); - repeat.setText(String.valueOf(option.getRepeatValue())); - return false; - } + public void actionPerformed(ActionEvent arg0) { + option.setRepeatValue(repeat.isSelected()); } + }); final JTextField firstAfter = new JTextField(String.valueOf(option.getFirstAfterValue()));