mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-02 13:57:49 +01:00
Refactoring: seperate listeners for different checks + instancing
instead of static for almost anything
This commit is contained in:
parent
6a6cb9e247
commit
77f347e182
@ -3,7 +3,7 @@ name: NoCheatPlugin
|
|||||||
author: Evenprime
|
author: Evenprime
|
||||||
|
|
||||||
main: cc.co.evenprime.bukkit.nocheat.NoCheatPlugin
|
main: cc.co.evenprime.bukkit.nocheat.NoCheatPlugin
|
||||||
version: 0.7.4
|
version: 0.7.4a
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
nocheat:
|
nocheat:
|
||||||
|
@ -19,60 +19,33 @@ import org.bukkit.util.config.Configuration;
|
|||||||
public class NoCheatConfiguration {
|
public class NoCheatConfiguration {
|
||||||
|
|
||||||
// Our personal logger
|
// Our personal logger
|
||||||
public static final String loggerName = "cc.co.evenprime.nocheat";
|
private final String loggerName = "cc.co.evenprime.nocheat";
|
||||||
public static final Logger logger = Logger.getLogger(loggerName);
|
public final Logger logger = Logger.getLogger(loggerName);
|
||||||
|
|
||||||
// Which checks are active
|
|
||||||
public static boolean speedhackCheckActive;
|
|
||||||
public static boolean movingCheckActive;
|
|
||||||
public static boolean airbuildCheckActive;
|
|
||||||
public static boolean bedteleportCheckActive;
|
|
||||||
|
|
||||||
// Limits for the speedhack check
|
|
||||||
public static int speedhackLimitLow;
|
|
||||||
public static int speedhackLimitMed;
|
|
||||||
public static int speedhackLimitHigh;
|
|
||||||
|
|
||||||
// How should speedhack violations be treated?
|
|
||||||
public static String speedhackActionMinor = "";
|
|
||||||
public static String speedhackActionNormal = "";
|
|
||||||
public static String speedhackActionHeavy = "";
|
|
||||||
|
|
||||||
public static int movingFreeMoves = 1;
|
|
||||||
|
|
||||||
// How should moving violations be treated?
|
|
||||||
public static String movingActionMinor = "";
|
|
||||||
public static String movingActionNormal = "";
|
|
||||||
public static String movingActionHeavy = "";
|
|
||||||
|
|
||||||
// How should airbuild violations be treated?
|
|
||||||
public static String airbuildActionLow = "";
|
|
||||||
public static String airbuildActionMed = "";
|
|
||||||
public static String airbuildActionHigh = "";
|
|
||||||
|
|
||||||
public static Runnable airbuildRunnable = null;
|
|
||||||
|
|
||||||
public static int airbuildLimitLow = 1;
|
|
||||||
public static int airbuildLimitMed = 3;
|
|
||||||
public static int airbuildLimitHigh = 10;
|
|
||||||
|
|
||||||
// The log level above which information gets logged to the specified logger
|
// The log level above which information gets logged to the specified logger
|
||||||
public static Level chatLevel = Level.OFF;
|
public Level chatLevel = Level.OFF;
|
||||||
public static Level ircLevel = Level.OFF;
|
public Level ircLevel = Level.OFF;
|
||||||
public static Level consoleLevel = Level.OFF;
|
public Level consoleLevel = Level.OFF;
|
||||||
|
|
||||||
public static String ircTag = "";
|
public String ircTag = "";
|
||||||
|
|
||||||
// Our log output to a file
|
// Our log output to a file
|
||||||
private static FileHandler fh = null;
|
private FileHandler fh = null;
|
||||||
|
|
||||||
private NoCheatConfiguration() {}
|
private final NoCheatPlugin plugin;
|
||||||
|
|
||||||
|
public NoCheatConfiguration(File configurationFile, NoCheatPlugin plugin) {
|
||||||
|
|
||||||
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
this.config(configurationFile);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the configuration file and assign either standard values or whatever is declared in the file
|
* Read the configuration file and assign either standard values or whatever is declared in the file
|
||||||
* @param configurationFile
|
* @param configurationFile
|
||||||
*/
|
*/
|
||||||
public static void config(File configurationFile) {
|
public void config(File configurationFile) {
|
||||||
|
|
||||||
if(!configurationFile.exists()) {
|
if(!configurationFile.exists()) {
|
||||||
createStandardConfigFile(configurationFile);
|
createStandardConfigFile(configurationFile);
|
||||||
@ -103,38 +76,30 @@ public class NoCheatConfiguration {
|
|||||||
ircLevel = stringToLevel(c.getString("logging.logtoirc"));
|
ircLevel = stringToLevel(c.getString("logging.logtoirc"));
|
||||||
ircTag = c.getString("logging.logtoirctag", "nocheat");
|
ircTag = c.getString("logging.logtoirctag", "nocheat");
|
||||||
|
|
||||||
speedhackCheckActive = c.getBoolean("active.speedhack", true);
|
plugin.speedhackCheck.limitLow = c.getInt("speedhack.limits.low", plugin.speedhackCheck.limitLow);
|
||||||
movingCheckActive = c.getBoolean("active.moving", true);
|
plugin.speedhackCheck.limitMed = c.getInt("speedhack.limits.med", plugin.speedhackCheck.limitMed);
|
||||||
airbuildCheckActive = c.getBoolean("active.airbuild", false);
|
plugin.speedhackCheck.limitHigh = c.getInt("speedhack.limits.high", plugin.speedhackCheck.limitHigh);
|
||||||
bedteleportCheckActive = c.getBoolean("active.bedteleport", true);
|
|
||||||
|
|
||||||
speedhackLimitLow = c.getInt("speedhack.limits.low", 30);
|
plugin.movingCheck.actionLow = c.getString("moving.action.low", plugin.movingCheck.actionLow);
|
||||||
speedhackLimitMed = c.getInt("speedhack.limits.med", 45);
|
plugin.movingCheck.actionMed = c.getString("moving.action.med", plugin.movingCheck.actionMed);
|
||||||
speedhackLimitHigh = c.getInt("speedhack.limits.high", 60);
|
plugin.movingCheck.actionHigh = c.getString("moving.action.high", plugin.movingCheck.actionHigh);
|
||||||
|
|
||||||
movingFreeMoves = c.getInt("moving.freemoves", 1);
|
plugin.speedhackCheck.actionLow = c.getString("speedhack.action.low", plugin.speedhackCheck.actionLow);
|
||||||
|
plugin.speedhackCheck.actionMed = c.getString("speedhack.action.med", plugin.speedhackCheck.actionMed);
|
||||||
|
plugin.speedhackCheck.actionHigh = c.getString("speedhack.action.high", plugin.speedhackCheck.actionHigh);
|
||||||
|
|
||||||
movingActionMinor = c.getString("moving.action.low", "loglow reset");
|
plugin.airbuildCheck.limitLow = c.getInt("airbuild.limits.low", plugin.airbuildCheck.limitLow);
|
||||||
movingActionNormal = c.getString("moving.action.med", "logmed reset");
|
plugin.airbuildCheck.limitMed = c.getInt("airbuild.limits.med", plugin.airbuildCheck.limitMed);
|
||||||
movingActionHeavy = c.getString("moving.action.high", "loghigh reset");
|
plugin.airbuildCheck.limitHigh = c.getInt("airbuild.limits.high", plugin.airbuildCheck.limitHigh);
|
||||||
|
|
||||||
speedhackActionMinor = c.getString("speedhack.action.low", "loglow reset");
|
plugin.airbuildCheck.actionLow = c.getString("airbuild.action.low", plugin.airbuildCheck.actionLow);
|
||||||
speedhackActionNormal = c.getString("speedhack.action.med", "logmed reset");
|
plugin.airbuildCheck.actionMed = c.getString("airbuild.action.med", plugin.airbuildCheck.actionMed);
|
||||||
speedhackActionHeavy = c.getString("speedhack.action.high", "loghigh reset");
|
plugin.airbuildCheck.actionHigh = c.getString("airbuild.action.high", plugin.airbuildCheck.actionHigh);
|
||||||
|
|
||||||
airbuildLimitLow = c.getInt("airbuild.limits.low", 1);
|
plugin.speedhackCheck.setActive(c.getBoolean("active.speedhack", plugin.speedhackCheck.isActive()));
|
||||||
airbuildLimitMed = c.getInt("airbuild.limits.med", 3);
|
plugin.movingCheck.setActive(c.getBoolean("active.moving", plugin.movingCheck.isActive()));
|
||||||
airbuildLimitHigh = c.getInt("airbuild.limits.high", 10);
|
plugin.airbuildCheck.setActive(c.getBoolean("active.airbuild", plugin.airbuildCheck.isActive()));
|
||||||
|
plugin.bedteleportCheck.setActive(c.getBoolean("active.bedteleport", plugin.bedteleportCheck.isActive()));
|
||||||
airbuildActionLow = c.getString("airbuild.action.low", "loglow deny");
|
|
||||||
airbuildActionMed = c.getString("airbuild.action.med", "logmed deny");
|
|
||||||
airbuildActionHigh = c.getString("airbuild.action.high", "loghigh deny");
|
|
||||||
|
|
||||||
|
|
||||||
// 1 is minimum. This is needed to smooth over some minecraft bugs like
|
|
||||||
// when a minecart gets broken while a player is inside it (which causes the player to "move"
|
|
||||||
// up 1.0D which is much more than a usual jump would allow in 1 event
|
|
||||||
if(movingFreeMoves < 1) movingFreeMoves = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,7 +123,7 @@ public class NoCheatConfiguration {
|
|||||||
* Standard configuration file for people who haven't got one yet
|
* Standard configuration file for people who haven't got one yet
|
||||||
* @param f
|
* @param f
|
||||||
*/
|
*/
|
||||||
private static void createStandardConfigFile(File f) {
|
private void createStandardConfigFile(File f) {
|
||||||
try {
|
try {
|
||||||
f.getParentFile().mkdirs();
|
f.getParentFile().mkdirs();
|
||||||
f.createNewFile();
|
f.createNewFile();
|
||||||
@ -174,42 +139,40 @@ public class NoCheatConfiguration {
|
|||||||
w.write(" logtoirctag: nocheat"); w.newLine();
|
w.write(" logtoirctag: nocheat"); w.newLine();
|
||||||
w.write("# Checks and Bugfixes that are activated (true or false)"); w.newLine();
|
w.write("# Checks and Bugfixes that are activated (true or false)"); w.newLine();
|
||||||
w.write("active:"); w.newLine();
|
w.write("active:"); w.newLine();
|
||||||
w.write(" speedhack: true"); w.newLine();
|
w.write(" speedhack: "+plugin.speedhackCheck.isActive()); w.newLine();
|
||||||
w.write(" moving: true"); w.newLine();
|
w.write(" moving: "+plugin.movingCheck.isActive()); w.newLine();
|
||||||
w.write(" airbuild: false"); w.newLine();
|
w.write(" airbuild: "+plugin.airbuildCheck.isActive()); w.newLine();
|
||||||
w.write(" bedteleport: true"); w.newLine();
|
w.write(" bedteleport: "+plugin.bedteleportCheck.isActive()); w.newLine();
|
||||||
w.write("# Speedhack specific options"); w.newLine();
|
w.write("# Speedhack specific options"); w.newLine();
|
||||||
w.write("speedhack:"); w.newLine();
|
w.write("speedhack:"); w.newLine();
|
||||||
w.write(" limits:"); w.newLine();
|
w.write(" limits:"); w.newLine();
|
||||||
w.write(" low: 30"); w.newLine();
|
w.write(" low: "+plugin.speedhackCheck.limitLow); w.newLine();
|
||||||
w.write(" med: 45"); w.newLine();
|
w.write(" med: "+plugin.speedhackCheck.limitMed); w.newLine();
|
||||||
w.write(" high: 60"); w.newLine();
|
w.write(" high: "+plugin.speedhackCheck.limitHigh); w.newLine();
|
||||||
w.write("# Speedhack Action, one or more of 'loglow logmed loghigh reset'"); w.newLine();
|
w.write("# Speedhack Action, one or more of 'loglow logmed loghigh reset'"); w.newLine();
|
||||||
w.write(" action:"); w.newLine();
|
w.write(" action:"); w.newLine();
|
||||||
w.write(" low: loglow reset"); w.newLine();
|
w.write(" low: "+plugin.speedhackCheck.actionLow); w.newLine();
|
||||||
w.write(" med: logmed reset"); w.newLine();
|
w.write(" med: "+plugin.speedhackCheck.actionMed); w.newLine();
|
||||||
w.write(" high: loghigh reset"); w.newLine();
|
w.write(" high: "+plugin.speedhackCheck.actionHigh); w.newLine();
|
||||||
w.write("# Moving specific options") ; w.newLine();
|
w.write("# Moving specific options") ; w.newLine();
|
||||||
w.write("moving:"); w.newLine();
|
w.write("moving:"); w.newLine();
|
||||||
w.write("# After how many minor violations should the plugin react (minimum 1)"); w.newLine();
|
|
||||||
w.write(" freemoves: 1"); w.newLine();
|
|
||||||
w.write("# Moving Action, one or more of 'loglow logmed loghigh reset'"); w.newLine();
|
w.write("# Moving Action, one or more of 'loglow logmed loghigh reset'"); w.newLine();
|
||||||
w.write(" action:"); w.newLine();
|
w.write(" action:"); w.newLine();
|
||||||
w.write(" low: loglow reset"); w.newLine();
|
w.write(" low: "+plugin.movingCheck.actionLow); w.newLine();
|
||||||
w.write(" med: logmed reset"); w.newLine();
|
w.write(" med: "+plugin.movingCheck.actionMed); w.newLine();
|
||||||
w.write(" high: loghigh reset"); w.newLine();
|
w.write(" high: "+plugin.movingCheck.actionHigh); w.newLine();
|
||||||
w.write("# Airbuild specific options"); w.newLine();
|
w.write("# Airbuild specific options"); w.newLine();
|
||||||
w.write("airbuild:"); w.newLine();
|
w.write("airbuild:"); w.newLine();
|
||||||
w.write("# How many blocks per second are placed by the player in midair (determines log level)"); w.newLine();
|
w.write("# How many blocks per second are placed by the player in midair (determines log level)"); w.newLine();
|
||||||
w.write(" limits:"); w.newLine();
|
w.write(" limits:"); w.newLine();
|
||||||
w.write(" low: 1"); w.newLine();
|
w.write(" low: "+plugin.airbuildCheck.limitLow); w.newLine();
|
||||||
w.write(" med: 3"); w.newLine();
|
w.write(" med: "+plugin.airbuildCheck.limitMed); w.newLine();
|
||||||
w.write(" high: 10"); w.newLine();
|
w.write(" high: "+plugin.airbuildCheck.limitHigh); w.newLine();
|
||||||
w.write("# Airbuild Action, one or more of 'loglow logmed loghigh deny'"); w.newLine();
|
w.write("# Airbuild Action, one or more of 'loglow logmed loghigh deny'"); w.newLine();
|
||||||
w.write(" action:"); w.newLine();
|
w.write(" action:"); w.newLine();
|
||||||
w.write(" low: loglow deny"); w.newLine();
|
w.write(" low: "+plugin.airbuildCheck.actionLow); w.newLine();
|
||||||
w.write(" med: logmed deny"); w.newLine();
|
w.write(" med: "+plugin.airbuildCheck.actionMed); w.newLine();
|
||||||
w.write(" high: loghigh deny"); w.newLine();
|
w.write(" high: "+plugin.airbuildCheck.actionHigh); w.newLine();
|
||||||
w.write("# Bedteleport specific options (none exist yet)"); w.newLine();
|
w.write("# Bedteleport specific options (none exist yet)"); w.newLine();
|
||||||
w.write("bedteleport:"); w.newLine();
|
w.write("bedteleport:"); w.newLine();
|
||||||
|
|
||||||
|
@ -15,9 +15,15 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.listeners.NoCheatBlockListener;
|
import cc.co.evenprime.bukkit.nocheat.checks.AirbuildCheck;
|
||||||
import cc.co.evenprime.bukkit.nocheat.listeners.NoCheatPlayerListener;
|
import cc.co.evenprime.bukkit.nocheat.checks.BedteleportCheck;
|
||||||
import cc.co.evenprime.bukkit.nocheat.listeners.NoCheatPlayerListenerMonitor;
|
import cc.co.evenprime.bukkit.nocheat.checks.MovingCheck;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.checks.SpeedhackCheck;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.listeners.AirbuildListener;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.listeners.BedteleportListener;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.listeners.MovingListener;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.listeners.MovingMonitor;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.listeners.SpeedhackListener;
|
||||||
|
|
||||||
import com.ensifera.animosity.craftirc.CraftIRC;
|
import com.ensifera.animosity.craftirc.CraftIRC;
|
||||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||||
@ -28,34 +34,36 @@ import org.bukkit.plugin.Plugin;
|
|||||||
*
|
*
|
||||||
* NoCheatPlugin
|
* NoCheatPlugin
|
||||||
*
|
*
|
||||||
* Check various player events for their plausibilty and log/deny them based on configuration
|
* Check various player events for their plausibility and log/deny them based on configuration
|
||||||
*
|
*
|
||||||
* @author Evenprime
|
* @author Evenprime
|
||||||
*/
|
*/
|
||||||
public class NoCheatPlugin extends JavaPlugin {
|
public class NoCheatPlugin extends JavaPlugin {
|
||||||
|
|
||||||
// Various listeners needed for different Checks
|
public final MovingCheck movingCheck;
|
||||||
private NoCheatPlayerListener playerListener;
|
public final BedteleportCheck bedteleportCheck;
|
||||||
private NoCheatPlayerListenerMonitor playerListenerMonitor;
|
public final SpeedhackCheck speedhackCheck;
|
||||||
private NoCheatBlockListener blockListener;
|
public final AirbuildCheck airbuildCheck;
|
||||||
|
|
||||||
// My main logger
|
private NoCheatConfiguration config;
|
||||||
private static Logger consoleLogger;
|
|
||||||
private static Logger fileLogger;
|
|
||||||
|
|
||||||
public static NoCheatPlugin p;
|
// Permissions 2.x, if available
|
||||||
|
private PermissionHandler permissions;
|
||||||
|
|
||||||
// Permissions 2.0, if available
|
// CraftIRC 2.x, if available
|
||||||
public static PermissionHandler Permissions = null;
|
private CraftIRC irc;
|
||||||
|
|
||||||
// CraftIRC 2.0, if available
|
|
||||||
public static CraftIRC Irc = null;
|
|
||||||
|
|
||||||
// Store data between Events
|
// Store data between Events
|
||||||
public static Map<Player, NoCheatData> playerData = new HashMap<Player, NoCheatData>();
|
private final Map<Player, NoCheatData> playerData = new HashMap<Player, NoCheatData>();
|
||||||
|
|
||||||
public NoCheatPlugin() {
|
public NoCheatPlugin() {
|
||||||
p = this;
|
movingCheck = new MovingCheck(this);
|
||||||
|
bedteleportCheck = new BedteleportCheck(this);
|
||||||
|
speedhackCheck = new SpeedhackCheck(this);
|
||||||
|
airbuildCheck = new AirbuildCheck(this);
|
||||||
|
|
||||||
|
// parse the nocheat.yml config file
|
||||||
|
setupConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +74,7 @@ public class NoCheatPlugin extends JavaPlugin {
|
|||||||
* @param p
|
* @param p
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static NoCheatData getPlayerData(Player p) {
|
public NoCheatData getPlayerData(Player p) {
|
||||||
NoCheatData data = null;
|
NoCheatData data = null;
|
||||||
|
|
||||||
if((data = playerData.get(p)) == null ) {
|
if((data = playerData.get(p)) == null ) {
|
||||||
@ -94,7 +102,7 @@ public class NoCheatPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args.length == 0) {
|
if(args.length == 0) {
|
||||||
sender.sendMessage("NC: Using "+ ((Permissions == null) ? "isOp()" : "Permissions") + ". Activated checks/bugfixes: " + getActiveChecksAsString());
|
sender.sendMessage("NC: Using "+ ((permissions == null) ? "isOp()" : "Permissions") + ". Activated checks/bugfixes: " + getActiveChecksAsString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(args.length == 1 && args[0] != null && args[0].trim().equals("-p")) {
|
else if(args.length == 1 && args[0] != null && args[0].trim().equals("-p")) {
|
||||||
@ -129,32 +137,35 @@ public class NoCheatPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
||||||
|
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
PluginDescriptionFile pdfFile = this.getDescription();
|
||||||
Logger.getLogger("Minecraft").info( "[NoCheatPlugin] version [" + pdfFile.getVersion() + "] is disabled.");
|
Logger.getLogger("Minecraft").info( "[NoCheatPlugin] version [" + pdfFile.getVersion() + "] is disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Create our listeners and feed them with neccessary information
|
// Create our listeners and feed them with neccessary information
|
||||||
playerListener = new NoCheatPlayerListener();
|
|
||||||
playerListenerMonitor = new NoCheatPlayerListenerMonitor();
|
|
||||||
blockListener = new NoCheatBlockListener();
|
|
||||||
|
|
||||||
fileLogger = NoCheatConfiguration.logger;
|
|
||||||
consoleLogger = Logger.getLogger("Minecraft");
|
|
||||||
|
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Lowest, this); // used for speedhack and moving checks
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Monitor, this); // used to delete old data of users
|
|
||||||
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Low, this); // used for airbuild check
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_TELEPORT, playerListener, Priority.Lowest, this); // used for teleportfrombed check
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_TELEPORT, playerListenerMonitor, Priority.Monitor, this); // used for moving, speedhack check
|
|
||||||
|
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
|
||||||
|
|
||||||
// parse the nocheat.yml config file
|
// parse the nocheat.yml config file
|
||||||
setupConfig();
|
setupConfig();
|
||||||
|
|
||||||
|
// Register listeners for moving check
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_MOVE, new MovingListener(movingCheck), Priority.Lowest, this);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_TELEPORT, new MovingMonitor(movingCheck), Priority.Monitor, this);
|
||||||
|
|
||||||
|
// Register listeners for speedhack check
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_MOVE, new SpeedhackListener(speedhackCheck), Priority.High, this);
|
||||||
|
|
||||||
|
// Register listeners for airbuild check
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_PLACED, new AirbuildListener(airbuildCheck), Priority.Low, this);
|
||||||
|
|
||||||
|
// Register listeners for bedteleport check
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_TELEPORT, new BedteleportListener(bedteleportCheck), Priority.Lowest, this);
|
||||||
|
|
||||||
|
PluginDescriptionFile pdfFile = this.getDescription();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Get, if available, the Permissions and irc plugin
|
// Get, if available, the Permissions and irc plugin
|
||||||
setupPermissions();
|
setupPermissions();
|
||||||
setupIRC();
|
setupIRC();
|
||||||
@ -165,7 +176,7 @@ public class NoCheatPlugin extends JavaPlugin {
|
|||||||
/**
|
/**
|
||||||
* Get, if available, a reference to the Permissions-plugin
|
* Get, if available, a reference to the Permissions-plugin
|
||||||
*/
|
*/
|
||||||
public void setupPermissions() {
|
private void setupPermissions() {
|
||||||
PermissionHandler p = null;
|
PermissionHandler p = null;
|
||||||
|
|
||||||
Plugin test = this.getServer().getPluginManager().getPlugin("Permissions");
|
Plugin test = this.getServer().getPluginManager().getPlugin("Permissions");
|
||||||
@ -183,13 +194,13 @@ public class NoCheatPlugin extends JavaPlugin {
|
|||||||
Logger.getLogger("Minecraft").warning("[NoCheatPlugin] version [" + pdfFile.getVersion() + "] couldn't find Permissions plugin. Fallback to 'isOp()' equals 'nocheat.*'");
|
Logger.getLogger("Minecraft").warning("[NoCheatPlugin] version [" + pdfFile.getVersion() + "] couldn't find Permissions plugin. Fallback to 'isOp()' equals 'nocheat.*'");
|
||||||
}
|
}
|
||||||
|
|
||||||
Permissions = p;
|
permissions = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get, if available, a reference to the Permissions-plugin
|
* Get, if available, a reference to the Permissions-plugin
|
||||||
*/
|
*/
|
||||||
public void setupIRC() {
|
private void setupIRC() {
|
||||||
CraftIRC p = null;
|
CraftIRC p = null;
|
||||||
|
|
||||||
Plugin test = this.getServer().getPluginManager().getPlugin("CraftIRC");
|
Plugin test = this.getServer().getPluginManager().getPlugin("CraftIRC");
|
||||||
@ -203,45 +214,46 @@ public class NoCheatPlugin extends JavaPlugin {
|
|||||||
Logger.getLogger("Minecraft").warning("[NoCheatPlugin] version [" + pdfFile.getVersion() + "] couldn't find CrafTIRC plugin. Disabling logging to IRC.");
|
Logger.getLogger("Minecraft").warning("[NoCheatPlugin] version [" + pdfFile.getVersion() + "] couldn't find CrafTIRC plugin. Disabling logging to IRC.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Irc = p;
|
irc = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a violation message to all locations declared in the config file
|
* Log a violation message to all locations declared in the config file
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
private static void log(Level l, String message) {
|
private void log(Level l, String message) {
|
||||||
if(l != null) {
|
if(l != null) {
|
||||||
logToChat(l, message);
|
logToChat(l, message);
|
||||||
logToIRC(l, message);
|
logToIRC(l, message);
|
||||||
logToConsole(l, message);
|
logToConsole(l, message);
|
||||||
fileLogger.log(l, message);
|
config.logger.log(l, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void logToChat(Level l, String message) {
|
private void logToChat(Level l, String message) {
|
||||||
if(NoCheatConfiguration.chatLevel.intValue() <= l.intValue()) {
|
if(config.chatLevel.intValue() <= l.intValue()) {
|
||||||
for(Player player : p.getServer().getOnlinePlayers()) {
|
for(Player player : getServer().getOnlinePlayers()) {
|
||||||
if(hasPermission(player, "nocheat.notify")) {
|
if(hasPermission(player, "nocheat.notify")) {
|
||||||
player.sendMessage("["+l.getName()+"] " + message);
|
player.sendMessage("["+l.getName()+"] " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static void logToIRC(Level l, String message) {
|
|
||||||
if(Irc != null && NoCheatConfiguration.ircLevel.intValue() <= l.intValue()) {
|
private void logToIRC(Level l, String message) {
|
||||||
Irc.sendMessageToTag("["+l.getName()+"] " + message , NoCheatConfiguration.ircTag);
|
if(irc != null && config.ircLevel.intValue() <= l.intValue()) {
|
||||||
|
irc.sendMessageToTag("["+l.getName()+"] " + message , config.ircTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void logToConsole(Level l, String message) {
|
private void logToConsole(Level l, String message) {
|
||||||
if( NoCheatConfiguration.consoleLevel.intValue() <= l.intValue()) {
|
if( config.consoleLevel.intValue() <= l.intValue()) {
|
||||||
consoleLogger.log(l, message);
|
Logger.getLogger("Minecraft").log(l, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logAction(String actions, String message) {
|
public void logAction(String actions, String message) {
|
||||||
if(actions == null) return;
|
if(actions == null) return;
|
||||||
|
|
||||||
// LOGGING IF NEEDED AND WHERE NEEDED
|
// LOGGING IF NEEDED AND WHERE NEEDED
|
||||||
@ -258,19 +270,19 @@ public class NoCheatPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(logLevel != null) {
|
if(logLevel != null) {
|
||||||
NoCheatPlugin.log(logLevel, "NC: "+message);
|
log(logLevel, "NC: "+message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPermission(Player player, String permission) {
|
public boolean hasPermission(Player player, String permission) {
|
||||||
|
|
||||||
if(player == null || permission == null) {
|
if(player == null || permission == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NoCheatPlugin.Permissions != null && NoCheatPlugin.Permissions.has(player, permission))
|
if(permissions != null && permissions.has(player, permission))
|
||||||
return true;
|
return true;
|
||||||
else if(NoCheatPlugin.Permissions == null && player.isOp())
|
else if(permissions == null && player.isOp())
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
@ -280,24 +292,26 @@ public class NoCheatPlugin extends JavaPlugin {
|
|||||||
* Read the config file
|
* Read the config file
|
||||||
*/
|
*/
|
||||||
private void setupConfig() {
|
private void setupConfig() {
|
||||||
NoCheatConfiguration.config(new File("plugins/NoCheat/nocheat.yml"));
|
if(this.config == null)
|
||||||
|
this.config = new NoCheatConfiguration(new File("plugins/NoCheat/nocheat.yml"), this);
|
||||||
|
else
|
||||||
|
this.config.config(new File("plugins/NoCheat/nocheat.yml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getActiveChecksAsString() {
|
private String getActiveChecksAsString() {
|
||||||
return (NoCheatConfiguration.movingCheckActive ? "moving ": "") +
|
return (movingCheck.isActive() ? movingCheck.getName() + " " : "") +
|
||||||
(NoCheatConfiguration.speedhackCheckActive ? "speedhack " : "") +
|
(speedhackCheck.isActive() ? speedhackCheck.getName() + " " : "") +
|
||||||
(NoCheatConfiguration.airbuildCheckActive ? "airbuild " : "") +
|
(airbuildCheck.isActive() ? airbuildCheck.getName() + " " : "") +
|
||||||
(NoCheatConfiguration.bedteleportCheckActive ? "bedteleport " : "");
|
(bedteleportCheck.isActive() ? bedteleportCheck.getName() + " " : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getPermissionsForPlayerAsString(Player p) {
|
private String getPermissionsForPlayerAsString(Player p) {
|
||||||
return (!NoCheatConfiguration.movingCheckActive ? "moving* ": (hasPermission(p, "nocheat.moving") ? "moving " : "") +
|
return (!movingCheck.isActive() ? movingCheck.getName() + "* " : (hasPermission(p, "nocheat.moving") ? movingCheck.getName() + " " : "") +
|
||||||
(!NoCheatConfiguration.speedhackCheckActive ? "speedhack* " : (hasPermission(p, "nocheat.speedhack") ? "speedhack " : "")) +
|
(!speedhackCheck.isActive() ? speedhackCheck.getName() + "* " : (hasPermission(p, "nocheat.speedhack") ? speedhackCheck.getName() + " " : "")) +
|
||||||
(!NoCheatConfiguration.airbuildCheckActive ? "airbuild* " : (hasPermission(p, "nocheat.airbuild") ? "airbuild " : "")) +
|
(!airbuildCheck.isActive() ? airbuildCheck.getName() + "* " : (hasPermission(p, "nocheat.airbuild") ? airbuildCheck.getName() + " " : "")) +
|
||||||
(!NoCheatConfiguration.bedteleportCheckActive ? "bedteleport* " : (hasPermission(p, "nocheat.bedteleport") ? "bedteleport " : "")) +
|
(!bedteleportCheck.isActive() ? bedteleportCheck.getName() + "* " : (hasPermission(p, "nocheat.bedteleport") ? bedteleportCheck.getName() + " " : "")) +
|
||||||
(hasPermission(p, "nocheat.notify") ? "notify " : ""));
|
(hasPermission(p, "nocheat.notify") ? "notify " : ""));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,6 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatConfiguration;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatData;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatData;
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||||
|
|
||||||
@ -16,18 +15,31 @@ import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
|||||||
* @author Evenprime
|
* @author Evenprime
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AirbuildCheck {
|
public class AirbuildCheck extends Check {
|
||||||
|
|
||||||
|
// How should airbuild violations be treated?
|
||||||
|
public String actionLow = "loglow deny";
|
||||||
|
public String actionMed = "logmed deny";
|
||||||
|
public String actionHigh = "loghigh deny";
|
||||||
|
|
||||||
public static void check(BlockPlaceEvent event) {
|
public int limitLow = 1;
|
||||||
|
public int limitMed = 3;
|
||||||
|
public int limitHigh = 10;
|
||||||
|
|
||||||
|
public AirbuildCheck(NoCheatPlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
setActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void check(BlockPlaceEvent event) {
|
||||||
|
|
||||||
// Should we check at all?
|
// Should we check at all?
|
||||||
if(NoCheatPlugin.hasPermission(event.getPlayer(), "nocheat.airbuild"))
|
if(plugin.hasPermission(event.getPlayer(), "nocheat.airbuild"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Are all 6 sides "air-blocks" -> cancel the event
|
// Are all 6 sides "air-blocks" -> cancel the event
|
||||||
if(event.getBlockAgainst().getType() == Material.AIR) {
|
if(event.getBlockAgainst().getType() == Material.AIR) {
|
||||||
final NoCheatData data = NoCheatPlugin.getPlayerData(event.getPlayer());
|
final NoCheatData data = plugin.getPlayerData(event.getPlayer());
|
||||||
final Player p = event.getPlayer();
|
final Player p = event.getPlayer();
|
||||||
|
|
||||||
if(data.airbuildRunnable == null) {
|
if(data.airbuildRunnable == null) {
|
||||||
@ -42,30 +54,30 @@ public class AirbuildCheck {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Give a summary in 50 ticks ~ 1 second
|
// Give a summary in 50 ticks ~ 1 second
|
||||||
NoCheatPlugin.p.getServer().getScheduler().scheduleAsyncDelayedTask(NoCheatPlugin.p, data.airbuildRunnable, 50);
|
plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, data.airbuildRunnable, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
data.airbuildPerSecond++;
|
data.airbuildPerSecond++;
|
||||||
|
|
||||||
boolean log = false;
|
boolean log = false;
|
||||||
// Only explicitly log certain "milestones"
|
// Only explicitly log certain "milestones"
|
||||||
if(data.airbuildPerSecond >= NoCheatConfiguration.airbuildLimitHigh) {
|
if(data.airbuildPerSecond >= limitHigh) {
|
||||||
if(data.airbuildPerSecond == NoCheatConfiguration.airbuildLimitHigh) {
|
if(data.airbuildPerSecond == limitHigh) {
|
||||||
log = true;
|
log = true;
|
||||||
}
|
}
|
||||||
action(NoCheatConfiguration.airbuildActionHigh, event, log);
|
action(actionHigh, event, log);
|
||||||
}
|
}
|
||||||
else if(data.airbuildPerSecond >= NoCheatConfiguration.airbuildLimitMed) {
|
else if(data.airbuildPerSecond >= limitMed) {
|
||||||
if(data.airbuildPerSecond == NoCheatConfiguration.airbuildLimitMed) {
|
if(data.airbuildPerSecond == limitMed) {
|
||||||
log = true;
|
log = true;
|
||||||
}
|
}
|
||||||
action(NoCheatConfiguration.airbuildActionMed, event, log);
|
action(actionMed, event, log);
|
||||||
}
|
}
|
||||||
else if(data.airbuildPerSecond >= NoCheatConfiguration.airbuildLimitLow) {
|
else if(data.airbuildPerSecond >= limitLow) {
|
||||||
if(data.airbuildPerSecond == NoCheatConfiguration.airbuildLimitLow) {
|
if(data.airbuildPerSecond == limitLow) {
|
||||||
log = true;
|
log = true;
|
||||||
}
|
}
|
||||||
action(NoCheatConfiguration.airbuildActionLow, event, log);
|
action(actionLow, event, log);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -74,12 +86,12 @@ public class AirbuildCheck {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void action(String action, BlockPlaceEvent event, boolean log) {
|
private void action(String action, BlockPlaceEvent event, boolean log) {
|
||||||
|
|
||||||
// LOG IF NEEDED
|
// LOG IF NEEDED
|
||||||
if(log && action.contains("log")) {
|
if(log && action.contains("log")) {
|
||||||
Location l = event.getBlockPlaced().getLocation();
|
Location l = event.getBlockPlaced().getLocation();
|
||||||
NoCheatPlugin.logAction(action, "Airbuild violation: "+event.getPlayer().getName()+" tried to place block " + event.getBlockPlaced().getType() + " in the air at " + l.getBlockX() + "," + l.getBlockY() +"," + l.getBlockZ());
|
plugin.logAction(action, "Airbuild violation: "+event.getPlayer().getName()+" tried to place block " + event.getBlockPlaced().getType() + " in the air at " + l.getBlockX() + "," + l.getBlockY() +"," + l.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// DENY IF NEEDED
|
// DENY IF NEEDED
|
||||||
@ -88,21 +100,26 @@ public class AirbuildCheck {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void summary(Player player, NoCheatData data) {
|
private void summary(Player player, NoCheatData data) {
|
||||||
|
|
||||||
String logLine = "Airbuild violation summary: " +player.getName() + " total events per second: " + data.airbuildPerSecond;
|
String logLine = "Airbuild violation summary: " +player.getName() + " total events per second: " + data.airbuildPerSecond;
|
||||||
|
|
||||||
// Give a summary according to the highest violation level we encountered in that second
|
// Give a summary according to the highest violation level we encountered in that second
|
||||||
if(data.airbuildPerSecond >= NoCheatConfiguration.airbuildLimitHigh) {
|
if(data.airbuildPerSecond >= limitHigh) {
|
||||||
NoCheatPlugin.logAction(NoCheatConfiguration.airbuildActionHigh, logLine);
|
plugin.logAction(actionHigh, logLine);
|
||||||
}
|
}
|
||||||
else if(data.airbuildPerSecond >= NoCheatConfiguration.airbuildLimitMed) {
|
else if(data.airbuildPerSecond >= limitMed) {
|
||||||
NoCheatPlugin.logAction(NoCheatConfiguration.airbuildActionMed, logLine);
|
plugin.logAction(actionMed, logLine);
|
||||||
}
|
}
|
||||||
else if(data.airbuildPerSecond >= NoCheatConfiguration.airbuildLimitLow) {
|
else if(data.airbuildPerSecond >= limitLow) {
|
||||||
NoCheatPlugin.logAction(NoCheatConfiguration.airbuildActionLow, logLine);
|
plugin.logAction(actionLow, logLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
data.airbuildPerSecond = 0;
|
data.airbuildPerSecond = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "airbuild";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,17 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||||
|
|
||||||
public class BedteleportCheck {
|
public class BedteleportCheck extends Check {
|
||||||
|
|
||||||
|
public BedteleportCheck(NoCheatPlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
setActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
public static void check(PlayerMoveEvent event) {
|
public void check(PlayerMoveEvent event) {
|
||||||
|
|
||||||
// Should we check at all?
|
// Should we check at all?
|
||||||
if(NoCheatPlugin.hasPermission(event.getPlayer(), "nocheat.bedteleport"))
|
if(plugin.hasPermission(event.getPlayer(), "nocheat.bedteleport"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(event.getFrom().getWorld().getBlockTypeIdAt(event.getFrom()) == Material.BED_BLOCK.getId()) {
|
if(event.getFrom().getWorld().getBlockTypeIdAt(event.getFrom()) == Material.BED_BLOCK.getId()) {
|
||||||
@ -21,4 +25,9 @@ public class BedteleportCheck {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "bedteleport";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
24
src/cc/co/evenprime/bukkit/nocheat/checks/Check.java
Normal file
24
src/cc/co/evenprime/bukkit/nocheat/checks/Check.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package cc.co.evenprime.bukkit.nocheat.checks;
|
||||||
|
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||||
|
|
||||||
|
|
||||||
|
public abstract class Check {
|
||||||
|
|
||||||
|
public Check(NoCheatPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean active = true;
|
||||||
|
protected NoCheatPlugin plugin;
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActive(boolean a) {
|
||||||
|
active = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract String getName();
|
||||||
|
}
|
@ -8,7 +8,6 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatConfiguration;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatData;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatData;
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||||
|
|
||||||
@ -18,10 +17,15 @@ import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
|||||||
* @author Evenprime
|
* @author Evenprime
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MovingCheck {
|
public class MovingCheck extends Check {
|
||||||
|
|
||||||
|
public MovingCheck(NoCheatPlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
setActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
// How many move events can a player have in air before he is expected to lose altitude (or land somewhere)
|
// How many move events can a player have in air before he is expected to lose altitude (or land somewhere)
|
||||||
static final int jumpingLimit = 3;
|
static final int jumpingLimit = 4;
|
||||||
|
|
||||||
// How high may a player get compared to his last location with ground contact
|
// How high may a player get compared to his last location with ground contact
|
||||||
static final double jumpingHeightLimit = 1.3D;
|
static final double jumpingHeightLimit = 1.3D;
|
||||||
@ -34,6 +38,11 @@ public class MovingCheck {
|
|||||||
public static double movingDistanceMed = 2.0D;
|
public static double movingDistanceMed = 2.0D;
|
||||||
public static double movingDistanceHigh = 5.0D;
|
public static double movingDistanceHigh = 5.0D;
|
||||||
|
|
||||||
|
// How should moving violations be treated?
|
||||||
|
public String actionLow = "loglow reset";
|
||||||
|
public String actionMed = "logmed reset";
|
||||||
|
public String actionHigh = "loghigh reset";
|
||||||
|
|
||||||
final static double magic = 0.30000001192092896D;
|
final static double magic = 0.30000001192092896D;
|
||||||
final static double magic2 = 0.69999998807907103D;
|
final static double magic2 = 0.69999998807907103D;
|
||||||
|
|
||||||
@ -135,14 +144,15 @@ public class MovingCheck {
|
|||||||
types[Material.CAKE_BLOCK.getId()]= BlockType.UNKNOWN;
|
types[Material.CAKE_BLOCK.getId()]= BlockType.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void check(final PlayerMoveEvent event) {
|
|
||||||
|
public void check(final PlayerMoveEvent event) {
|
||||||
|
|
||||||
// Should we check at all
|
// Should we check at all
|
||||||
if(NoCheatPlugin.hasPermission(event.getPlayer(), "nocheat.moving"))
|
if(plugin.hasPermission(event.getPlayer(), "nocheat.moving"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the player-specific data
|
// Get the player-specific data
|
||||||
NoCheatData data = NoCheatPlugin.getPlayerData(event.getPlayer());
|
NoCheatData data = plugin.getPlayerData(event.getPlayer());
|
||||||
|
|
||||||
// Notice to myself: How world changes with e.g. command /world work:
|
// Notice to myself: How world changes with e.g. command /world work:
|
||||||
// 1. TeleportEvent from the players current position to another position in the _same_ world
|
// 1. TeleportEvent from the players current position to another position in the _same_ world
|
||||||
@ -186,7 +196,7 @@ public class MovingCheck {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The server believes the player should be moving up, so we ignore this event
|
// The server believes the player should be moving up, so we ignore this event
|
||||||
if(event.getPlayer().getVelocity().getY() > 0) {
|
if(event.getPlayer().getVelocity().getY() >= 0) {
|
||||||
data.movingSetBackPoint = null;
|
data.movingSetBackPoint = null;
|
||||||
data.speedhackSetBackPoint = null;
|
data.speedhackSetBackPoint = null;
|
||||||
return;
|
return;
|
||||||
@ -345,20 +355,9 @@ public class MovingCheck {
|
|||||||
|
|
||||||
// Find out with what actions to treat the violation(s)
|
// Find out with what actions to treat the violation(s)
|
||||||
if(Level.INFO.equals(vl)) {
|
if(Level.INFO.equals(vl)) {
|
||||||
|
if(data.movingMinorViolationsInARow > 0) log = false;
|
||||||
data.movingMinorViolationsInARow++;
|
data.movingMinorViolationsInARow++;
|
||||||
|
actions = actionLow;
|
||||||
actions = NoCheatConfiguration.movingActionMinor;
|
|
||||||
|
|
||||||
// React only after the freebee illegal moves have all been used
|
|
||||||
if(data.movingMinorViolationsInARow <= NoCheatConfiguration.movingFreeMoves) {
|
|
||||||
vl = null;
|
|
||||||
actions = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(data.movingMinorViolationsInARow > NoCheatConfiguration.movingFreeMoves+1) {
|
|
||||||
log = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// after a set number of minor violations a normal violation gets thrown
|
// after a set number of minor violations a normal violation gets thrown
|
||||||
if(data.movingMinorViolationsInARow % 40 == 0) {
|
if(data.movingMinorViolationsInARow % 40 == 0) {
|
||||||
@ -370,31 +369,46 @@ public class MovingCheck {
|
|||||||
if(Level.WARNING.equals(vl)) {
|
if(Level.WARNING.equals(vl)) {
|
||||||
if(data.movingNormalViolationsInARow > 0) log = false;
|
if(data.movingNormalViolationsInARow > 0) log = false;
|
||||||
data.movingNormalViolationsInARow++;
|
data.movingNormalViolationsInARow++;
|
||||||
actions = NoCheatConfiguration.movingActionNormal;
|
actions = actionMed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Level.SEVERE.equals(vl)) {
|
if(Level.SEVERE.equals(vl)) {
|
||||||
if(data.movingHeavyViolationsInARow > 0) log = false;
|
if(data.movingHeavyViolationsInARow > 0) log = false;
|
||||||
data.movingHeavyViolationsInARow++;
|
data.movingHeavyViolationsInARow++;
|
||||||
actions = NoCheatConfiguration.movingActionHeavy;
|
actions = actionHigh;
|
||||||
}
|
}
|
||||||
|
|
||||||
action(event, actions, log);
|
action(event, actions, log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void teleported(PlayerMoveEvent event) {
|
||||||
|
NoCheatData data = plugin.getPlayerData(event.getPlayer());
|
||||||
|
|
||||||
|
if(data.reset) { // My plugin requested this teleport, so we don't do anything
|
||||||
|
data.reset = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
// If it wasn't our plugin that ordered the teleport, forget all our information and start from scratch at the new location
|
||||||
|
data.speedhackSetBackPoint = event.getTo().clone();
|
||||||
|
data.movingSetBackPoint = event.getTo().clone();
|
||||||
|
data.movingJumpPhase = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform actions that were specified by the admin
|
* Perform actions that were specified by the admin
|
||||||
* @param event
|
* @param event
|
||||||
* @param actions
|
* @param actions
|
||||||
*/
|
*/
|
||||||
private static void action(PlayerMoveEvent event, String actions, boolean log) {
|
private void action(PlayerMoveEvent event, String actions, boolean log) {
|
||||||
|
|
||||||
if(actions == null) return;
|
if(actions == null) return;
|
||||||
// LOGGING IF NEEDED
|
// LOGGING IF NEEDED
|
||||||
if(log && actions.contains("log")) {
|
if(log && actions.contains("log")) {
|
||||||
NoCheatPlugin.logAction(actions, "Moving violation: "+event.getPlayer().getName()+" from " + String.format("%s (%.5f, %.5f, %.5f) to %s (%.5f, %.5f, %.5f)", event.getFrom().getWorld().getName(), event.getFrom().getX(), event.getFrom().getY(), event.getFrom().getZ(), event.getTo().getWorld().getName(), event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()));
|
plugin.logAction(actions, "Moving violation: "+event.getPlayer().getName()+" from " + String.format("%s (%.5f, %.5f, %.5f) to %s (%.5f, %.5f, %.5f)", event.getFrom().getWorld().getName(), event.getFrom().getX(), event.getFrom().getY(), event.getFrom().getZ(), event.getTo().getWorld().getName(), event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// RESET IF NEEDED
|
// RESET IF NEEDED
|
||||||
@ -405,7 +419,7 @@ public class MovingCheck {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected static void legitimateMove(NoCheatData data, PlayerMoveEvent event) {
|
protected void legitimateMove(NoCheatData data, PlayerMoveEvent event) {
|
||||||
|
|
||||||
// Give some logging about violations if the player hasn't done any for at least two seconds
|
// Give some logging about violations if the player hasn't done any for at least two seconds
|
||||||
if(data.movingLastViolationTime != 0 && data.movingLastViolationTime + 2000L < System.currentTimeMillis()) {
|
if(data.movingLastViolationTime != 0 && data.movingLastViolationTime + 2000L < System.currentTimeMillis()) {
|
||||||
@ -414,15 +428,15 @@ public class MovingCheck {
|
|||||||
|
|
||||||
// Give some additional logs about now ending violations
|
// Give some additional logs about now ending violations
|
||||||
if(data.movingHeavyViolationsInARow > 0) {
|
if(data.movingHeavyViolationsInARow > 0) {
|
||||||
NoCheatPlugin.logAction(NoCheatConfiguration.movingActionHeavy, "Moving violation ended: "+event.getPlayer().getName() + " total Events: "+ data.movingHeavyViolationsInARow);
|
plugin.logAction(actionHigh, "Moving violation ended: "+event.getPlayer().getName() + " total Events: "+ data.movingHeavyViolationsInARow);
|
||||||
data.movingHeavyViolationsInARow = 0;
|
data.movingHeavyViolationsInARow = 0;
|
||||||
}
|
}
|
||||||
if(data.movingNormalViolationsInARow > 0) {
|
if(data.movingNormalViolationsInARow > 0) {
|
||||||
NoCheatPlugin.logAction(NoCheatConfiguration.movingActionNormal, "Moving violation ended: "+event.getPlayer().getName()+ " total Events: "+ data.movingNormalViolationsInARow);
|
plugin.logAction(actionMed, "Moving violation ended: "+event.getPlayer().getName()+ " total Events: "+ data.movingNormalViolationsInARow);
|
||||||
data.movingNormalViolationsInARow = 0;
|
data.movingNormalViolationsInARow = 0;
|
||||||
}
|
}
|
||||||
if(data.movingMinorViolationsInARow > NoCheatConfiguration.movingFreeMoves) {
|
if(data.movingMinorViolationsInARow > 0) {
|
||||||
NoCheatPlugin.logAction(NoCheatConfiguration.movingActionMinor, "Moving violation ended: "+event.getPlayer().getName()+ " total Events: "+ data.movingMinorViolationsInARow);
|
plugin.logAction(actionLow, "Moving violation ended: "+event.getPlayer().getName()+ " total Events: "+ data.movingMinorViolationsInARow);
|
||||||
data.movingMinorViolationsInARow = 0;
|
data.movingMinorViolationsInARow = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,9 +456,9 @@ public class MovingCheck {
|
|||||||
* @param data
|
* @param data
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
private static void resetPlayer(PlayerMoveEvent event) {
|
private void resetPlayer(PlayerMoveEvent event) {
|
||||||
|
|
||||||
NoCheatData data = NoCheatPlugin.getPlayerData(event.getPlayer());
|
NoCheatData data = plugin.getPlayerData(event.getPlayer());
|
||||||
|
|
||||||
// Reset the jumpphase. We choose the setback-point such that it should be
|
// Reset the jumpphase. We choose the setback-point such that it should be
|
||||||
// on solid ground, but in case it isn't (maybe the ground is gone now) we
|
// on solid ground, but in case it isn't (maybe the ground is gone now) we
|
||||||
@ -533,14 +547,7 @@ public class MovingCheck {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int lowerBorder(double d1) {
|
||||||
public static int floor_double(double d)
|
|
||||||
{
|
|
||||||
int i = (int)d;
|
|
||||||
return d > (double)i ? i : i - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int lowerBorder(double d1) {
|
|
||||||
double floor = Math.floor(d1);
|
double floor = Math.floor(d1);
|
||||||
double d4 = floor + magic;
|
double d4 = floor + magic;
|
||||||
|
|
||||||
@ -552,7 +559,7 @@ public class MovingCheck {
|
|||||||
return (int) (floor - d4);
|
return (int) (floor - d4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int upperBorder(double d1) {
|
private static int upperBorder(double d1) {
|
||||||
double floor = Math.floor(d1);
|
double floor = Math.floor(d1);
|
||||||
double d4 = floor + magic2;
|
double d4 = floor + magic2;
|
||||||
|
|
||||||
@ -563,4 +570,9 @@ public class MovingCheck {
|
|||||||
|
|
||||||
return (int) (floor - d4);
|
return (int) (floor - d4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "moving";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package cc.co.evenprime.bukkit.nocheat.checks;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatConfiguration;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatData;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatData;
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||||
|
|
||||||
@ -13,20 +12,34 @@ import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
|||||||
* @author Evenprime
|
* @author Evenprime
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SpeedhackCheck {
|
public class SpeedhackCheck extends Check {
|
||||||
|
|
||||||
|
public SpeedhackCheck(NoCheatPlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
setActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
private static final long interval = 1000;
|
private static final long interval = 1000;
|
||||||
private static final int violationsLimit = 3;
|
private static final int violationsLimit = 3;
|
||||||
|
|
||||||
public static void check(PlayerMoveEvent event) {
|
// Limits for the speedhack check
|
||||||
|
public int limitLow = 30;
|
||||||
|
public int limitMed = 45;
|
||||||
|
public int limitHigh = 60;
|
||||||
|
|
||||||
|
// How should speedhack violations be treated?
|
||||||
|
public String actionLow = "loglow reset";
|
||||||
|
public String actionMed = "logmed reset";
|
||||||
|
public String actionHigh = "loghigh reset";
|
||||||
|
|
||||||
|
public void check(PlayerMoveEvent event) {
|
||||||
|
|
||||||
// Should we check at all?
|
// Should we check at all?
|
||||||
if(NoCheatPlugin.hasPermission(event.getPlayer(), "nocheat.speedhack"))
|
if(plugin.hasPermission(event.getPlayer(), "nocheat.speedhack"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the player-specific data
|
// Get the player-specific data
|
||||||
NoCheatData data = NoCheatPlugin.getPlayerData(event.getPlayer());
|
NoCheatData data = plugin.getPlayerData(event.getPlayer());
|
||||||
|
|
||||||
// Get the time of the server
|
// Get the time of the server
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
@ -37,14 +50,14 @@ public class SpeedhackCheck {
|
|||||||
// TODO: Needs some better handling for server lag
|
// TODO: Needs some better handling for server lag
|
||||||
String action = null;
|
String action = null;
|
||||||
|
|
||||||
int limitLow = (int)((NoCheatConfiguration.speedhackLimitLow * (time - data.speedhackLastCheck)) / interval);
|
int low = (int)((limitLow * (time - data.speedhackLastCheck)) / interval);
|
||||||
int limitMed = (int)((NoCheatConfiguration.speedhackLimitMed * (time - data.speedhackLastCheck)) / interval);
|
int med = (int)((limitMed * (time - data.speedhackLastCheck)) / interval);
|
||||||
int limitHigh = (int)((NoCheatConfiguration.speedhackLimitHigh * (time - data.speedhackLastCheck)) / interval);
|
int high = (int)((limitHigh * (time - data.speedhackLastCheck)) / interval);
|
||||||
|
|
||||||
|
|
||||||
if(data.speedhackEventsSinceLastCheck > limitHigh) action = NoCheatConfiguration.speedhackActionHeavy;
|
if(data.speedhackEventsSinceLastCheck > high) action = actionLow;
|
||||||
else if(data.speedhackEventsSinceLastCheck > limitMed) action = NoCheatConfiguration.speedhackActionNormal;
|
else if(data.speedhackEventsSinceLastCheck > med) action = actionMed;
|
||||||
else if(data.speedhackEventsSinceLastCheck > limitLow) action = NoCheatConfiguration.speedhackActionMinor;
|
else if(data.speedhackEventsSinceLastCheck > low) action = actionHigh;
|
||||||
|
|
||||||
if(action == null) {
|
if(action == null) {
|
||||||
data.speedhackSetBackPoint = event.getFrom().clone();
|
data.speedhackSetBackPoint = event.getFrom().clone();
|
||||||
@ -71,12 +84,12 @@ public class SpeedhackCheck {
|
|||||||
data.speedhackEventsSinceLastCheck++;
|
data.speedhackEventsSinceLastCheck++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void action(String actions, PlayerMoveEvent event, NoCheatData data) {
|
private void action(String actions, PlayerMoveEvent event, NoCheatData data) {
|
||||||
|
|
||||||
if(actions == null) return;
|
if(actions == null) return;
|
||||||
// LOGGING IF NEEDED
|
// LOGGING IF NEEDED
|
||||||
if(actions.contains("log")) {
|
if(actions.contains("log")) {
|
||||||
NoCheatPlugin.logAction(actions, event.getPlayer().getName()+" sent "+ data.speedhackEventsSinceLastCheck + " move events, but only "+NoCheatConfiguration.speedhackLimitLow+ " were allowed. Speedhack?");
|
plugin.logAction(actions, event.getPlayer().getName()+" sent "+ data.speedhackEventsSinceLastCheck + " move events, but only "+limitLow+ " were allowed. Speedhack?");
|
||||||
}
|
}
|
||||||
// RESET IF NEEDED
|
// RESET IF NEEDED
|
||||||
if(actions.contains("reset")) {
|
if(actions.contains("reset")) {
|
||||||
@ -103,4 +116,9 @@ public class SpeedhackCheck {
|
|||||||
event.getPlayer().teleportTo(event.getFrom());
|
event.getPlayer().teleportTo(event.getFrom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "speedhack";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package cc.co.evenprime.bukkit.nocheat.listeners;
|
|||||||
import org.bukkit.event.block.BlockListener;
|
import org.bukkit.event.block.BlockListener;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatConfiguration;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.checks.AirbuildCheck;
|
import cc.co.evenprime.bukkit.nocheat.checks.AirbuildCheck;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,17 +11,17 @@ import cc.co.evenprime.bukkit.nocheat.checks.AirbuildCheck;
|
|||||||
* @author Evenprime
|
* @author Evenprime
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class NoCheatBlockListener extends BlockListener {
|
public class AirbuildListener extends BlockListener {
|
||||||
|
|
||||||
|
|
||||||
public NoCheatBlockListener() {
|
|
||||||
|
|
||||||
|
private AirbuildCheck check;
|
||||||
|
public AirbuildListener(AirbuildCheck check) {
|
||||||
|
this.check = check;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
|
||||||
if(!event.isCancelled() && NoCheatConfiguration.airbuildCheckActive)
|
if(!event.isCancelled() && check.isActive())
|
||||||
AirbuildCheck.check(event);
|
check.check(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package cc.co.evenprime.bukkit.nocheat.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.checks.BedteleportCheck;
|
||||||
|
|
||||||
|
public class BedteleportListener extends PlayerListener {
|
||||||
|
|
||||||
|
private BedteleportCheck check;
|
||||||
|
|
||||||
|
public BedteleportListener(BedteleportCheck check) {
|
||||||
|
this.check = check;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTeleport(PlayerMoveEvent event) {
|
||||||
|
|
||||||
|
if(!event.isCancelled() && check.isActive()) {
|
||||||
|
check.check(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cc.co.evenprime.bukkit.nocheat.listeners;
|
||||||
|
|
||||||
|
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.checks.MovingCheck;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle events for all Player related events
|
||||||
|
*
|
||||||
|
* @author Evenprime
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MovingListener extends PlayerListener {
|
||||||
|
|
||||||
|
private MovingCheck check;
|
||||||
|
|
||||||
|
public MovingListener(MovingCheck check) {
|
||||||
|
this.check = check;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
|
|
||||||
|
if(!event.isCancelled() && check.isActive())
|
||||||
|
check.check(event);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package cc.co.evenprime.bukkit.nocheat.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.checks.MovingCheck;
|
||||||
|
|
||||||
|
public class MovingMonitor extends PlayerListener {
|
||||||
|
|
||||||
|
private MovingCheck check;
|
||||||
|
|
||||||
|
public MovingMonitor(MovingCheck check) {
|
||||||
|
this.check = check;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTeleport(PlayerMoveEvent event) {
|
||||||
|
|
||||||
|
check.teleported(event);
|
||||||
|
}
|
||||||
|
}
|
@ -1,49 +0,0 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.listeners;
|
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
|
||||||
import org.bukkit.event.player.PlayerListener;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatConfiguration;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.checks.BedteleportCheck;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.checks.MovingCheck;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.checks.SpeedhackCheck;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle events for all Player related events
|
|
||||||
*
|
|
||||||
* @author Evenprime
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class NoCheatPlayerListener extends PlayerListener {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public NoCheatPlayerListener() { }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerQuit(PlayerEvent event) {
|
|
||||||
NoCheatPlugin.playerData.remove(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
|
||||||
|
|
||||||
|
|
||||||
if(!event.isCancelled() && NoCheatConfiguration.speedhackCheckActive)
|
|
||||||
SpeedhackCheck.check(event);
|
|
||||||
|
|
||||||
if(!event.isCancelled() && NoCheatConfiguration.movingCheckActive)
|
|
||||||
MovingCheck.check(event);
|
|
||||||
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPlayerTeleport(PlayerMoveEvent event) {
|
|
||||||
|
|
||||||
if(!event.isCancelled() && NoCheatConfiguration.bedteleportCheckActive) {
|
|
||||||
BedteleportCheck.check(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.event.player.PlayerListener;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatData;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
|
||||||
|
|
||||||
public class NoCheatPlayerListenerMonitor extends PlayerListener {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerTeleport(PlayerMoveEvent event) {
|
|
||||||
|
|
||||||
NoCheatData data = NoCheatPlugin.getPlayerData(event.getPlayer());
|
|
||||||
|
|
||||||
if(data.reset) { // My plugin requested this teleport, so we don't do anything
|
|
||||||
data.reset = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(!event.isCancelled()) {
|
|
||||||
// If it wasn't our plugin that ordered the teleport, forget all our information and start from scratch at the new location
|
|
||||||
data.speedhackSetBackPoint = event.getTo().clone();
|
|
||||||
data.movingSetBackPoint = event.getTo().clone();
|
|
||||||
data.movingJumpPhase = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,22 @@
|
|||||||
|
package cc.co.evenprime.bukkit.nocheat.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.checks.SpeedhackCheck;
|
||||||
|
|
||||||
|
public class SpeedhackListener extends PlayerListener {
|
||||||
|
|
||||||
|
private SpeedhackCheck check;
|
||||||
|
|
||||||
|
public SpeedhackListener(SpeedhackCheck check) {
|
||||||
|
this.check = check;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
|
|
||||||
|
if(!event.isCancelled() && check.isActive())
|
||||||
|
check.check(event);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user