summaryrefslogtreecommitdiffstats
path: root/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions')
-rw-r--r--EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/Action.java32
-rw-r--r--EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/ParameterName.java35
-rw-r--r--EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/ActionList.java86
-rw-r--r--EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/ActionWithParameters.java94
-rw-r--r--EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/ConsolecommandAction.java39
-rw-r--r--EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/DummyAction.java26
-rw-r--r--EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/LogAction.java76
-rw-r--r--EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/SpecialAction.java22
8 files changed, 0 insertions, 410 deletions
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/Action.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/Action.java
deleted file mode 100644
index aa72472ff..000000000
--- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/Action.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.earth2me.essentials.anticheat.actions;
-
-
-/**
- * An action gets executed as the result of a failed check. If it 'really' gets executed depends on how many executions
- * have occurred within the last 60 seconds and how much time was between this and the previous execution
- *
- */
-public abstract class Action
-{
- /**
- * Delay in violations. An "ExecutionHistory" will use this info to make sure that there were at least "delay"
- * attempts to execute this action before it really gets executed.
- */
- public final int delay;
- /**
- * Repeat only every "repeat" seconds. An "ExecutionHistory" will use this info to make sure that there were at
- * least "repeat" seconds between the last execution of this action and this execution.
- */
- public final int repeat;
- /**
- * The name of the action, to identify it, e.g. in the config file
- */
- public final String name;
-
- public Action(String name, int delay, int repeat)
- {
- this.name = name;
- this.delay = delay;
- this.repeat = repeat;
- }
-}
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/ParameterName.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/ParameterName.java
deleted file mode 100644
index 6f2b2181e..000000000
--- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/ParameterName.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.earth2me.essentials.anticheat.actions;
-
-
-/**
- * Some wildcards that are used in commands and log messages
- */
-public enum ParameterName
-{
- PLAYER("player"), LOCATION("location"), WORLD("world"),
- VIOLATIONS("violations"), MOVEDISTANCE("movedistance"),
- REACHDISTANCE("reachdistance"), FALLDISTANCE("falldistance"),
- LOCATION_TO("locationto"), CHECK("check"), PACKETS("packets"),
- TEXT("text"), PLACE_LOCATION("placelocation"),
- PLACE_AGAINST("placeagainst"), BLOCK_TYPE("blocktype"), LIMIT("limit"),
- FOOD("food"), SERVERS("servers");
- private final String s;
-
- private ParameterName(String s)
- {
- this.s = s;
- }
-
- public static ParameterName get(String s)
- {
- for (ParameterName c : ParameterName.values())
- {
- if (c.s.equals(s))
- {
- return c;
- }
- }
-
- return null;
- }
-}
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/ActionList.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/ActionList.java
deleted file mode 100644
index 25a7ba296..000000000
--- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/ActionList.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.earth2me.essentials.anticheat.actions.types;
-
-import com.earth2me.essentials.anticheat.actions.Action;
-import java.util.*;
-
-
-/**
- * A list of actions, that associates actions to tresholds. It allows to retrieve all actions that match a certain
- * treshold
- *
- */
-public class ActionList
-{
- // This is a very bad design decision, but it's also really
- // convenient to define this here
- public final String permissionSilent;
-
- public ActionList(String permission)
- {
- this.permissionSilent = permission + ".silent";
- }
- // If there are no actions registered, we still return an Array. It's
- // just empty/size=0
- private final static Action[] emptyArray = new Action[0];
- // The actions of this ActionList, "bundled" by treshold (violation level)
- private final Map<Integer, Action[]> actions = new HashMap<Integer, Action[]>();
- // The tresholds of this list
- private final List<Integer> tresholds = new ArrayList<Integer>();
-
- /**
- * Add an entry to this actionList. The list will be sorted by tresholds automatically after the insertion.
- *
- * @param treshold The minimum violation level a player needs to have to be suspected to the given actions
- * @param actions The actions that will be used if the player reached the accompanying treshold/violation level
- */
- public void setActions(Integer treshold, Action[] actions)
- {
-
- if (!this.tresholds.contains(treshold))
- {
- this.tresholds.add(treshold);
- Collections.sort(this.tresholds);
- }
-
- this.actions.put(treshold, actions);
- }
-
- /**
- * Get a list of actions that match the violation level. The only method that has to be called by a check
- *
- * @param violationLevel The violation level that should be matched.
- * @return The array of actions whose treshold was closest to the violationLevel but not bigger
- */
- public Action[] getActions(double violationLevel)
- {
-
- Integer result = null;
-
- for (Integer treshold : tresholds)
- {
- if (treshold <= violationLevel)
- {
- result = treshold;
- }
- }
-
- if (result != null)
- {
- return actions.get(result);
- }
- else
- {
- return emptyArray;
- }
- }
-
- /**
- * Get a sorted list of the tresholds/violation levels that were used in this list
- *
- * @return The sorted list of tresholds
- */
- public List<Integer> getTresholds()
- {
- return tresholds;
- }
-}
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/ActionWithParameters.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/ActionWithParameters.java
deleted file mode 100644
index c07d20198..000000000
--- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/ActionWithParameters.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package com.earth2me.essentials.anticheat.actions.types;
-
-import com.earth2me.essentials.anticheat.NoCheatPlayer;
-import com.earth2me.essentials.anticheat.actions.Action;
-import com.earth2me.essentials.anticheat.actions.ParameterName;
-import com.earth2me.essentials.anticheat.checks.Check;
-import java.util.ArrayList;
-
-
-/**
- * Action with parameters is used to
- *
- */
-public abstract class ActionWithParameters extends Action
-{
- private final ArrayList<Object> messageParts;
-
- public ActionWithParameters(String name, int delay, int repeat, String message)
- {
- super(name, delay, repeat);
-
- messageParts = new ArrayList<Object>();
-
- parseMessage(message);
- }
-
- private void parseMessage(String message)
- {
- String parts[] = message.split("\\[", 2);
-
- // No opening braces left
- if (parts.length != 2)
- {
- messageParts.add(message);
- }
- // Found an opening brace
- else
- {
- String parts2[] = parts[1].split("\\]", 2);
-
- // Found no matching closing brace
- if (parts2.length != 2)
- {
- messageParts.add(message);
- }
- // Found a matching closing brace
- else
- {
- ParameterName w = ParameterName.get(parts2[0]);
-
- if (w != null)
- {
- // Found an existing wildcard inbetween the braces
- messageParts.add(parts[0]);
- messageParts.add(w);
-
- // Go further down recursive
- parseMessage(parts2[1]);
- }
- else
- {
- messageParts.add(message);
- }
- }
- }
- }
-
- /**
- * Get a string with all the wildcards replaced with data from LogData
- *
- * @param data
- * @return
- */
- protected String getMessage(NoCheatPlayer player, Check check)
- {
-
- StringBuilder log = new StringBuilder(100); // Should be big enough most
- // of the time
-
- for (Object part : messageParts)
- {
- if (part instanceof String)
- {
- log.append((String)part);
- }
- else
- {
- log.append(check.getParameter((ParameterName)part, player));
- }
- }
-
- return log.toString();
- }
-}
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/ConsolecommandAction.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/ConsolecommandAction.java
deleted file mode 100644
index 5af889c16..000000000
--- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/ConsolecommandAction.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.earth2me.essentials.anticheat.actions.types;
-
-import com.earth2me.essentials.anticheat.NoCheatPlayer;
-import com.earth2me.essentials.anticheat.checks.Check;
-
-
-/**
- * Execute a command by imitating an admin typing the command directly into the console
- *
- */
-public class ConsolecommandAction extends ActionWithParameters
-{
- public ConsolecommandAction(String name, int delay, int repeat, String command)
- {
- // Log messages may have color codes now
- super(name, delay, repeat, command);
- }
-
- /**
- * Fill in the placeholders ( stuff that looks like '[something]') with information, make a nice String out of it
- * that can be directly used as a command in the console.
- *
- * @param player The player that is used to fill in missing data
- * @param check The check that is used to fill in missing data
- * @return The complete, ready to use, command
- */
- public String getCommand(NoCheatPlayer player, Check check)
- {
- return super.getMessage(player, check);
- }
-
- /**
- * Convert the commands data into a string that can be used in the config files
- */
- public String toString()
- {
- return "cmd:" + name + ":" + delay + ":" + repeat;
- }
-}
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/DummyAction.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/DummyAction.java
deleted file mode 100644
index d89372144..000000000
--- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/DummyAction.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.earth2me.essentials.anticheat.actions.types;
-
-import com.earth2me.essentials.anticheat.actions.Action;
-
-
-/**
- * If an action can't be parsed correctly, at least keep it stored in this form to not lose it when loading/storing the
- * config file
- *
- */
-public class DummyAction extends Action
-{
- // The original string used for this action definition
- private final String def;
-
- public DummyAction(String def)
- {
- super("dummyAction", 10000, 10000);
- this.def = def;
- }
-
- public String toString()
- {
- return def;
- }
-}
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/LogAction.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/LogAction.java
deleted file mode 100644
index 16830b8d7..000000000
--- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/LogAction.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.earth2me.essentials.anticheat.actions.types;
-
-import com.earth2me.essentials.anticheat.NoCheatPlayer;
-import com.earth2me.essentials.anticheat.checks.Check;
-
-
-/**
- * Print a log message to various locations
- *
- */
-public class LogAction extends ActionWithParameters
-{
- // Some flags to decide where the log message should show up, based on
- // the config file
- private final boolean toChat;
- private final boolean toConsole;
- private final boolean toFile;
-
- public LogAction(String name, int delay, int repeat, boolean toChat, boolean toConsole, boolean toFile, String message)
- {
- super(name, delay, repeat, message);
- this.toChat = toChat;
- this.toConsole = toConsole;
- this.toFile = toFile;
- }
-
- /**
- * Parse the final log message out of various data from the player and check that triggered the action.
- *
- * @param player The player that is used as a source for the log message
- * @param check The check that is used as a source for the log message
- * @return
- */
- public String getLogMessage(NoCheatPlayer player, Check check)
- {
- return super.getMessage(player, check);
- }
-
- /**
- * Should the message be shown in chat?
- *
- * @return true, if yes
- */
- public boolean toChat()
- {
- return toChat;
- }
-
- /**
- * Should the message be shown in the console?
- *
- * @return true, if yes
- */
- public boolean toConsole()
- {
- return toConsole;
- }
-
- /**
- * Should the message be written to the logfile?
- *
- * @return true, if yes
- */
- public boolean toFile()
- {
- return toFile;
- }
-
- /**
- * Create the string that's used to define the action in the logfile
- */
- public String toString()
- {
- return "log:" + name + ":" + delay + ":" + repeat + ":" + (toConsole ? "c" : "") + (toChat ? "i" : "") + (toFile ? "f" : "");
- }
-}
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/SpecialAction.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/SpecialAction.java
deleted file mode 100644
index 5e4a93b3d..000000000
--- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/SpecialAction.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.earth2me.essentials.anticheat.actions.types;
-
-import com.earth2me.essentials.anticheat.actions.Action;
-
-
-/**
- * Do something check-specific. Usually that is to cancel the event, undo something the player did, or do something the
- * server should've done
- *
- */
-public class SpecialAction extends Action
-{
- public SpecialAction()
- {
- super("cancel", 0, 0);
- }
-
- public String toString()
- {
- return "cancel";
- }
-}