This commit is contained in:
asofold 2012-08-08 20:39:01 +02:00
parent 52ee9ef7b1
commit 2906a33bec
5 changed files with 38 additions and 218 deletions

132
pom.xml
View File

@ -1,132 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- Informations -->
<name>NoCheatPlus</name>
<version>3.7</version>
<description>Detect and fight the exploitation of various flaws/bugs in Minecraft.</description>
<url>http://dev.bukkit.org/server-mods/nocheatplus</url>
<groupId>fr.neatmonster.nocheatplus</groupId>
<artifactId>NoCheatPlus</artifactId>
<packaging>jar</packaging>
<!-- License -->
<licenses>
<license>
<name>GNU General Public License v3</name>
<url>http://www.gnu.org/licenses/gpl-3.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<!-- Source code -->
<scm>
<developerConnection>scm:git:git@github.com:NeatMonster/${project.name}.git</developerConnection>
<connection>scm:git:git://github.com/NeatMonster/${project.name}.git</connection>
<url>https://github.com/NeatMonster/${project.name}</url>
</scm>
<!-- Repositories -->
<repositories>
<repository>
<id>bukkit</id>
<name>Bukkit</name>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
</repositories>
<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.3.1-R1.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<!-- Building -->
<build>
<defaultGoal>clean package</defaultGoal>
<sourceDirectory>${basedir}/src</sourceDirectory>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>${basedir}</directory>
<includes>
<include>plugin.yml</include>
<include>LICENSE.txt</include>
<include>Instructions.txt</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<finalName>NoCheatPlus</finalName>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<pomPropertiesFile>false</pomPropertiesFile>
<manifest>
<addDefaultSpecificationEntries>false</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>false</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>deploy-build</id>
<phase>install</phase>
<configuration>
<target>
<property file="auth.properties" prefix="auth" />
<scp todir="${auth.user}:${auth.pass}@${auth.host}:${auth.path}"
file="target/NoCheatPlus.jar" sftp="yes" trust="yes"
failonerror="no" />
<sshexec host="${auth.host}" username="${auth.user}"
password="${auth.pass}" command="${auth.cmd}" trust="yes"
failonerror="no" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.8.4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<!-- Properties -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -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

View File

@ -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<Long, String> joins = new HashMap<Long, String>();
/**
* 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<Long> toRemove = new ArrayList<Long>();
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;
}
}

View File

@ -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);
}
}

View File

@ -37,7 +37,6 @@ public class ChatData {
}
// Violation levels.
public double arrivalsVL;
public double colorVL;
public double noPwnageVL;