diff options
Diffstat (limited to 'EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/LogAction.java')
-rw-r--r-- | EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/LogAction.java | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/LogAction.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/LogAction.java new file mode 100644 index 000000000..16830b8d7 --- /dev/null +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/actions/types/LogAction.java @@ -0,0 +1,76 @@ +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" : ""); + } +} |