mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-29 20:07:58 +01:00
Renamed to NoCheat + configurable moving check messages
This commit is contained in:
parent
18a46a996c
commit
f8eff5ee25
@ -1,13 +1,13 @@
|
||||
name: NoCheatPlugin
|
||||
name: NoCheat
|
||||
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheatPlugin
|
||||
version: 0.7.8
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||
version: 0.7.8a
|
||||
|
||||
commands:
|
||||
nocheat:
|
||||
description: Provides information about the current status of the NoCheatPlugin
|
||||
description: Provides information about the current status of the NoCheat plugin
|
||||
usage: |
|
||||
/<command>
|
||||
Example: /<command> | Displays version, enabled checks and bugfixes
|
||||
|
@ -32,13 +32,13 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* NoCheatPlugin
|
||||
* NoCheat
|
||||
*
|
||||
* Check various player events for their plausibility and log/deny them based on configuration
|
||||
*
|
||||
* @author Evenprime
|
||||
*/
|
||||
public class NoCheatPlugin extends JavaPlugin {
|
||||
public class NoCheat extends JavaPlugin {
|
||||
|
||||
public final MovingCheck movingCheck;
|
||||
public final BedteleportCheck bedteleportCheck;
|
||||
@ -56,7 +56,7 @@ public class NoCheatPlugin extends JavaPlugin {
|
||||
// Store data between Events
|
||||
private final Map<Player, NoCheatData> playerData = new HashMap<Player, NoCheatData>();
|
||||
|
||||
public NoCheatPlugin() {
|
||||
public NoCheat() {
|
||||
movingCheck = new MovingCheck(this);
|
||||
bedteleportCheck = new BedteleportCheck(this);
|
||||
speedhackCheck = new SpeedhackCheck(this);
|
||||
@ -154,7 +154,7 @@ public class NoCheatPlugin extends JavaPlugin {
|
||||
public void onDisable() {
|
||||
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
Logger.getLogger("Minecraft").info( "[NoCheatPlugin] version [" + pdfFile.getVersion() + "] is disabled.");
|
||||
Logger.getLogger("Minecraft").info( "[NoCheat] version [" + pdfFile.getVersion() + "] is disabled.");
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
@ -186,7 +186,7 @@ public class NoCheatPlugin extends JavaPlugin {
|
||||
setupPermissions();
|
||||
setupIRC();
|
||||
|
||||
Logger.getLogger("Minecraft").info( "[NoCheatPlugin] version [" + pdfFile.getVersion() + "] is enabled with the following checks: "+getActiveChecksAsString());
|
||||
Logger.getLogger("Minecraft").info( "[NoCheat] version [" + pdfFile.getVersion() + "] is enabled with the following checks: "+getActiveChecksAsString());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,7 +207,7 @@ public class NoCheatPlugin extends JavaPlugin {
|
||||
|
||||
if(p == null) {
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
Logger.getLogger("Minecraft").warning("[NoCheatPlugin] version [" + pdfFile.getVersion() + "] couldn't find Permissions plugin. Fallback to 'isOp()' equals 'nocheat.*'");
|
||||
Logger.getLogger("Minecraft").warning("[NoCheat] version [" + pdfFile.getVersion() + "] couldn't find Permissions plugin. Fallback to 'isOp()' equals 'nocheat.*'");
|
||||
}
|
||||
|
||||
permissions = p;
|
||||
@ -227,7 +227,7 @@ public class NoCheatPlugin extends JavaPlugin {
|
||||
|
||||
if(p == null) {
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
Logger.getLogger("Minecraft").warning("[NoCheatPlugin] version [" + pdfFile.getVersion() + "] couldn't find CrafTIRC plugin. Disabling logging to IRC.");
|
||||
Logger.getLogger("Minecraft").warning("[NoCheat] version [" + pdfFile.getVersion() + "] couldn't find CrafTIRC plugin. Disabling logging to IRC.");
|
||||
}
|
||||
|
||||
irc = p;
|
@ -44,9 +44,9 @@ public class NoCheatConfiguration {
|
||||
// Our log output to a file
|
||||
private FileHandler fh = null;
|
||||
|
||||
private final NoCheatPlugin plugin;
|
||||
private final NoCheat plugin;
|
||||
|
||||
public NoCheatConfiguration(NoCheatPlugin plugin) {
|
||||
public NoCheatConfiguration(NoCheat plugin) {
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
@ -98,6 +98,10 @@ public class NoCheatConfiguration {
|
||||
plugin.movingCheck.actions[1] = stringToActions(c.getString("moving.action.med"), plugin.movingCheck.actions[1]);
|
||||
plugin.movingCheck.actions[2] = stringToActions(c.getString("moving.action.high"), plugin.movingCheck.actions[2]);
|
||||
|
||||
|
||||
plugin.movingCheck.logMessage = c.getString("moving.logmessage", plugin.movingCheck.logMessage);
|
||||
plugin.movingCheck.summaryMessage = c.getString("moving.summarymessage", plugin.movingCheck.summaryMessage);
|
||||
|
||||
plugin.speedhackCheck.actions[0] = stringToActions(c.getString("speedhack.action.low"), plugin.speedhackCheck.actions[0]);
|
||||
plugin.speedhackCheck.actions[1] = stringToActions(c.getString("speedhack.action.med"), plugin.speedhackCheck.actions[1]);
|
||||
plugin.speedhackCheck.actions[2] = stringToActions(c.getString("speedhack.action.high"), plugin.speedhackCheck.actions[2]);
|
||||
@ -227,26 +231,28 @@ public class NoCheatConfiguration {
|
||||
w.write(" low: "+plugin.speedhackCheck.limits[0]); w.newLine();
|
||||
w.write(" med: "+plugin.speedhackCheck.limits[1]); w.newLine();
|
||||
w.write(" high: "+plugin.speedhackCheck.limits[2]); 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 cancel'"); w.newLine();
|
||||
w.write(" action:"); w.newLine();
|
||||
w.write(" low: "+actionsToString(plugin.speedhackCheck.actions[0])); w.newLine();
|
||||
w.write(" med: "+actionsToString(plugin.speedhackCheck.actions[1])); w.newLine();
|
||||
w.write(" high: "+actionsToString(plugin.speedhackCheck.actions[2])); w.newLine();
|
||||
w.write("# Moving specific options") ; w.newLine();
|
||||
w.write("moving:"); w.newLine();
|
||||
w.write("# Moving Action, one or more of 'loglow logmed loghigh reset'"); w.newLine();
|
||||
w.write(" logmessage: \"" + plugin.movingCheck.logMessage+"\""); w.newLine();
|
||||
w.write(" summarymessage: \"" + plugin.movingCheck.summaryMessage+"\""); w.newLine();
|
||||
w.write("# Moving Action, one or more of 'loglow logmed loghigh cancel'"); w.newLine();
|
||||
w.write(" action:"); w.newLine();
|
||||
w.write(" low: "+actionsToString(plugin.movingCheck.actions[0])); w.newLine();
|
||||
w.write(" med: "+actionsToString(plugin.movingCheck.actions[1])); w.newLine();
|
||||
w.write(" high: "+actionsToString(plugin.movingCheck.actions[2])); w.newLine();
|
||||
w.write("# Airbuild specific options"); 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 to trigger corresponding action"); w.newLine();
|
||||
w.write(" limits:"); w.newLine();
|
||||
w.write(" low: "+plugin.airbuildCheck.limits[0]); w.newLine();
|
||||
w.write(" med: "+plugin.airbuildCheck.limits[1]); w.newLine();
|
||||
w.write(" high: "+plugin.airbuildCheck.limits[2]); 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 cancel'"); w.newLine();
|
||||
w.write(" action:"); w.newLine();
|
||||
w.write(" low: "+actionsToString(plugin.airbuildCheck.actions[0])); w.newLine();
|
||||
w.write(" med: "+actionsToString(plugin.airbuildCheck.actions[1])); w.newLine();
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatData;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.CancelAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.CustomAction;
|
||||
@ -29,7 +29,7 @@ public class AirbuildCheck extends Check {
|
||||
|
||||
public final int limits[] = { 1, 3, 10 };
|
||||
|
||||
public AirbuildCheck(NoCheatPlugin plugin) {
|
||||
public AirbuildCheck(NoCheat plugin) {
|
||||
super(plugin);
|
||||
setActive(false);
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ package cc.co.evenprime.bukkit.nocheat.checks;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
|
||||
public class BedteleportCheck extends Check {
|
||||
|
||||
public BedteleportCheck(NoCheatPlugin plugin) {
|
||||
public BedteleportCheck(NoCheat plugin) {
|
||||
super(plugin);
|
||||
setActive(true);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.checks;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -9,12 +9,12 @@ import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||
*/
|
||||
public abstract class Check {
|
||||
|
||||
public Check(NoCheatPlugin plugin) {
|
||||
public Check(NoCheat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private boolean active = true;
|
||||
protected NoCheatPlugin plugin;
|
||||
protected NoCheat plugin;
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatData;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.CancelAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.CustomAction;
|
||||
@ -25,7 +25,7 @@ import cc.co.evenprime.bukkit.nocheat.actions.LogAction;
|
||||
*/
|
||||
public class MovingCheck extends Check {
|
||||
|
||||
public MovingCheck(NoCheatPlugin plugin) {
|
||||
public MovingCheck(NoCheat plugin) {
|
||||
super(plugin);
|
||||
setActive(true);
|
||||
}
|
||||
@ -42,7 +42,7 @@ public class MovingCheck extends Check {
|
||||
// Limits
|
||||
public final double moveLimits[] = { 0.0D, 0.5D, 2.0D };
|
||||
public final double heightLimits[] = { 0.0D, 0.5D, 2.0D };
|
||||
|
||||
|
||||
public int ticksBeforeSummary = 100;
|
||||
|
||||
// How should moving violations be treated?
|
||||
@ -50,6 +50,9 @@ public class MovingCheck extends Check {
|
||||
{ LogAction.loglow, CancelAction.cancel },
|
||||
{ LogAction.logmed, CancelAction.cancel },
|
||||
{ LogAction.loghigh, CancelAction.cancel } };
|
||||
|
||||
public String logMessage = "Moving violation: %1$s from %2$s (%4$.5f, %5$.5f, %6$.5f) to %3$s (%7$.5f, %8$.5f, %9$.5f)";
|
||||
public String summaryMessage = "Moving summary of last ~%2$d seconds: %1$s total Violations: (%3$d,%4$d,%5$d)";
|
||||
|
||||
private static final double magic = 0.30000001192092896D;
|
||||
private static final double magic2 = 0.69999998807907103D;
|
||||
@ -324,7 +327,7 @@ public class MovingCheck extends Check {
|
||||
@Override
|
||||
public void run() {
|
||||
if(data.movingHighestLogLevel != null) {
|
||||
String logString = "Moving summary of last ~" + (ticksBeforeSummary/20) + " seconds: "+p.getName() + " total Violations: ("+ data.movingViolationsInARow[0] + "," + data.movingViolationsInARow[1] + "," + data.movingViolationsInARow[2] + ")";
|
||||
String logString = String.format(summaryMessage, p.getName(), ticksBeforeSummary/20, data.movingViolationsInARow[0], data.movingViolationsInARow[1],data.movingViolationsInARow[2]);
|
||||
plugin.log(data.movingHighestLogLevel, logString);
|
||||
}
|
||||
// deleting its own reference
|
||||
@ -376,15 +379,15 @@ public class MovingCheck extends Check {
|
||||
boolean cancelled = false;
|
||||
|
||||
// prepare log message if necessary
|
||||
String logMessage = null;
|
||||
String log = null;
|
||||
|
||||
if(loggingAllowed) {
|
||||
logMessage = "Moving violation: "+player.getName()+" from " + String.format("%s (%.5f, %.5f, %.5f) to %s (%.5f, %.5f, %.5f)", from.getWorld().getName(), from.getX(), from.getY(), from.getZ(), to.getWorld().getName(), to.getX(), to.getY(), to.getZ());
|
||||
log = String.format(logMessage, player.getName(), from.getWorld().getName(), to.getWorld().getName(), from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ());
|
||||
}
|
||||
|
||||
for(Action a : actions) {
|
||||
if(loggingAllowed && a instanceof LogAction) {
|
||||
plugin.log(((LogAction)a).level, logMessage);
|
||||
plugin.log(((LogAction)a).level, log);
|
||||
if(data.movingHighestLogLevel == null) data.movingHighestLogLevel = Level.ALL;
|
||||
if(data.movingHighestLogLevel.intValue() < ((LogAction)a).level.intValue()) data.movingHighestLogLevel = ((LogAction)a).level;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatData;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.CancelAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.CustomAction;
|
||||
@ -18,7 +18,7 @@ import cc.co.evenprime.bukkit.nocheat.actions.LogAction;
|
||||
*/
|
||||
public class SpeedhackCheck extends Check {
|
||||
|
||||
public SpeedhackCheck(NoCheatPlugin plugin) {
|
||||
public SpeedhackCheck(NoCheat plugin) {
|
||||
super(plugin);
|
||||
setActive(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user