mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-06 20:18:00 +02:00
Another round of code cleaning, simplification
Fixed nocheat reload command to give feedback and clear critical data Remove stored data when a player disconnects
This commit is contained in:
parent
4309c70a39
commit
747e5bcdce
@ -3,7 +3,7 @@ name: NoCheat
|
|||||||
author: Evenprime
|
author: Evenprime
|
||||||
|
|
||||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||||
version: 2.09
|
version: 2.09a
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
nocheat:
|
nocheat:
|
||||||
|
@ -21,6 +21,7 @@ import cc.co.evenprime.bukkit.nocheat.events.BlockPlaceEventManager;
|
|||||||
import cc.co.evenprime.bukkit.nocheat.events.BlockBreakEventManager;
|
import cc.co.evenprime.bukkit.nocheat.events.BlockBreakEventManager;
|
||||||
import cc.co.evenprime.bukkit.nocheat.events.EventManager;
|
import cc.co.evenprime.bukkit.nocheat.events.EventManager;
|
||||||
import cc.co.evenprime.bukkit.nocheat.events.PlayerChatEventManager;
|
import cc.co.evenprime.bukkit.nocheat.events.PlayerChatEventManager;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.events.PlayerQuitEventManager;
|
||||||
import cc.co.evenprime.bukkit.nocheat.events.PlayerMoveEventManager;
|
import cc.co.evenprime.bukkit.nocheat.events.PlayerMoveEventManager;
|
||||||
import cc.co.evenprime.bukkit.nocheat.events.PlayerTeleportEventManager;
|
import cc.co.evenprime.bukkit.nocheat.events.PlayerTeleportEventManager;
|
||||||
import cc.co.evenprime.bukkit.nocheat.log.LogLevel;
|
import cc.co.evenprime.bukkit.nocheat.log.LogLevel;
|
||||||
@ -37,17 +38,17 @@ import cc.co.evenprime.bukkit.nocheat.log.LogManager;
|
|||||||
*/
|
*/
|
||||||
public class NoCheat extends JavaPlugin {
|
public class NoCheat extends JavaPlugin {
|
||||||
|
|
||||||
private ConfigurationManager conf;
|
private ConfigurationManager conf;
|
||||||
private LogManager log;
|
private LogManager log;
|
||||||
private DataManager data;
|
private DataManager data;
|
||||||
|
|
||||||
private List<EventManager> eventManagers = new LinkedList<EventManager>();
|
private final List<EventManager> eventManagers = new LinkedList<EventManager>();
|
||||||
|
|
||||||
private int taskId = -1;
|
private int taskId = -1;
|
||||||
private int ingameseconds = 0;
|
private int ingameseconds = 0;
|
||||||
private long lastIngamesecondTime = 0L;
|
private long lastIngamesecondTime = 0L;
|
||||||
private long lastIngamesecondDuration = 0L;
|
private long lastIngamesecondDuration = 0L;
|
||||||
private boolean skipCheck = false;
|
private boolean skipCheck = false;
|
||||||
|
|
||||||
public NoCheat() {
|
public NoCheat() {
|
||||||
|
|
||||||
@ -84,13 +85,13 @@ public class NoCheat extends JavaPlugin {
|
|||||||
eventManagers.add(new PlayerChatEventManager(this));
|
eventManagers.add(new PlayerChatEventManager(this));
|
||||||
eventManagers.add(new BlockBreakEventManager(this));
|
eventManagers.add(new BlockBreakEventManager(this));
|
||||||
eventManagers.add(new BlockPlaceEventManager(this));
|
eventManagers.add(new BlockPlaceEventManager(this));
|
||||||
|
eventManagers.add(new PlayerQuitEventManager(this));
|
||||||
|
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
PluginDescriptionFile pdfFile = this.getDescription();
|
||||||
|
|
||||||
if(taskId == -1) {
|
if(taskId == -1) {
|
||||||
taskId = this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
|
taskId = this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
// If the previous second took to long, skip checks during
|
// If the previous second took to long, skip checks during
|
||||||
@ -224,9 +225,8 @@ public class NoCheat extends JavaPlugin {
|
|||||||
sender.sendMessage("[NoCheat] Reloading configuration");
|
sender.sendMessage("[NoCheat] Reloading configuration");
|
||||||
|
|
||||||
this.conf.cleanup();
|
this.conf.cleanup();
|
||||||
DataManager newData = new DataManager();
|
|
||||||
this.conf = new ConfigurationManager(this.getDataFolder().getPath());
|
this.conf = new ConfigurationManager(this.getDataFolder().getPath());
|
||||||
this.data = newData;
|
this.data.resetAllCriticalData();
|
||||||
|
|
||||||
sender.sendMessage("[NoCheat] Configuration loaded");
|
sender.sendMessage("[NoCheat] Configuration loaded");
|
||||||
|
|
||||||
|
@ -22,16 +22,11 @@ public class ActionManager {
|
|||||||
this.actions.put(action.name.toLowerCase(), action);
|
this.actions.put(action.name.toLowerCase(), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action getAction(String actionName) {
|
|
||||||
|
|
||||||
return this.actions.get(actionName.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action[] getActions(String[] actionNames) {
|
public Action[] getActions(String[] actionNames) {
|
||||||
Action[] result = new Action[actionNames.length];
|
Action[] result = new Action[actionNames.length];
|
||||||
|
|
||||||
for(int i = 0; i < actionNames.length; i++) {
|
for(int i = 0; i < actionNames.length; i++) {
|
||||||
result[i] = getAction(actionNames[i]);
|
result[i] = this.actions.get(actionNames[i].toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -96,10 +96,10 @@ public class ConsoleCommandSender implements CommandSender {
|
|||||||
server.dispatchCommand(this, command);
|
server.dispatchCommand(this, command);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
// TODO: Better error handling
|
// TODO: Better error handling
|
||||||
|
System.out.println("[NoCheat] failed to execute the command '"+command + "', please check if everything is setup correct.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "NoCheat";
|
return "NoCheat";
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,14 @@ public class ActionHistory {
|
|||||||
private int totalEntries = 0;
|
private int totalEntries = 0;
|
||||||
private long lastClearedTime = 0;
|
private long lastClearedTime = 0;
|
||||||
|
|
||||||
public ExecutionHistoryEntry(int monitoredTimeFrame) {
|
private ExecutionHistoryEntry(int monitoredTimeFrame) {
|
||||||
this.executionTimes = new int[monitoredTimeFrame];
|
this.executionTimes = new int[monitoredTimeFrame];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remember an execution at the specific time
|
* Remember an execution at the specific time
|
||||||
*/
|
*/
|
||||||
public void addCounter(long time) {
|
private void addCounter(long time) {
|
||||||
// clear out now outdated values from the array
|
// clear out now outdated values from the array
|
||||||
if(time - lastClearedTime > 0) {
|
if(time - lastClearedTime > 0) {
|
||||||
// Clear the next few fields of the array
|
// Clear the next few fields of the array
|
||||||
|
@ -10,27 +10,27 @@ import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
|||||||
|
|
||||||
public abstract class ActionWithParameters extends Action {
|
public abstract class ActionWithParameters extends Action {
|
||||||
|
|
||||||
protected enum WildCard {
|
private enum WildCard {
|
||||||
PLAYER("player"), LOCATION("location"), WORLD("world"), VIOLATIONS("violations"), MOVEDISTANCE("movedistance"), REACHDISTANCE("reachdistance"), FALLDISTANCE("falldistance"), LOCATION_TO("locationto"), CHECK("check"), PACKETS("packets"), TEXT("text"), PLACE_LOCATION("placelocation"), PLACE_AGAINST("placeagainst"), BLOCK_TYPE("blocktype");
|
PLAYER("player"), LOCATION("location"), WORLD("world"), VIOLATIONS("violations"), MOVEDISTANCE("movedistance"), REACHDISTANCE("reachdistance"), FALLDISTANCE("falldistance"), LOCATION_TO("locationto"), CHECK("check"), PACKETS("packets"), TEXT("text"), PLACE_LOCATION("placelocation"), PLACE_AGAINST("placeagainst"), BLOCK_TYPE("blocktype");
|
||||||
|
|
||||||
private final String s;
|
private final String s;
|
||||||
|
|
||||||
private WildCard(String s) {
|
private WildCard(String s) {
|
||||||
this.s = s;
|
this.s = s;
|
||||||
}
|
|
||||||
|
|
||||||
private static final WildCard get(String s) {
|
|
||||||
for(WildCard c : WildCard.values()) {
|
|
||||||
if(c.s.equals(s)) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final ArrayList<Object> messageParts;
|
private static final WildCard get(String s) {
|
||||||
|
for(WildCard c : WildCard.values()) {
|
||||||
|
if(c.s.equals(s)) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final ArrayList<Object> messageParts;
|
||||||
|
|
||||||
public ActionWithParameters(String name, int delay, int repeat, String message) {
|
public ActionWithParameters(String name, int delay, int repeat, String message) {
|
||||||
super(name, delay, repeat);
|
super(name, delay, repeat);
|
||||||
@ -40,7 +40,7 @@ public abstract class ActionWithParameters extends Action {
|
|||||||
parseMessage(message);
|
parseMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void parseMessage(String message) {
|
private void parseMessage(String message) {
|
||||||
String parts[] = message.split("\\[", 2);
|
String parts[] = message.split("\\[", 2);
|
||||||
|
|
||||||
// No opening braces left
|
// No opening braces left
|
||||||
@ -112,7 +112,7 @@ public abstract class ActionWithParameters extends Action {
|
|||||||
return data.player.getWorld().getName();
|
return data.player.getWorld().getName();
|
||||||
|
|
||||||
case VIOLATIONS:
|
case VIOLATIONS:
|
||||||
return String.format(Locale.US, "%.2f", data.violationLevel);
|
return String.format(Locale.US, "%d", data.violationLevel);
|
||||||
|
|
||||||
case MOVEDISTANCE:
|
case MOVEDISTANCE:
|
||||||
Location l2 = data.player.getLocation();
|
Location l2 = data.player.getLocation();
|
||||||
@ -154,7 +154,11 @@ public abstract class ActionWithParameters extends Action {
|
|||||||
return String.format(Locale.US, "%d %d %d", blocka.getX(), blocka.getY(), blocka.getZ());
|
return String.format(Locale.US, "%d %d %d", blocka.getX(), blocka.getY(), blocka.getZ());
|
||||||
|
|
||||||
case BLOCK_TYPE:
|
case BLOCK_TYPE:
|
||||||
return data.placedMaterial.toString();
|
Block blockb = data.placed;
|
||||||
|
if(blockb == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return blockb.getType().toString();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "Evenprime was lazy and forgot to define " + wildcard + ".";
|
return "Evenprime was lazy and forgot to define " + wildcard + ".";
|
||||||
|
@ -50,7 +50,7 @@ public class DirectionCheck {
|
|||||||
data.directionViolationLevel += 1;
|
data.directionViolationLevel += 1;
|
||||||
|
|
||||||
// Prepare some event-specific values for logging and custom actions
|
// Prepare some event-specific values for logging and custom actions
|
||||||
LogData ldata = plugin.getDataManager().getLogData(player);
|
LogData ldata = plugin.getDataManager().getData( player).log;
|
||||||
ldata.check = "blockbreak.direction";
|
ldata.check = "blockbreak.direction";
|
||||||
|
|
||||||
cancel = action.executeActions(player, cc.blockbreak.directionActions, (int) data.directionViolationLevel, ldata, cc);
|
cancel = action.executeActions(player, cc.blockbreak.directionActions, (int) data.directionViolationLevel, ldata, cc);
|
||||||
|
@ -37,7 +37,7 @@ public class ReachCheck {
|
|||||||
// Increment violation counter
|
// Increment violation counter
|
||||||
data.reachViolationLevel += 1;
|
data.reachViolationLevel += 1;
|
||||||
|
|
||||||
LogData ldata = plugin.getDataManager().getLogData(player);
|
LogData ldata = plugin.getDataManager().getData(player).log;
|
||||||
|
|
||||||
ldata.check = "blockbreak.reach";
|
ldata.check = "blockbreak.reach";
|
||||||
ldata.reachdistance = distance;
|
ldata.reachdistance = distance;
|
||||||
|
@ -38,7 +38,7 @@ public class OnLiquidCheck {
|
|||||||
// all ok
|
// all ok
|
||||||
} else {
|
} else {
|
||||||
data.onliquidViolationLevel += 1;
|
data.onliquidViolationLevel += 1;
|
||||||
LogData ldata = plugin.getDataManager().getLogData(player);
|
LogData ldata = plugin.getDataManager().getData(player).log;
|
||||||
ldata.check = "blockplace.onliquid";
|
ldata.check = "blockplace.onliquid";
|
||||||
ldata.placed = blockPlaced;
|
ldata.placed = blockPlaced;
|
||||||
ldata.placedAgainst = blockPlacedAgainst;
|
ldata.placedAgainst = blockPlacedAgainst;
|
||||||
@ -51,7 +51,7 @@ public class OnLiquidCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSolid(Block block) {
|
private boolean isSolid(Block block) {
|
||||||
Material m = block.getType();
|
Material m = block.getType();
|
||||||
return !(m == Material.AIR) || (m == Material.WATER) || (m == Material.STATIONARY_WATER) || (m == Material.LAVA) || (m == Material.STATIONARY_LAVA);
|
return !(m == Material.AIR) || (m == Material.WATER) || (m == Material.STATIONARY_WATER) || (m == Material.LAVA) || (m == Material.STATIONARY_LAVA);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class ReachCheck {
|
|||||||
data.reachViolationLevel += 1;
|
data.reachViolationLevel += 1;
|
||||||
|
|
||||||
// Prepare some event-specific values for logging and custom actions
|
// Prepare some event-specific values for logging and custom actions
|
||||||
LogData ldata = plugin.getDataManager().getLogData(player);
|
LogData ldata = plugin.getDataManager().getData(player).log;
|
||||||
ldata.check = "blockplace.reach";
|
ldata.check = "blockplace.reach";
|
||||||
ldata.reachdistance = distance;
|
ldata.reachdistance = distance;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class ChatCheck {
|
|||||||
|
|
||||||
// Prepare some event-specific values for logging and custom
|
// Prepare some event-specific values for logging and custom
|
||||||
// actions
|
// actions
|
||||||
LogData ldata = plugin.getDataManager().getLogData(player);
|
LogData ldata = plugin.getDataManager().getData(player).log;
|
||||||
|
|
||||||
ldata.check = "chat.spam";
|
ldata.check = "chat.spam";
|
||||||
ldata.text = message;
|
ldata.text = message;
|
||||||
|
@ -83,7 +83,7 @@ public class FlyingCheck {
|
|||||||
data.runflyViolationLevel += result;
|
data.runflyViolationLevel += result;
|
||||||
|
|
||||||
// Prepare some event-specific values for logging and custom actions
|
// Prepare some event-specific values for logging and custom actions
|
||||||
LogData ldata = plugin.getDataManager().getLogData(player);
|
LogData ldata = plugin.getDataManager().getData(player).log;
|
||||||
|
|
||||||
ldata.toLocation = to;
|
ldata.toLocation = to;
|
||||||
ldata.check = "flying/toofast";
|
ldata.check = "flying/toofast";
|
||||||
|
@ -25,8 +25,8 @@ public class MorePacketsCheck {
|
|||||||
|
|
||||||
private final ActionExecutor action;
|
private final ActionExecutor action;
|
||||||
|
|
||||||
private final int packetsPerTimeframe = 22;
|
private final static int packetsPerTimeframe = 22;
|
||||||
private final int bufferLimit = 30;
|
private final static int bufferLimit = 30;
|
||||||
private final NoCheat plugin;
|
private final NoCheat plugin;
|
||||||
|
|
||||||
public MorePacketsCheck(NoCheat plugin) {
|
public MorePacketsCheck(NoCheat plugin) {
|
||||||
@ -122,7 +122,7 @@ public class MorePacketsCheck {
|
|||||||
if(!plugin.skipCheck() && packetsAboveLimit > 0) {
|
if(!plugin.skipCheck() && packetsAboveLimit > 0) {
|
||||||
data.morePacketsViolationLevel += packetsAboveLimit;
|
data.morePacketsViolationLevel += packetsAboveLimit;
|
||||||
|
|
||||||
LogData ldata = plugin.getDataManager().getLogData(player);
|
LogData ldata = plugin.getDataManager().getData(player).log;
|
||||||
// Packets above limit
|
// Packets above limit
|
||||||
ldata.packets = data.morePacketsCounter - limit;
|
ldata.packets = data.morePacketsCounter - limit;
|
||||||
ldata.check = "moving/morepackets";
|
ldata.check = "moving/morepackets";
|
||||||
|
@ -15,8 +15,8 @@ import org.bukkit.World;
|
|||||||
*/
|
*/
|
||||||
public class MovingEventHelper {
|
public class MovingEventHelper {
|
||||||
|
|
||||||
private final double magic = 0.45D;
|
private final static double magic = 0.45D;
|
||||||
private final double magic2 = 0.55D;
|
private final static double magic2 = 0.55D;
|
||||||
|
|
||||||
// Block types that may need to be treated specially
|
// Block types that may need to be treated specially
|
||||||
private static final int NONSOLID = 1; // 0x00000001
|
private static final int NONSOLID = 1; // 0x00000001
|
||||||
@ -159,7 +159,7 @@ public class MovingEventHelper {
|
|||||||
return (value & LIQUID) == LIQUID;
|
return (value & LIQUID) == LIQUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isNonSolid(int value) {
|
private final boolean isNonSolid(int value) {
|
||||||
return((value & NONSOLID) == NONSOLID);
|
return((value & NONSOLID) == NONSOLID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class NoFallCheck {
|
|||||||
data.nofallViolationLevel += difference;
|
data.nofallViolationLevel += difference;
|
||||||
|
|
||||||
// Prepare some event-specific values for logging and custom actions
|
// Prepare some event-specific values for logging and custom actions
|
||||||
LogData ldata = plugin.getDataManager().getLogData(player);
|
LogData ldata = plugin.getDataManager().getData(player).log;
|
||||||
ldata.falldistance = data.fallDistance;
|
ldata.falldistance = data.fallDistance;
|
||||||
ldata.check = "moving/nofall";
|
ldata.check = "moving/nofall";
|
||||||
|
|
||||||
|
@ -97,8 +97,6 @@ public class RunFlyCheck {
|
|||||||
* This is a workaround for people placing blocks below them causing false positives
|
* This is a workaround for people placing blocks below them causing false positives
|
||||||
* with the move check(s).
|
* with the move check(s).
|
||||||
*
|
*
|
||||||
* TODO: Check if still needed, maybe this got fixed in 1.8.1
|
|
||||||
*
|
|
||||||
* @param player
|
* @param player
|
||||||
* @param data
|
* @param data
|
||||||
* @param blockPlaced
|
* @param blockPlaced
|
||||||
|
@ -77,7 +77,7 @@ public class RunningCheck {
|
|||||||
data.runflyViolationLevel += result;
|
data.runflyViolationLevel += result;
|
||||||
|
|
||||||
// Prepare some event-specific values for logging and custom actions
|
// Prepare some event-specific values for logging and custom actions
|
||||||
LogData ldata = plugin.getDataManager().getLogData(player);
|
LogData ldata = plugin.getDataManager().getData(player).log;
|
||||||
ldata.toLocation = to;
|
ldata.toLocation = to;
|
||||||
if(resultHoriz > 0 && resultVert > 0)
|
if(resultHoriz > 0 && resultVert > 0)
|
||||||
ldata.check = "runfly/both";
|
ldata.check = "runfly/both";
|
||||||
|
@ -21,21 +21,21 @@ public abstract class Configuration {
|
|||||||
|
|
||||||
public final static OptionNode ROOT = new OptionNode(null, null, DataType.PARENT);
|
public final static OptionNode ROOT = new OptionNode(null, null, DataType.PARENT);
|
||||||
|
|
||||||
public final static OptionNode LOGGING = new OptionNode("logging", ROOT, DataType.PARENT);
|
private final static OptionNode LOGGING = new OptionNode("logging", ROOT, DataType.PARENT);
|
||||||
public final static OptionNode LOGGING_ACTIVE = new OptionNode("active", LOGGING, DataType.BOOLEAN);
|
public final static OptionNode LOGGING_ACTIVE = new OptionNode("active", LOGGING, DataType.BOOLEAN);
|
||||||
public final static OptionNode LOGGING_FILENAME = new OptionNode("filename", LOGGING, DataType.STRING);
|
public final static OptionNode LOGGING_FILENAME = new OptionNode("filename", LOGGING, DataType.STRING);
|
||||||
public final static OptionNode LOGGING_FILELEVEL = new OptionNode("filelevel", LOGGING, DataType.LOGLEVEL);
|
public final static OptionNode LOGGING_FILELEVEL = new OptionNode("filelevel", LOGGING, DataType.LOGLEVEL);
|
||||||
public final static OptionNode LOGGING_CONSOLELEVEL = new OptionNode("consolelevel", LOGGING, DataType.LOGLEVEL);
|
public final static OptionNode LOGGING_CONSOLELEVEL = new OptionNode("consolelevel", LOGGING, DataType.LOGLEVEL);
|
||||||
public final static OptionNode LOGGING_CHATLEVEL = new OptionNode("chatlevel", LOGGING, DataType.LOGLEVEL);
|
public final static OptionNode LOGGING_CHATLEVEL = new OptionNode("chatlevel", LOGGING, DataType.LOGLEVEL);
|
||||||
|
|
||||||
public final static OptionNode DEBUG = new OptionNode("debug", ROOT, DataType.PARENT);
|
private final static OptionNode DEBUG = new OptionNode("debug", ROOT, DataType.PARENT);
|
||||||
public final static OptionNode DEBUG_SHOWACTIVECHECKS = new OptionNode("showactivechecks", DEBUG, DataType.BOOLEAN);
|
public final static OptionNode DEBUG_SHOWACTIVECHECKS = new OptionNode("showactivechecks", DEBUG, DataType.BOOLEAN);
|
||||||
|
|
||||||
public final static OptionNode MOVING = new OptionNode("moving", ROOT, DataType.PARENT);
|
private final static OptionNode MOVING = new OptionNode("moving", ROOT, DataType.PARENT);
|
||||||
public final static OptionNode MOVING_CHECK = new OptionNode("check", MOVING, DataType.BOOLEAN);
|
public final static OptionNode MOVING_CHECK = new OptionNode("check", MOVING, DataType.BOOLEAN);
|
||||||
public final static OptionNode MOVING_IDENTIFYCREATIVEMODE = new OptionNode("identifycreativemode", MOVING, DataType.BOOLEAN);
|
public final static OptionNode MOVING_IDENTIFYCREATIVEMODE = new OptionNode("identifycreativemode", MOVING, DataType.BOOLEAN);
|
||||||
|
|
||||||
public final static OptionNode MOVING_RUNFLY = new OptionNode("runfly", MOVING, DataType.PARENT);
|
private final static OptionNode MOVING_RUNFLY = new OptionNode("runfly", MOVING, DataType.PARENT);
|
||||||
public final static OptionNode MOVING_RUNFLY_CHECK = new OptionNode("check", MOVING_RUNFLY, DataType.BOOLEAN);
|
public final static OptionNode MOVING_RUNFLY_CHECK = new OptionNode("check", MOVING_RUNFLY, DataType.BOOLEAN);
|
||||||
public final static OptionNode MOVING_RUNFLY_WALKINGSPEEDLIMIT = new OptionNode("alkingspeedlimit", MOVING_RUNFLY, DataType.INTEGER);
|
public final static OptionNode MOVING_RUNFLY_WALKINGSPEEDLIMIT = new OptionNode("alkingspeedlimit", MOVING_RUNFLY, DataType.INTEGER);
|
||||||
public final static OptionNode MOVING_RUNFLY_SPRINTINGSPEEDLIMIT = new OptionNode("sprintingspeedlimit", MOVING_RUNFLY, DataType.INTEGER);
|
public final static OptionNode MOVING_RUNFLY_SPRINTINGSPEEDLIMIT = new OptionNode("sprintingspeedlimit", MOVING_RUNFLY, DataType.INTEGER);
|
||||||
@ -53,39 +53,39 @@ public abstract class Configuration {
|
|||||||
public final static OptionNode MOVING_RUNFLY_FLYINGSPEEDLIMITHORIZONTAL = new OptionNode("flyingspeedlimithorizontal", MOVING_RUNFLY, DataType.INTEGER);
|
public final static OptionNode MOVING_RUNFLY_FLYINGSPEEDLIMITHORIZONTAL = new OptionNode("flyingspeedlimithorizontal", MOVING_RUNFLY, DataType.INTEGER);
|
||||||
public final static OptionNode MOVING_RUNFLY_FLYINGACTIONS = new OptionNode("flyingactions", MOVING_RUNFLY, DataType.ACTIONLIST);
|
public final static OptionNode MOVING_RUNFLY_FLYINGACTIONS = new OptionNode("flyingactions", MOVING_RUNFLY, DataType.ACTIONLIST);
|
||||||
|
|
||||||
public final static OptionNode MOVING_MOREPACKETS = new OptionNode("morepackets", MOVING, DataType.PARENT);
|
private final static OptionNode MOVING_MOREPACKETS = new OptionNode("morepackets", MOVING, DataType.PARENT);
|
||||||
public final static OptionNode MOVING_MOREPACKETS_CHECK = new OptionNode("check", MOVING_MOREPACKETS, DataType.BOOLEAN);
|
public final static OptionNode MOVING_MOREPACKETS_CHECK = new OptionNode("check", MOVING_MOREPACKETS, DataType.BOOLEAN);
|
||||||
public final static OptionNode MOVING_MOREPACKETS_ACTIONS = new OptionNode("actions", MOVING_MOREPACKETS, DataType.ACTIONLIST);
|
public final static OptionNode MOVING_MOREPACKETS_ACTIONS = new OptionNode("actions", MOVING_MOREPACKETS, DataType.ACTIONLIST);
|
||||||
|
|
||||||
public final static OptionNode BLOCKBREAK = new OptionNode("blockbreak", ROOT, DataType.PARENT);
|
private final static OptionNode BLOCKBREAK = new OptionNode("blockbreak", ROOT, DataType.PARENT);
|
||||||
public final static OptionNode BLOCKBREAK_CHECK = new OptionNode("check", BLOCKBREAK, DataType.BOOLEAN);
|
public final static OptionNode BLOCKBREAK_CHECK = new OptionNode("check", BLOCKBREAK, DataType.BOOLEAN);
|
||||||
|
|
||||||
public final static OptionNode BLOCKBREAK_REACH = new OptionNode("reach", BLOCKBREAK, DataType.PARENT);
|
private final static OptionNode BLOCKBREAK_REACH = new OptionNode("reach", BLOCKBREAK, DataType.PARENT);
|
||||||
public final static OptionNode BLOCKBREAK_REACH_CHECK = new OptionNode("check", BLOCKBREAK_REACH, DataType.BOOLEAN);
|
public final static OptionNode BLOCKBREAK_REACH_CHECK = new OptionNode("check", BLOCKBREAK_REACH, DataType.BOOLEAN);
|
||||||
public final static OptionNode BLOCKBREAK_REACH_LIMIT = new OptionNode("limit", BLOCKBREAK_REACH, DataType.INTEGER);
|
public final static OptionNode BLOCKBREAK_REACH_LIMIT = new OptionNode("limit", BLOCKBREAK_REACH, DataType.INTEGER);
|
||||||
public final static OptionNode BLOCKBREAK_REACH_ACTIONS = new OptionNode("actions", BLOCKBREAK_REACH, DataType.ACTIONLIST);
|
public final static OptionNode BLOCKBREAK_REACH_ACTIONS = new OptionNode("actions", BLOCKBREAK_REACH, DataType.ACTIONLIST);
|
||||||
|
|
||||||
public final static OptionNode BLOCKBREAK_DIRECTION = new OptionNode("direction", BLOCKBREAK, DataType.PARENT);
|
private final static OptionNode BLOCKBREAK_DIRECTION = new OptionNode("direction", BLOCKBREAK, DataType.PARENT);
|
||||||
public final static OptionNode BLOCKBREAK_DIRECTION_CHECK = new OptionNode("check", BLOCKBREAK_DIRECTION, DataType.BOOLEAN);
|
public final static OptionNode BLOCKBREAK_DIRECTION_CHECK = new OptionNode("check", BLOCKBREAK_DIRECTION, DataType.BOOLEAN);
|
||||||
public static final OptionNode BLOCKBREAK_DIRECTION_CHECKINSTABREAKBLOCKS = new OptionNode("checkinstabreakblocks", BLOCKBREAK_DIRECTION, DataType.BOOLEAN);
|
public static final OptionNode BLOCKBREAK_DIRECTION_CHECKINSTABREAKBLOCKS = new OptionNode("checkinstabreakblocks", BLOCKBREAK_DIRECTION, DataType.BOOLEAN);
|
||||||
public final static OptionNode BLOCKBREAK_DIRECTION_ACTIONS = new OptionNode("actions", BLOCKBREAK_DIRECTION, DataType.ACTIONLIST);
|
public final static OptionNode BLOCKBREAK_DIRECTION_ACTIONS = new OptionNode("actions", BLOCKBREAK_DIRECTION, DataType.ACTIONLIST);
|
||||||
|
|
||||||
public final static OptionNode BLOCKPLACE = new OptionNode("blockplace", ROOT, DataType.PARENT);
|
private final static OptionNode BLOCKPLACE = new OptionNode("blockplace", ROOT, DataType.PARENT);
|
||||||
public final static OptionNode BLOCKPLACE_CHECK = new OptionNode("check", BLOCKPLACE, DataType.BOOLEAN);
|
public final static OptionNode BLOCKPLACE_CHECK = new OptionNode("check", BLOCKPLACE, DataType.BOOLEAN);
|
||||||
|
|
||||||
public final static OptionNode BLOCKPLACE_REACH = new OptionNode("reach", BLOCKPLACE, DataType.PARENT);
|
private final static OptionNode BLOCKPLACE_REACH = new OptionNode("reach", BLOCKPLACE, DataType.PARENT);
|
||||||
public final static OptionNode BLOCKPLACE_REACH_CHECK = new OptionNode("check", BLOCKPLACE_REACH, DataType.BOOLEAN);
|
public final static OptionNode BLOCKPLACE_REACH_CHECK = new OptionNode("check", BLOCKPLACE_REACH, DataType.BOOLEAN);
|
||||||
public final static OptionNode BLOCKPLACE_REACH_LIMIT = new OptionNode("limit", BLOCKPLACE_REACH, DataType.INTEGER);
|
public final static OptionNode BLOCKPLACE_REACH_LIMIT = new OptionNode("limit", BLOCKPLACE_REACH, DataType.INTEGER);
|
||||||
public final static OptionNode BLOCKPLACE_REACH_ACTIONS = new OptionNode("actions", BLOCKPLACE_REACH, DataType.ACTIONLIST);
|
public final static OptionNode BLOCKPLACE_REACH_ACTIONS = new OptionNode("actions", BLOCKPLACE_REACH, DataType.ACTIONLIST);
|
||||||
|
|
||||||
public final static OptionNode BLOCKPLACE_ONLIQUID = new OptionNode("onliquid", BLOCKPLACE, DataType.PARENT);
|
private final static OptionNode BLOCKPLACE_ONLIQUID = new OptionNode("onliquid", BLOCKPLACE, DataType.PARENT);
|
||||||
public final static OptionNode BLOCKPLACE_ONLIQUID_CHECK = new OptionNode("check", BLOCKPLACE_ONLIQUID, DataType.BOOLEAN);
|
public final static OptionNode BLOCKPLACE_ONLIQUID_CHECK = new OptionNode("check", BLOCKPLACE_ONLIQUID, DataType.BOOLEAN);
|
||||||
public final static OptionNode BLOCKPLACE_ONLIQUID_ACTIONS = new OptionNode("actions", BLOCKPLACE_ONLIQUID, DataType.ACTIONLIST);
|
public final static OptionNode BLOCKPLACE_ONLIQUID_ACTIONS = new OptionNode("actions", BLOCKPLACE_ONLIQUID, DataType.ACTIONLIST);
|
||||||
|
|
||||||
public final static OptionNode CHAT = new OptionNode("chat", ROOT, DataType.PARENT);
|
private final static OptionNode CHAT = new OptionNode("chat", ROOT, DataType.PARENT);
|
||||||
public final static OptionNode CHAT_CHECK = new OptionNode("check", CHAT, DataType.BOOLEAN);
|
public final static OptionNode CHAT_CHECK = new OptionNode("check", CHAT, DataType.BOOLEAN);
|
||||||
|
|
||||||
public final static OptionNode CHAT_SPAM = new OptionNode("spam", CHAT, DataType.PARENT);
|
private final static OptionNode CHAT_SPAM = new OptionNode("spam", CHAT, DataType.PARENT);
|
||||||
public final static OptionNode CHAT_SPAM_CHECK = new OptionNode("check", CHAT_SPAM, DataType.BOOLEAN);
|
public final static OptionNode CHAT_SPAM_CHECK = new OptionNode("check", CHAT_SPAM, DataType.BOOLEAN);
|
||||||
public final static OptionNode CHAT_SPAM_TIMEFRAME = new OptionNode("timeframe", CHAT_SPAM, DataType.INTEGER);
|
public final static OptionNode CHAT_SPAM_TIMEFRAME = new OptionNode("timeframe", CHAT_SPAM, DataType.INTEGER);
|
||||||
public final static OptionNode CHAT_SPAM_LIMIT = new OptionNode("limit", CHAT_SPAM, DataType.INTEGER);
|
public final static OptionNode CHAT_SPAM_LIMIT = new OptionNode("limit", CHAT_SPAM, DataType.INTEGER);
|
||||||
|
@ -30,7 +30,6 @@ public class ConfigurationManager {
|
|||||||
private final static String configFileName = "config.txt";
|
private final static String configFileName = "config.txt";
|
||||||
private final static String actionFileName = "actions.txt";
|
private final static String actionFileName = "actions.txt";
|
||||||
private final static String defaultActionFileName = "default_actions.txt";
|
private final static String defaultActionFileName = "default_actions.txt";
|
||||||
private final static String descriptionsFileName = "descriptions.txt";
|
|
||||||
|
|
||||||
private final Map<String, ConfigurationCache> worldnameToConfigCacheMap = new HashMap<String, ConfigurationCache>();
|
private final Map<String, ConfigurationCache> worldnameToConfigCacheMap = new HashMap<String, ConfigurationCache>();
|
||||||
|
|
||||||
@ -175,14 +174,14 @@ public class ConfigurationManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getGlobalConfigFile(String rootFolder) {
|
private static File getGlobalConfigFile(String rootFolder) {
|
||||||
|
|
||||||
File globalConfig = new File(rootFolder, configFileName);
|
File globalConfig = new File(rootFolder, configFileName);
|
||||||
|
|
||||||
return globalConfig;
|
return globalConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, File> getWorldSpecificConfigFiles(String rootConfigFolder) {
|
private static Map<String, File> getWorldSpecificConfigFiles(String rootConfigFolder) {
|
||||||
|
|
||||||
HashMap<String, File> files = new HashMap<String, File>();
|
HashMap<String, File> files = new HashMap<String, File>();
|
||||||
|
|
||||||
@ -206,6 +205,14 @@ public class ConfigurationManager {
|
|||||||
|
|
||||||
FileHandler fh = fileToFileHandlerMap.get(logfile);
|
FileHandler fh = fileToFileHandlerMap.get(logfile);
|
||||||
|
|
||||||
|
// this logger will be used ONLY for logging to a single log-file and
|
||||||
|
// only
|
||||||
|
// in this plugin, therefore it doesn't need any namespace
|
||||||
|
Logger l = Logger.getAnonymousLogger();
|
||||||
|
l.setLevel(Level.INFO);
|
||||||
|
// Ignore parent's settings
|
||||||
|
l.setUseParentHandlers(false);
|
||||||
|
|
||||||
if(fh == null) {
|
if(fh == null) {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
@ -221,6 +228,8 @@ public class ConfigurationManager {
|
|||||||
fh.setFormatter(new LogFileFormatter());
|
fh.setFormatter(new LogFileFormatter());
|
||||||
fileToFileHandlerMap.put(logfile, fh);
|
fileToFileHandlerMap.put(logfile, fh);
|
||||||
|
|
||||||
|
l.addHandler(fh);
|
||||||
|
|
||||||
} catch(SecurityException e) {
|
} catch(SecurityException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
@ -228,15 +237,6 @@ public class ConfigurationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this logger will be used ONLY for logging to a single log-file and
|
|
||||||
// only
|
|
||||||
// in this plugin, therefore it doesn't need any namespace
|
|
||||||
Logger l = Logger.getAnonymousLogger();
|
|
||||||
l.setLevel(Level.INFO);
|
|
||||||
// Ignore parent's settings
|
|
||||||
l.setUseParentHandlers(false);
|
|
||||||
l.addHandler(fh);
|
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,17 +282,4 @@ public class ConfigurationManager {
|
|||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getDescriptionFile(String rootConfigFolder) {
|
|
||||||
|
|
||||||
return new File(rootConfigFolder, descriptionsFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getDefaultActionFile(String rootConfigFolder) {
|
|
||||||
return new File(rootConfigFolder, defaultActionFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getActionFile(String rootConfigFolder) {
|
|
||||||
return new File(rootConfigFolder, actionFileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -221,11 +221,11 @@ public class FlatFileConfiguration extends Configuration {
|
|||||||
|
|
||||||
private void saveActionList(BufferedWriter w, String id, ActionList actionList) throws IOException {
|
private void saveActionList(BufferedWriter w, String id, ActionList actionList) throws IOException {
|
||||||
for(Integer treshold : actionList.getTresholds()) {
|
for(Integer treshold : actionList.getTresholds()) {
|
||||||
String s = "";
|
StringBuilder s = new StringBuilder("");
|
||||||
for(Action s2 : actionList.getActions(treshold)) {
|
for(Action s2 : actionList.getActions(treshold)) {
|
||||||
s = s + " " + s2.name;
|
s.append(" ").append(s2.name);
|
||||||
}
|
}
|
||||||
saveValue(w, id + "." + treshold, s.trim());
|
saveValue(w, id + "." + treshold, s.toString().trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -238,7 +238,7 @@ public class FlatFileConfiguration extends Configuration {
|
|||||||
w.write(id + " = " + value + "\r\n");
|
w.write(id + " = " + value + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String removeQuotationMarks(String s) {
|
private String removeQuotationMarks(String s) {
|
||||||
|
|
||||||
s = s.trim();
|
s = s.trim();
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ public class FlatFileConfiguration extends Configuration {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String addQuotationMarks(String s) {
|
private String addQuotationMarks(String s) {
|
||||||
|
|
||||||
return "\"" + s + "\"";
|
return "\"" + s + "\"";
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class OptionNode {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChild(OptionNode node) {
|
private void addChild(OptionNode node) {
|
||||||
if(this.type != DataType.PARENT) {
|
if(this.type != DataType.PARENT) {
|
||||||
throw new IllegalArgumentException("Can't a child to a leaf node.");
|
throw new IllegalArgumentException("Can't a child to a leaf node.");
|
||||||
}
|
}
|
||||||
|
37
src/cc/co/evenprime/bukkit/nocheat/data/BaseData.java
Normal file
37
src/cc/co/evenprime/bukkit/nocheat/data/BaseData.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package cc.co.evenprime.bukkit.nocheat.data;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
|
public class BaseData {
|
||||||
|
|
||||||
|
public final BlockBreakData blockbreak;
|
||||||
|
public final BlockPlaceData blockplace;
|
||||||
|
public final ChatData chat;
|
||||||
|
public final LogData log;
|
||||||
|
public final MovingData moving;
|
||||||
|
|
||||||
|
private final Data[] data;
|
||||||
|
|
||||||
|
public BaseData() {
|
||||||
|
this.blockbreak = new BlockBreakData();
|
||||||
|
this.blockplace = new BlockPlaceData();
|
||||||
|
this.chat = new ChatData();
|
||||||
|
this.log = new LogData();
|
||||||
|
this.moving = new MovingData();
|
||||||
|
|
||||||
|
data = new Data[] { this.blockbreak, this.blockplace, this.chat, this.log, this.moving };
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearCriticalData() {
|
||||||
|
for(Data d : data) {
|
||||||
|
d.clearCriticalData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize(Player player) {
|
||||||
|
for(Data d : data) {
|
||||||
|
d.initialize(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,11 +8,11 @@ import org.bukkit.Location;
|
|||||||
* @author Evenprime
|
* @author Evenprime
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BlockBreakData {
|
public class BlockBreakData extends Data {
|
||||||
|
|
||||||
public double reachViolationLevel = 0.0D;
|
public double reachViolationLevel = 0.0D;
|
||||||
|
public double directionViolationLevel = 0.0D;
|
||||||
public double directionViolationLevel = 0.0D;
|
|
||||||
|
|
||||||
public Location instaBrokeBlockLocation = null;
|
public Location instaBrokeBlockLocation = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ package cc.co.evenprime.bukkit.nocheat.data;
|
|||||||
* @author Evenprime
|
* @author Evenprime
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BlockPlaceData {
|
public class BlockPlaceData extends Data {
|
||||||
|
|
||||||
public double onliquidViolationLevel = 0.0D;
|
public double onliquidViolationLevel = 0.0D;
|
||||||
public double reachViolationLevel = 0.0D;
|
public double reachViolationLevel = 0.0D;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ package cc.co.evenprime.bukkit.nocheat.data;
|
|||||||
* @author Evenprime
|
* @author Evenprime
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ChatData {
|
public class ChatData extends Data {
|
||||||
|
|
||||||
public int messageCount = 0;
|
public int messageCount = 0;
|
||||||
public int spamLasttime = 0;
|
public int spamLasttime = 0;
|
||||||
|
21
src/cc/co/evenprime/bukkit/nocheat/data/Data.java
Normal file
21
src/cc/co/evenprime/bukkit/nocheat/data/Data.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package cc.co.evenprime.bukkit.nocheat.data;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Every class that is extending this has to implement an empty Constructor()
|
||||||
|
*
|
||||||
|
* @author Evenprime
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class Data {
|
||||||
|
|
||||||
|
public void initialize(Player player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearCriticalData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -7,100 +7,55 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide secure access to player-specific data objects for various checks or
|
* Provide secure access to player-specific data objects for various checks or
|
||||||
* check groups
|
* check groups.
|
||||||
*
|
|
||||||
* @author Evenprime
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class DataManager {
|
public class DataManager {
|
||||||
|
|
||||||
// Store data between Events
|
// Store data between Events
|
||||||
private final Map<Player, MovingData> movingData = new HashMap<Player, MovingData>();
|
private final Map<Player, BaseData> map;
|
||||||
private final Map<Player, BlockBreakData> blockbreakData = new HashMap<Player, BlockBreakData>();
|
|
||||||
private final Map<Player, BlockPlaceData> blockPlaceData = new HashMap<Player, BlockPlaceData>();
|
|
||||||
private final Map<Player, ChatData> chatData = new HashMap<Player, ChatData>();
|
|
||||||
private final Map<Player, LogData> logData = new HashMap<Player, LogData>();
|
|
||||||
|
|
||||||
public DataManager() {
|
public DataManager() {
|
||||||
|
this.map = new HashMap<Player, BaseData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MovingData getMovingData(Player player) {
|
/**
|
||||||
|
* Get a data object of the specified class. If none is stored yet, create
|
||||||
|
* one.
|
||||||
|
*/
|
||||||
|
public BaseData getData(Player player) {
|
||||||
|
|
||||||
MovingData data;
|
BaseData data = this.map.get(player);
|
||||||
|
|
||||||
// intentionally not thread-safe, because bukkit events are handled
|
|
||||||
// in sequence anyway, so zero chance of two move events of the same
|
|
||||||
// player being handled at the same time
|
|
||||||
data = movingData.get(player);
|
|
||||||
if(data == null) {
|
|
||||||
data = new MovingData();
|
|
||||||
movingData.put(player, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockBreakData getBlockBreakData(Player player) {
|
|
||||||
|
|
||||||
BlockBreakData data;
|
|
||||||
|
|
||||||
// intentionally not thread-safe, because bukkit events are handled
|
|
||||||
// in sequence anyway, so zero chance of two move events of the same
|
|
||||||
// player being handled at the same time
|
|
||||||
data = blockbreakData.get(player);
|
|
||||||
if(data == null) {
|
|
||||||
data = new BlockBreakData();
|
|
||||||
blockbreakData.put(player, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPlaceData getBlockPlaceData(Player player) {
|
|
||||||
BlockPlaceData data;
|
|
||||||
|
|
||||||
// intentionally not thread-safe, because bukkit events are handled
|
// intentionally not thread-safe, because bukkit events are handled
|
||||||
// in sequence anyway, so zero chance of two events of the same
|
// in sequence anyway, so zero chance of two events of the same
|
||||||
// player being handled at the same time
|
// player being handled at the same time
|
||||||
data = blockPlaceData.get(player);
|
// And if it still happens by accident, it's no real loss anyway, as
|
||||||
|
// losing data of one instance doesn't really hurt at all
|
||||||
if(data == null) {
|
if(data == null) {
|
||||||
data = new BlockPlaceData();
|
data = new BaseData();
|
||||||
blockPlaceData.put(player, data);
|
data.initialize(player);
|
||||||
|
this.map.put(player, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatData getChatData(Player player) {
|
/**
|
||||||
ChatData data;
|
* Remove all data Objects of a specific player
|
||||||
|
*
|
||||||
// intentionally not thread-safe, because bukkit events are handled
|
* @param player
|
||||||
// in sequence anyway, so zero chance of two events of the same
|
*/
|
||||||
// player being handled at the same time
|
public void removeDataForPlayer(Player player) {
|
||||||
// And if it still happens by accident, it's no real loss anyway
|
this.map.remove(player);
|
||||||
data = chatData.get(player);
|
|
||||||
if(data == null) {
|
|
||||||
data = new ChatData();
|
|
||||||
chatData.put(player, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LogData getLogData(Player player) {
|
/**
|
||||||
LogData data;
|
* Reset data that may cause problems after e.g. changing the config
|
||||||
|
*
|
||||||
// intentionally not thread-safe, because bukkit events are handled
|
*/
|
||||||
// in sequence anyway, so zero chance of two events of the same
|
public void resetAllCriticalData() {
|
||||||
// player being handled at the same time
|
for(BaseData b : this.map.values()) {
|
||||||
// And if it still happens by accident, it's no real loss anyway
|
b.clearCriticalData();
|
||||||
data = logData.get(player);
|
|
||||||
if(data == null) {
|
|
||||||
data = new LogData(player);
|
|
||||||
logData.put(player, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,28 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.data;
|
package cc.co.evenprime.bukkit.nocheat.data;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Everything that could be relevant for logging or consolecommand actions
|
* Everything that could be relevant for logging or consolecommand actions
|
||||||
*
|
|
||||||
* @author Evenprime
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class LogData {
|
public class LogData extends Data {
|
||||||
|
|
||||||
// The player never changes
|
public Player player;
|
||||||
public final Player player;
|
public String check;
|
||||||
public String check;
|
public int violationLevel;
|
||||||
public int violationLevel;
|
|
||||||
public Location toLocation;
|
public Location toLocation;
|
||||||
public int packets;
|
public int packets;
|
||||||
public String text;
|
public String text;
|
||||||
public Material placedMaterial;
|
public Block placed;
|
||||||
public Block placed;
|
public Block placedAgainst;
|
||||||
public Block placedAgainst;
|
public double reachdistance;
|
||||||
public double reachdistance;
|
public float falldistance;
|
||||||
public float falldistance;
|
|
||||||
|
|
||||||
public LogData(Player player) {
|
public void initialize(Player player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
check = "";
|
||||||
|
toLocation = player.getLocation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,41 +1,59 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.data;
|
package cc.co.evenprime.bukkit.nocheat.data;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Playerspecific data for the moving check group
|
* Player specific data for the moving check group
|
||||||
*
|
|
||||||
* @author Evenprime
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class MovingData {
|
public class MovingData extends Data {
|
||||||
|
|
||||||
public int jumpPhase = 0;
|
public int jumpPhase;
|
||||||
|
|
||||||
public Location runflySetBackPoint = null;
|
public Location runflySetBackPoint;
|
||||||
|
|
||||||
public double runflyViolationLevel = 0.0D;
|
public double runflyViolationLevel;
|
||||||
|
|
||||||
public double vertFreedom = 0.0D;
|
public double vertFreedom;
|
||||||
public double vertVelocity = 0.0D;
|
public double vertVelocity;
|
||||||
public int vertVelocityCounter = 0;
|
public int vertVelocityCounter;
|
||||||
public double horizFreedom = 0.0D;
|
public double horizFreedom;
|
||||||
public int horizVelocityCounter = 0;
|
public int horizVelocityCounter;
|
||||||
|
|
||||||
public double nofallViolationLevel = 0.0D;
|
public double nofallViolationLevel;
|
||||||
public float fallDistance = 0.0F;
|
public float fallDistance;
|
||||||
public float lastAddedFallDistance = 0.0F;
|
public float lastAddedFallDistance;
|
||||||
|
|
||||||
public double horizontalBuffer;
|
public double horizontalBuffer;
|
||||||
public int bunnyhopdelay = 0;
|
public int bunnyhopdelay;
|
||||||
|
|
||||||
public int morePacketsCounter;
|
public int morePacketsCounter;
|
||||||
public int morePacketsBuffer = 50;
|
public int morePacketsBuffer;
|
||||||
public Location morePacketsSetbackPoint;
|
public Location morePacketsSetbackPoint;
|
||||||
public double morePacketsViolationLevel = 0;
|
public double morePacketsViolationLevel;
|
||||||
|
|
||||||
public Location teleportTo;
|
public Location teleportTo;
|
||||||
|
|
||||||
public int lastElapsedIngameSeconds = 0;
|
public int lastElapsedIngameSeconds;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(Player player) {
|
||||||
|
runflySetBackPoint = player.getLocation();
|
||||||
|
morePacketsBuffer = 50;
|
||||||
|
morePacketsSetbackPoint = player.getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearCriticalData() {
|
||||||
|
teleportTo = null;
|
||||||
|
jumpPhase = 0;
|
||||||
|
runflySetBackPoint = null;
|
||||||
|
fallDistance = 0;
|
||||||
|
lastAddedFallDistance = 0;
|
||||||
|
bunnyhopdelay = 0;
|
||||||
|
morePacketsBuffer = 50;
|
||||||
|
morePacketsSetbackPoint = null;
|
||||||
|
lastElapsedIngameSeconds = 0;
|
||||||
|
morePacketsCounter = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ import cc.co.evenprime.bukkit.nocheat.data.BlockBreakData;
|
|||||||
*/
|
*/
|
||||||
public class BlockBreakEventManager extends BlockListener implements EventManager {
|
public class BlockBreakEventManager extends BlockListener implements EventManager {
|
||||||
|
|
||||||
private final BlockBreakCheck blockBreakCheck;
|
private final BlockBreakCheck blockBreakCheck;
|
||||||
private final NoCheat plugin;
|
private final NoCheat plugin;
|
||||||
|
|
||||||
public BlockBreakEventManager(NoCheat plugin) {
|
public BlockBreakEventManager(NoCheat plugin) {
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public class BlockBreakEventManager extends BlockListener implements EventManage
|
|||||||
boolean cancel = false;
|
boolean cancel = false;
|
||||||
|
|
||||||
// Get the player-specific stored data that applies here
|
// Get the player-specific stored data that applies here
|
||||||
final BlockBreakData data = plugin.getDataManager().getBlockBreakData(player);
|
final BlockBreakData data = plugin.getDataManager().getData(player).blockbreak;
|
||||||
|
|
||||||
cancel = blockBreakCheck.check(player, event.getBlock(), data, cc);
|
cancel = blockBreakCheck.check(player, event.getBlock(), data, cc);
|
||||||
|
|
||||||
@ -77,14 +77,13 @@ public class BlockBreakEventManager extends BlockListener implements EventManage
|
|||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
// Get the player-specific stored data that applies here
|
// Get the player-specific stored data that applies here
|
||||||
final BlockBreakData data = plugin.getDataManager().getBlockBreakData(player);
|
final BlockBreakData data = plugin.getDataManager().getData(player).blockbreak;
|
||||||
|
|
||||||
// Remember this location. We ignore block breaks in the block-break
|
// Remember this location. We ignore block breaks in the block-break
|
||||||
// direction check that are insta-breaks
|
// direction check that are insta-breaks
|
||||||
data.instaBrokeBlockLocation = event.getBlock().getLocation();
|
data.instaBrokeBlockLocation = event.getBlock().getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||||
LinkedList<String> s = new LinkedList<String>();
|
LinkedList<String> s = new LinkedList<String>();
|
||||||
|
|
||||||
@ -96,7 +95,6 @@ public class BlockBreakEventManager extends BlockListener implements EventManage
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||||
LinkedList<String> s = new LinkedList<String>();
|
LinkedList<String> s = new LinkedList<String>();
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public class BlockPlaceEventManager extends BlockListener implements EventManage
|
|||||||
if(!event.isCancelled()) {
|
if(!event.isCancelled()) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
// Get the player-specific stored data that applies here
|
// Get the player-specific stored data that applies here
|
||||||
movingCheck.blockPlaced(player, plugin.getDataManager().getMovingData(player), event.getBlockPlaced());
|
movingCheck.blockPlaced(player, plugin.getDataManager().getData(player).moving, event.getBlockPlaced());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, Priority.Monitor, plugin);
|
}, Priority.Monitor, plugin);
|
||||||
@ -67,7 +67,7 @@ public class BlockPlaceEventManager extends BlockListener implements EventManage
|
|||||||
// Find out if checks need to be done for that player
|
// Find out if checks need to be done for that player
|
||||||
if(cc.blockplace.check && !player.hasPermission(Permissions.BLOCKPLACE)) {
|
if(cc.blockplace.check && !player.hasPermission(Permissions.BLOCKPLACE)) {
|
||||||
|
|
||||||
cancel = blockPlaceCheck.check(player, event.getBlockPlaced(), event.getBlockAgainst(), plugin.getDataManager().getBlockPlaceData(player), cc);
|
cancel = blockPlaceCheck.check(player, event.getBlockPlaced(), event.getBlockAgainst(), plugin.getDataManager().getData(player).blockplace, cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cancel) {
|
if(cancel) {
|
||||||
@ -76,7 +76,6 @@ public class BlockPlaceEventManager extends BlockListener implements EventManage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||||
LinkedList<String> s = new LinkedList<String>();
|
LinkedList<String> s = new LinkedList<String>();
|
||||||
|
|
||||||
@ -88,7 +87,6 @@ public class BlockPlaceEventManager extends BlockListener implements EventManage
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||||
LinkedList<String> s = new LinkedList<String>();
|
LinkedList<String> s = new LinkedList<String>();
|
||||||
|
|
||||||
|
@ -8,5 +8,6 @@ import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
|||||||
public interface EventManager {
|
public interface EventManager {
|
||||||
|
|
||||||
public List<String> getActiveChecks(ConfigurationCache cc);
|
public List<String> getActiveChecks(ConfigurationCache cc);
|
||||||
|
|
||||||
public List<String> getInactiveChecks(ConfigurationCache cc);
|
public List<String> getInactiveChecks(ConfigurationCache cc);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
|||||||
import cc.co.evenprime.bukkit.nocheat.checks.chat.ChatCheck;
|
import cc.co.evenprime.bukkit.nocheat.checks.chat.ChatCheck;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.Permissions;
|
import cc.co.evenprime.bukkit.nocheat.config.Permissions;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||||
import cc.co.evenprime.bukkit.nocheat.data.ChatData;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -54,10 +53,7 @@ public class PlayerChatEventManager extends PlayerListener implements EventManag
|
|||||||
|
|
||||||
boolean cancel = false;
|
boolean cancel = false;
|
||||||
|
|
||||||
// Get the player-specific stored data that applies here
|
cancel = chatCheck.check(player, event.getMessage(), plugin.getDataManager().getData(player).chat, cc);
|
||||||
final ChatData data = plugin.getDataManager().getChatData(player);
|
|
||||||
|
|
||||||
cancel = chatCheck.check(player, event.getMessage(), data, cc);
|
|
||||||
|
|
||||||
if(cancel) {
|
if(cancel) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -70,7 +66,6 @@ public class PlayerChatEventManager extends PlayerListener implements EventManag
|
|||||||
onPlayerChat(event);
|
onPlayerChat(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||||
LinkedList<String> s = new LinkedList<String>();
|
LinkedList<String> s = new LinkedList<String>();
|
||||||
|
|
||||||
@ -79,7 +74,6 @@ public class PlayerChatEventManager extends PlayerListener implements EventManag
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||||
LinkedList<String> s = new LinkedList<String>();
|
LinkedList<String> s = new LinkedList<String>();
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class PlayerMoveEventManager extends PlayerListener implements EventManag
|
|||||||
if(cc.moving.check && !player.hasPermission(Permissions.MOVE)) {
|
if(cc.moving.check && !player.hasPermission(Permissions.MOVE)) {
|
||||||
|
|
||||||
// Get the player-specific stored data that applies here
|
// Get the player-specific stored data that applies here
|
||||||
final MovingData data = plugin.getDataManager().getMovingData(player);
|
final MovingData data = plugin.getDataManager().getData(player).moving;
|
||||||
|
|
||||||
// Get some data that's needed from this event, to avoid passing the
|
// Get some data that's needed from this event, to avoid passing the
|
||||||
// event itself on to the checks (and risk to
|
// event itself on to the checks (and risk to
|
||||||
@ -96,7 +96,7 @@ public class PlayerMoveEventManager extends PlayerListener implements EventManag
|
|||||||
if(!event.isCancelled()) {
|
if(!event.isCancelled()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
MovingData mdata = plugin.getDataManager().getMovingData(player);
|
MovingData mdata = plugin.getDataManager().getData(player).moving;
|
||||||
|
|
||||||
Vector v = event.getVelocity();
|
Vector v = event.getVelocity();
|
||||||
|
|
||||||
@ -116,7 +116,6 @@ public class PlayerMoveEventManager extends PlayerListener implements EventManag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||||
LinkedList<String> s = new LinkedList<String>();
|
LinkedList<String> s = new LinkedList<String>();
|
||||||
|
|
||||||
@ -136,7 +135,6 @@ public class PlayerMoveEventManager extends PlayerListener implements EventManag
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||||
LinkedList<String> s = new LinkedList<String>();
|
LinkedList<String> s = new LinkedList<String>();
|
||||||
|
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
package cc.co.evenprime.bukkit.nocheat.events;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.Event.Priority;
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||||
|
|
||||||
|
public class PlayerQuitEventManager extends PlayerListener implements EventManager {
|
||||||
|
|
||||||
|
private final NoCheat plugin;
|
||||||
|
public PlayerQuitEventManager(NoCheat plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
PluginManager pm = Bukkit.getServer().getPluginManager();
|
||||||
|
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_QUIT, this, Priority.Monitor, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
// Get rid of the players stored data when disconnecting him
|
||||||
|
plugin.getDataManager().removeDataForPlayer(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -48,9 +48,9 @@ public class PlayerTeleportEventManager extends PlayerListener implements EventM
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
final MovingData data2 = plugin.getDataManager().getMovingData(event.getPlayer());
|
final MovingData data = plugin.getDataManager().getData(event.getPlayer()).moving;
|
||||||
if(event.isCancelled()) {
|
if(event.isCancelled()) {
|
||||||
if(data2.teleportTo != null && data2.teleportTo.equals(event.getTo())) {
|
if(data.teleportTo != null && data.teleportTo.equals(event.getTo())) {
|
||||||
event.setCancelled(false);
|
event.setCancelled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,13 +60,15 @@ public class PlayerTeleportEventManager extends PlayerListener implements EventM
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
// Intentionally not check for cancelled state, may help with problems with other plugins...
|
if(!event.isCancelled()) {
|
||||||
handleTeleportation(event.getPlayer(), event.getTo());
|
handleTeleportation(event.getPlayer(), event.getTo());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerPortal(PlayerPortalEvent event) {
|
public void onPlayerPortal(PlayerPortalEvent event) {
|
||||||
// Intentionally not check for cancelled state, may help with problems with other plugins...
|
if(!event.isCancelled()) {
|
||||||
handleTeleportation(event.getPlayer(), event.getTo());
|
handleTeleportation(event.getPlayer(), event.getTo());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||||
@ -82,23 +84,13 @@ public class PlayerTeleportEventManager extends PlayerListener implements EventM
|
|||||||
|
|
||||||
private void handleTeleportation(Player player, Location newLocation) {
|
private void handleTeleportation(Player player, Location newLocation) {
|
||||||
|
|
||||||
/********* Moving check ************/
|
plugin.getDataManager().getData(player).clearCriticalData();
|
||||||
final MovingData data = plugin.getDataManager().getMovingData(player);
|
|
||||||
|
|
||||||
data.runflySetBackPoint = null;
|
|
||||||
data.morePacketsCounter = 0;
|
|
||||||
data.morePacketsSetbackPoint = null;
|
|
||||||
data.jumpPhase = 0;
|
|
||||||
data.fallDistance = 0F;
|
|
||||||
data.lastAddedFallDistance = 0F;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class LogManager {
|
|||||||
* @param level
|
* @param level
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public void logToChat(LogLevel level, String message) {
|
private void logToChat(LogLevel level, String message) {
|
||||||
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
|
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
if(player.hasPermission(Permissions.ADMIN_CHATLOG)) {
|
if(player.hasPermission(Permissions.ADMIN_CHATLOG)) {
|
||||||
player.sendMessage(message);
|
player.sendMessage(message);
|
||||||
@ -81,7 +81,7 @@ public class LogManager {
|
|||||||
* @param message
|
* @param message
|
||||||
* @param fileLogger
|
* @param fileLogger
|
||||||
*/
|
*/
|
||||||
public void logToFile(LogLevel level, String message, Logger fileLogger) {
|
private void logToFile(LogLevel level, String message, Logger fileLogger) {
|
||||||
fileLogger.log(level.level, message);
|
fileLogger.log(level.level, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user