From 2906a33bec003e6fa0a00c5bc8fcfd480800ab86 Mon Sep 17 00:00:00 2001 From: asofold Date: Wed, 8 Aug 2012 20:39:01 +0200 Subject: [PATCH] merged. --- pom.xml | 132 ------------------ .../nocheatplus/CommandHandler.java | 34 +++++ .../nocheatplus/checks/chat/Arrivals.java | 73 ---------- .../nocheatplus/checks/chat/ChatConfig.java | 16 +-- .../nocheatplus/checks/chat/ChatData.java | 1 - 5 files changed, 38 insertions(+), 218 deletions(-) delete mode 100644 pom.xml delete mode 100644 src/fr/neatmonster/nocheatplus/checks/chat/Arrivals.java diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 3dc3f329..00000000 --- a/pom.xml +++ /dev/null @@ -1,132 +0,0 @@ - - 4.0.0 - - - NoCheatPlus - 3.7 - Detect and fight the exploitation of various flaws/bugs in Minecraft. - http://dev.bukkit.org/server-mods/nocheatplus - - fr.neatmonster.nocheatplus - NoCheatPlus - jar - - - - - GNU General Public License v3 - http://www.gnu.org/licenses/gpl-3.0.html - repo - - - - - - scm:git:git@github.com:NeatMonster/${project.name}.git - scm:git:git://github.com/NeatMonster/${project.name}.git - https://github.com/NeatMonster/${project.name} - - - - - - bukkit - Bukkit - http://repo.bukkit.org/content/groups/public/ - - - - - - - org.bukkit - craftbukkit - 1.3.1-R1.0 - jar - compile - - - - - - clean package - ${basedir}/src - - - . - true - ${basedir} - - plugin.yml - LICENSE.txt - Instructions.txt - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.5.1 - - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - NoCheatPlus - - false - false - - false - false - - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.7 - - - deploy-build - install - - - - - - - - - run - - - - - - org.apache.ant - ant-jsch - 1.8.4 - - - - - - - - - UTF-8 - - \ No newline at end of file diff --git a/src/fr/neatmonster/nocheatplus/CommandHandler.java b/src/fr/neatmonster/nocheatplus/CommandHandler.java index 729ae94b..c838dfa3 100644 --- a/src/fr/neatmonster/nocheatplus/CommandHandler.java +++ b/src/fr/neatmonster/nocheatplus/CommandHandler.java @@ -1,10 +1,13 @@ package fr.neatmonster.nocheatplus; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; import fr.neatmonster.nocheatplus.checks.blockbreak.BlockBreakConfig; import fr.neatmonster.nocheatplus.checks.blockinteract.BlockInteractConfig; @@ -38,6 +41,34 @@ import fr.neatmonster.nocheatplus.players.Permissions; * This the class handling all the commands. */ public class CommandHandler implements CommandExecutor { + + /** + * The event triggered when NoCheatPlus configuration is reloaded. + */ + public static class NCPReloadEvent extends Event { + + /** The handlers list. */ + private static final HandlerList handlers = new HandlerList(); + + /** + * Gets the handler list. + * + * @return the handler list + */ + public static HandlerList getHandlerList() { + return handlers; + } + + /* (non-Javadoc) + * @see org.bukkit.event.Event#getHandlers() + */ + @Override + public HandlerList getHandlers() { + return handlers; + } + } + + /** The plugin. */ private final NoCheatPlus plugin; /** @@ -73,6 +104,9 @@ public class CommandHandler implements CommandExecutor { InventoryConfig.clear(); MovingConfig.clear(); + // Say to the other plugins that we've reloaded the configuration. + Bukkit.getPluginManager().callEvent(new NCPReloadEvent()); + sender.sendMessage(ChatColor.RED + "NCP: " + ChatColor.WHITE + "Configuration reloaded!"); } else sender.sendMessage(ChatColor.RED + "You lack the " + Permissions.ADMINISTRATION_RELOAD diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/Arrivals.java b/src/fr/neatmonster/nocheatplus/checks/chat/Arrivals.java deleted file mode 100644 index 2c039249..00000000 --- a/src/fr/neatmonster/nocheatplus/checks/chat/Arrivals.java +++ /dev/null @@ -1,73 +0,0 @@ -package fr.neatmonster.nocheatplus.checks.chat; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.bukkit.entity.Player; - -import fr.neatmonster.nocheatplus.NoCheatPlus; -import fr.neatmonster.nocheatplus.checks.Check; -import fr.neatmonster.nocheatplus.checks.CheckType; - -/* - * MMP"""""""MM oo dP - * M' .mmmm MM 88 - * M `M 88d888b. 88d888b. dP dP .dP .d8888b. 88 .d8888b. - * M MMMMM MM 88' `88 88' `88 88 88 d8' 88' `88 88 Y8ooooo. - * M MMMMM MM 88 88 88 88 .88' 88. .88 88 88 - * M MMMMM MM dP dP dP 8888P' `88888P8 dP `88888P' - * MMMMMMMMMMMM - */ -/** - * The Arrivals check is used to limit the number of new players allowed to join in a specified time frame. - */ -public class Arrivals extends Check { - - /** The map containing the time and the name of the player, every time that one of them joins. */ - private final Map joins = new HashMap(); - - /** - * Instantiates a new arrivals check. - */ - public Arrivals() { - super(CheckType.CHAT_ARRIVALS); - } - - /** - * Checks a player. - * - * @param player - * the player - * @return true, if successful - */ - public boolean check(final Player player) { - final ChatConfig cc = ChatConfig.getConfig(player); - - // If the server has just restarted or if the player is a regular one, do not check it. - if (System.currentTimeMillis() - NoCheatPlus.time < 120000L - || System.currentTimeMillis() - player.getFirstPlayed() > cc.arrivalsJoinsLimit) - return false; - - boolean cancel = false; - - // Remove the old data from the map holding the joins. - final List toRemove = new ArrayList(); - for (final long time : joins.keySet()) - // If the data is too old or belong to the checked player. - if (System.currentTimeMillis() - time > cc.arrivalsTimeLimit && joins.get(time).equals(player.getName())) - toRemove.add(time); - for (final long time : toRemove) - joins.remove(time); - - // Add the new data. - joins.put(System.currentTimeMillis(), player.getName()); - - if (joins.size() > cc.arrivalsJoinsLimit) - // Find out if we should cancel the event or not. - cancel = executeActions(player); - - return cancel; - } -} diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java b/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java index dc5dbd99..86fec486 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java @@ -55,12 +55,6 @@ public class ChatConfig { } } - public final boolean arrivalsCheck; - public final int arrivalsJoinsLimit; - public final String arrivalsMessage; - public final long arrivalsTimeLimit; - public final ActionList arrivalsActions; - public final boolean colorCheck; public final ActionList colorActions; @@ -116,6 +110,8 @@ public class ChatConfig { public final ActionList noPwnageActions; + public final boolean opInConsoleOnly; + public final boolean protectPlugins; /** @@ -125,12 +121,6 @@ public class ChatConfig { * the data */ public ChatConfig(final ConfigFile data) { - arrivalsCheck = data.getBoolean(ConfPaths.CHAT_ARRIVALS_CHECK); - arrivalsJoinsLimit = data.getInt(ConfPaths.CHAT_ARRIVALS_JOINSLIMIT); - arrivalsMessage = data.getString(ConfPaths.CHAT_ARRIVALS_MESSAGE); - arrivalsTimeLimit = data.getLong(ConfPaths.CHAT_ARRIVALS_TIMELIMIT); - arrivalsActions = data.getActionList(ConfPaths.CHAT_ARRIVALS_ACTIONS, Permissions.CHAT_ARRIVALS); - colorCheck = data.getBoolean(ConfPaths.CHAT_COLOR_CHECK); colorActions = data.getActionList(ConfPaths.CHAT_COLOR_ACTIONS, Permissions.CHAT_COLOR); @@ -186,6 +176,8 @@ public class ChatConfig { noPwnageActions = data.getActionList(ConfPaths.CHAT_NOPWNAGE_ACTIONS, Permissions.CHAT_NOPWNAGE); + opInConsoleOnly = data.getBoolean(ConfPaths.MISCELLANEOUS_OPINCONSOLEONLY); + protectPlugins = data.getBoolean(ConfPaths.MISCELLANEOUS_PROTECTPLUGINS); } } diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/ChatData.java b/src/fr/neatmonster/nocheatplus/checks/chat/ChatData.java index a70983ce..37610e7c 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/ChatData.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/ChatData.java @@ -37,7 +37,6 @@ public class ChatData { } // Violation levels. - public double arrivalsVL; public double colorVL; public double noPwnageVL;