mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-10-06 18:37:29 +02:00
Refactoring, code cleanup, moved executionHistories to "data"
This commit is contained in:
parent
0b04b7d43f
commit
a0024d0737
@ -12,6 +12,7 @@ import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.ConfigurationManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.Permissions;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
@ -46,6 +47,7 @@ public class NoCheat extends JavaPlugin {
|
||||
private LogManager log;
|
||||
private DataManager data;
|
||||
private PerformanceManager performance;
|
||||
private ActionManager action;
|
||||
|
||||
private final List<EventManager> eventManagers = new LinkedList<EventManager>();
|
||||
|
||||
@ -89,6 +91,9 @@ public class NoCheat extends JavaPlugin {
|
||||
// Then set up the performance counters
|
||||
this.performance = new PerformanceManager();
|
||||
|
||||
// Then set up the Action Manager
|
||||
this.action = new ActionManager(this);
|
||||
|
||||
// Then set up the event listeners
|
||||
eventManagers.add(new PlayerMoveEventManager(this));
|
||||
eventManagers.add(new PlayerTeleportEventManager(this));
|
||||
@ -144,6 +149,10 @@ public class NoCheat extends JavaPlugin {
|
||||
return performance;
|
||||
}
|
||||
|
||||
public ActionManager getActionManager() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public int getIngameSeconds() {
|
||||
return ingameseconds;
|
||||
}
|
||||
|
@ -1,17 +1,15 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.actions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.history.ActionHistory;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.Action;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.ConsolecommandAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.LogAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.SpecialAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.ActionData;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
|
||||
/**
|
||||
@ -21,34 +19,32 @@ import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class ActionExecutor {
|
||||
public class ActionManager {
|
||||
|
||||
private final Map<Player, ActionHistory> actionHistory = new HashMap<Player, ActionHistory>();
|
||||
private final NoCheat plugin;
|
||||
|
||||
public ActionExecutor(NoCheat plugin) {
|
||||
public ActionManager(NoCheat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean executeActions(Player player, ActionList actions, int violationLevel, LogData data, ConfigurationCache cc) {
|
||||
public boolean executeActions(Player player, ActionList actions, int violationLevel, LogData data, ActionData history, ConfigurationCache cc) {
|
||||
|
||||
boolean special = false;
|
||||
|
||||
// Always set this here "by hand"
|
||||
data.violationLevel = violationLevel;
|
||||
|
||||
long time = System.currentTimeMillis() / 1000;
|
||||
final long time = System.currentTimeMillis() / 1000;
|
||||
|
||||
for(Action ac : actions.getActions(violationLevel)) {
|
||||
|
||||
if(getHistory(player).executeAction(ac, time)) {
|
||||
if(history.executeAction(ac, time)) {
|
||||
if(ac instanceof LogAction) {
|
||||
LogAction l = (LogAction) ac;
|
||||
plugin.getLogManager().log(l.level, l.getMessage(data), cc);
|
||||
executeLogAction((LogAction) ac, data, cc);
|
||||
} else if(ac instanceof SpecialAction) {
|
||||
special = true;
|
||||
} else if(ac instanceof ConsolecommandAction) {
|
||||
executeConsoleCommand(((ConsolecommandAction) ac).getCommand(data));
|
||||
executeConsoleCommand((ConsolecommandAction) ac, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -56,19 +52,12 @@ public class ActionExecutor {
|
||||
return special;
|
||||
}
|
||||
|
||||
private ActionHistory getHistory(Player player) {
|
||||
|
||||
ActionHistory history = actionHistory.get(player);
|
||||
|
||||
if(history == null) {
|
||||
history = new ActionHistory();
|
||||
actionHistory.put(player, history);
|
||||
private void executeLogAction(LogAction l, LogData data, ConfigurationCache cc) {
|
||||
plugin.getLogManager().log(l.level, l.getMessage(data), cc);
|
||||
}
|
||||
|
||||
return history;
|
||||
}
|
||||
|
||||
private void executeConsoleCommand(String command) {
|
||||
private void executeConsoleCommand(ConsolecommandAction action, LogData data) {
|
||||
String command = action.getCommand(data);
|
||||
try {
|
||||
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command);
|
||||
} catch(Exception e) {
|
@ -11,9 +11,9 @@ import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.BlockBreakData;
|
||||
|
||||
/**
|
||||
* The main Check class for blockbreak event checking. It will decide which checks
|
||||
* need to be executed and in which order. It will also precalculate some values
|
||||
* that are needed by multiple checks.
|
||||
* The main Check class for blockbreak event checking. It will decide which
|
||||
* checks need to be executed and in which order. It will also precalculate
|
||||
* some values that are needed by multiple checks.
|
||||
*
|
||||
* @author Evenprime
|
||||
*
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutor;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.BlockBreakData;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
@ -19,12 +18,10 @@ import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
*/
|
||||
public class DirectionCheck {
|
||||
|
||||
private final ActionExecutor action;
|
||||
private final NoCheat plugin;
|
||||
|
||||
public DirectionCheck(NoCheat plugin) {
|
||||
this.plugin = plugin;
|
||||
this.action = new ActionExecutor(plugin);
|
||||
}
|
||||
|
||||
public boolean check(Player player, double factor, double x1, double y1, double z1, Block brokenBlock, BlockBreakData data, ConfigurationCache cc) {
|
||||
@ -50,10 +47,10 @@ public class DirectionCheck {
|
||||
data.directionViolationLevel += 1;
|
||||
|
||||
// Prepare some event-specific values for logging and custom actions
|
||||
LogData ldata = plugin.getDataManager().getData( player).log;
|
||||
LogData ldata = plugin.getDataManager().getData(player).log;
|
||||
ldata.check = "blockbreak.direction";
|
||||
|
||||
cancel = action.executeActions(player, cc.blockbreak.directionActions, (int) data.directionViolationLevel, ldata, cc);
|
||||
cancel = plugin.getActionManager().executeActions(player, cc.blockbreak.directionActions, (int) data.directionViolationLevel, ldata, data.history, cc);
|
||||
}
|
||||
|
||||
return cancel;
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutor;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.BlockBreakData;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
@ -19,11 +18,9 @@ import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
public class ReachCheck {
|
||||
|
||||
private final NoCheat plugin;
|
||||
private final ActionExecutor action;
|
||||
|
||||
public ReachCheck(NoCheat plugin) {
|
||||
this.plugin = plugin;
|
||||
this.action = new ActionExecutor(plugin);
|
||||
}
|
||||
|
||||
public boolean check(Player player, double distance, BlockBreakData data, ConfigurationCache cc) {
|
||||
@ -41,7 +38,7 @@ public class ReachCheck {
|
||||
|
||||
ldata.check = "blockbreak.reach";
|
||||
ldata.reachdistance = distance;
|
||||
cancel = action.executeActions(player, cc.blockbreak.reachActions, (int) data.reachViolationLevel, ldata, cc);
|
||||
cancel = plugin.getActionManager().executeActions(player, cc.blockbreak.reachActions, (int) data.reachViolationLevel, ldata, data.history, cc);
|
||||
} else {
|
||||
data.reachViolationLevel *= 0.9D;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutor;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.BlockPlaceData;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
@ -19,11 +18,9 @@ import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
public class OnLiquidCheck {
|
||||
|
||||
private final NoCheat plugin;
|
||||
private final ActionExecutor action;
|
||||
|
||||
public OnLiquidCheck(NoCheat plugin) {
|
||||
this.plugin = plugin;
|
||||
action = new ActionExecutor(plugin);
|
||||
}
|
||||
|
||||
public boolean check(Player player, Block blockPlaced, Block blockPlacedAgainst, BlockPlaceData data, ConfigurationCache cc) {
|
||||
@ -43,7 +40,7 @@ public class OnLiquidCheck {
|
||||
ldata.placed = blockPlaced;
|
||||
ldata.placedAgainst = blockPlacedAgainst;
|
||||
|
||||
cancel = action.executeActions(player, cc.blockplace.onliquidActions, (int) data.onliquidViolationLevel, ldata, cc);
|
||||
cancel = plugin.getActionManager().executeActions(player, cc.blockplace.onliquidActions, (int) data.onliquidViolationLevel, ldata, data.history, cc);
|
||||
}
|
||||
|
||||
data.onliquidViolationLevel *= 0.95D; // Reduce level over time
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutor;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.BlockPlaceData;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
@ -21,11 +20,9 @@ import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
public class ReachCheck {
|
||||
|
||||
private final NoCheat plugin;
|
||||
private final ActionExecutor action;
|
||||
|
||||
public ReachCheck(NoCheat plugin) {
|
||||
this.plugin = plugin;
|
||||
this.action = new ActionExecutor(plugin);
|
||||
}
|
||||
|
||||
public boolean check(Player player, Block blockPlaced, Block placedAgainstBlock, BlockPlaceData data, ConfigurationCache cc) {
|
||||
@ -51,7 +48,7 @@ public class ReachCheck {
|
||||
ldata.check = "blockplace.reach";
|
||||
ldata.reachdistance = distance;
|
||||
|
||||
cancel = action.executeActions(player, cc.blockplace.reachActions, (int) data.reachViolationLevel, ldata, cc);
|
||||
cancel = plugin.getActionManager().executeActions(player, cc.blockplace.reachActions, (int) data.reachViolationLevel, ldata, data.history, cc);
|
||||
} else {
|
||||
data.reachViolationLevel *= 0.9D;
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package cc.co.evenprime.bukkit.nocheat.checks.chat;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutor;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.Permissions;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.ChatData;
|
||||
@ -16,13 +15,11 @@ import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
*/
|
||||
public class ChatCheck {
|
||||
|
||||
private final ActionExecutor action;
|
||||
private final NoCheat plugin;
|
||||
|
||||
public ChatCheck(NoCheat plugin) {
|
||||
|
||||
this.plugin = plugin;
|
||||
action = new ActionExecutor(plugin);
|
||||
}
|
||||
|
||||
public boolean check(Player player, String message, ChatData data, ConfigurationCache cc) {
|
||||
@ -51,7 +48,7 @@ public class ChatCheck {
|
||||
ldata.check = "chat.spam";
|
||||
ldata.text = message;
|
||||
|
||||
cancel = action.executeActions(player, cc.chat.spamActions, data.messageCount - cc.chat.spamLimit, ldata, cc);
|
||||
cancel = plugin.getActionManager().executeActions(player, cc.chat.spamActions, data.messageCount - cc.chat.spamLimit, ldata, data.history, cc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutor;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.Permissions;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.FightData;
|
||||
@ -19,13 +18,11 @@ import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
*/
|
||||
public class FightCheck {
|
||||
|
||||
private final ActionExecutor action;
|
||||
private final NoCheat plugin;
|
||||
|
||||
public FightCheck(NoCheat plugin) {
|
||||
|
||||
this.plugin = plugin;
|
||||
action = new ActionExecutor(plugin);
|
||||
}
|
||||
|
||||
public boolean check(Player player, Entity damagee, FightData data, ConfigurationCache cc) {
|
||||
@ -50,7 +47,8 @@ public class FightCheck {
|
||||
final double p = width / 2 + cc.fight.directionPrecision;
|
||||
final double h = height / 2 + cc.fight.directionPrecision;
|
||||
|
||||
// TODO: Move this into a seperate class to recycle it throughout NoCheat
|
||||
// TODO: Move this into a seperate class to recycle it throughout
|
||||
// NoCheat
|
||||
final double x1 = ((double) damagee.getLocation().getX()) - eyes.getX() - p;
|
||||
final double y1 = ((double) damagee.getLocation().getY()) - eyes.getY() - cc.fight.directionPrecision;
|
||||
final double z1 = ((double) damagee.getLocation().getZ()) - eyes.getZ() - p;
|
||||
@ -77,7 +75,7 @@ public class FightCheck {
|
||||
LogData ldata = plugin.getDataManager().getData(player).log;
|
||||
ldata.check = "fight.direction";
|
||||
|
||||
cancel = action.executeActions(player, cc.fight.directionActions, (int) data.violationLevel, ldata, cc);
|
||||
cancel = plugin.getActionManager().executeActions(player, cc.fight.directionActions, (int) data.violationLevel, ldata, data.history, cc);
|
||||
|
||||
if(cancel) {
|
||||
// Needed to calculate penalty times
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutor;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.MovingData;
|
||||
@ -22,13 +21,11 @@ import cc.co.evenprime.bukkit.nocheat.data.MovingData;
|
||||
public class FlyingCheck {
|
||||
|
||||
private final NoCheat plugin;
|
||||
private final ActionExecutor action;
|
||||
|
||||
private static final double creativeSpeed = 0.60D;
|
||||
|
||||
public FlyingCheck(NoCheat plugin) {
|
||||
this.plugin = plugin;
|
||||
this.action = new ActionExecutor(plugin);
|
||||
}
|
||||
|
||||
public Location check(Player player, Location from, Location to, ConfigurationCache cc, MovingData data) {
|
||||
@ -88,7 +85,7 @@ public class FlyingCheck {
|
||||
ldata.toLocation = to;
|
||||
ldata.check = "flying/toofast";
|
||||
|
||||
boolean cancel = action.executeActions(player, cc.moving.flyingActions, (int) data.runflyViolationLevel, ldata, cc);
|
||||
boolean cancel = plugin.getActionManager().executeActions(player, cc.moving.flyingActions, (int) data.runflyViolationLevel, ldata, data.history, cc);
|
||||
|
||||
// Was one of the actions a cancel? Then really do it
|
||||
if(cancel) {
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutor;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.MovingData;
|
||||
@ -23,14 +22,11 @@ import cc.co.evenprime.bukkit.nocheat.data.MovingData;
|
||||
*/
|
||||
public class MorePacketsCheck {
|
||||
|
||||
private final ActionExecutor action;
|
||||
|
||||
private final static int packetsPerTimeframe = 22;
|
||||
private final static int bufferLimit = 30;
|
||||
private final NoCheat plugin;
|
||||
|
||||
public MorePacketsCheck(NoCheat plugin) {
|
||||
this.action = new ActionExecutor(plugin);
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@ -128,7 +124,7 @@ public class MorePacketsCheck {
|
||||
ldata.check = "moving/morepackets";
|
||||
|
||||
boolean cancel = false;
|
||||
cancel = action.executeActions(player, cc.moving.morePacketsActions, (int) data.morePacketsViolationLevel, ldata, cc);
|
||||
cancel = plugin.getActionManager().executeActions(player, cc.moving.morePacketsActions, (int) data.morePacketsViolationLevel, ldata, data.history, cc);
|
||||
|
||||
// Only do the cancel if the player didn't change worlds
|
||||
// inbetween
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutor;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.MovingData;
|
||||
@ -18,12 +17,10 @@ import cc.co.evenprime.bukkit.nocheat.data.MovingData;
|
||||
*/
|
||||
public class NoFallCheck {
|
||||
|
||||
private final ActionExecutor action;
|
||||
private final NoCheat plugin;
|
||||
|
||||
public NoFallCheck(NoCheat plugin) {
|
||||
this.plugin = plugin;
|
||||
this.action = new ActionExecutor(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +38,8 @@ public class NoFallCheck {
|
||||
data.fallDistance = 0F;
|
||||
}
|
||||
|
||||
// If we increased fall height before for no good reason, reduce now by the same amount
|
||||
// If we increased fall height before for no good reason, reduce now by
|
||||
// the same amount
|
||||
if(player.getFallDistance() > data.lastAddedFallDistance) {
|
||||
player.setFallDistance(player.getFallDistance() - data.lastAddedFallDistance);
|
||||
}
|
||||
@ -60,9 +58,10 @@ public class NoFallCheck {
|
||||
ldata.falldistance = data.fallDistance;
|
||||
ldata.check = "moving/nofall";
|
||||
|
||||
boolean cancel = action.executeActions(player, cc.moving.nofallActions, (int) data.nofallViolationLevel, ldata, cc);
|
||||
boolean cancel = plugin.getActionManager().executeActions(player, cc.moving.nofallActions, (int) data.nofallViolationLevel, ldata, data.history, cc);
|
||||
|
||||
// If "cancelled", the fall damage gets dealt in a way that's visible to other plugins
|
||||
// If "cancelled", the fall damage gets dealt in a way that's
|
||||
// visible to other plugins
|
||||
if(cancel) {
|
||||
// Increase the fall distance a bit :)
|
||||
float totalDistance = data.fallDistance + difference * (cc.moving.nofallMultiplier - 1.0F);
|
||||
@ -73,10 +72,14 @@ public class NoFallCheck {
|
||||
data.fallDistance = 0F;
|
||||
}
|
||||
|
||||
// Increase the fall distance that is recorded by the plugin, AND set the fall distance of the player
|
||||
// to whatever he would get with this move event. This modifies Minecrafts fall damage calculation
|
||||
// slightly, but that's still better than ignoring players that try to use "teleports" or "stepdown"
|
||||
// to avoid falldamage. It is only added for big height differences anyway, as to avoid to much deviation
|
||||
// Increase the fall distance that is recorded by the plugin, AND set
|
||||
// the fall distance of the player
|
||||
// to whatever he would get with this move event. This modifies
|
||||
// Minecrafts fall damage calculation
|
||||
// slightly, but that's still better than ignoring players that try to
|
||||
// use "teleports" or "stepdown"
|
||||
// to avoid falldamage. It is only added for big height differences
|
||||
// anyway, as to avoid to much deviation
|
||||
// from the original Minecraft feeling.
|
||||
if(oldY > newY) {
|
||||
float dist = (float) (oldY - newY);
|
||||
@ -85,12 +88,10 @@ public class NoFallCheck {
|
||||
if(dist > 1.0F) {
|
||||
data.lastAddedFallDistance = dist;
|
||||
player.setFallDistance(player.getFallDistance() + dist);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
data.lastAddedFallDistance = 0.0F;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
data.lastAddedFallDistance = 0.0F;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutor;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.Permissions;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
@ -28,14 +27,12 @@ public class RunningCheck {
|
||||
// lose altitude (or eventually land somewhere)
|
||||
private final static int jumpingLimit = 6;
|
||||
|
||||
private final ActionExecutor action;
|
||||
private final NoCheat plugin;
|
||||
|
||||
private final NoFallCheck noFallCheck;
|
||||
|
||||
public RunningCheck(NoCheat plugin, NoFallCheck noFallCheck) {
|
||||
this.plugin = plugin;
|
||||
this.action = new ActionExecutor(plugin);
|
||||
this.noFallCheck = noFallCheck;
|
||||
}
|
||||
|
||||
@ -86,7 +83,7 @@ public class RunningCheck {
|
||||
else if(resultVert > 0)
|
||||
ldata.check = "runfly/vertical";
|
||||
|
||||
boolean cancel = action.executeActions(player, cc.moving.actions, (int) data.runflyViolationLevel, ldata, cc);
|
||||
boolean cancel = plugin.getActionManager().executeActions(player, cc.moving.actions, (int) data.runflyViolationLevel, ldata, data.history, cc);
|
||||
|
||||
// Was one of the actions a cancel? Then do it
|
||||
if(cancel) {
|
||||
|
@ -3,8 +3,9 @@ package cc.co.evenprime.bukkit.nocheat.config;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.OptionNode.DataType;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.OptionNode;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.OptionNode.DataType;
|
||||
import cc.co.evenprime.bukkit.nocheat.log.LogLevel;
|
||||
|
||||
/**
|
||||
@ -100,8 +101,6 @@ public abstract class Configuration {
|
||||
public static final OptionNode FIGHT_DIRECTION_PENALTYTIME = new OptionNode("penaltytime", FIGHT_DIRECTION, DataType.INTEGER);
|
||||
public final static OptionNode FIGHT_DIRECTION_ACTIONS = new OptionNode("actions", FIGHT_DIRECTION, DataType.ACTIONLIST);
|
||||
|
||||
|
||||
|
||||
private final Map<OptionNode, Object> values;
|
||||
private final Configuration defaults;
|
||||
|
||||
|
@ -16,6 +16,7 @@ import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionMapper;
|
||||
|
||||
/**
|
||||
* Central location for everything that's described in the configuration file(s)
|
||||
|
@ -5,7 +5,8 @@ import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionMapper;
|
||||
import cc.co.evenprime.bukkit.nocheat.log.LogLevel;
|
||||
|
||||
/**
|
||||
|
@ -3,6 +3,8 @@ package cc.co.evenprime.bukkit.nocheat.config;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.OptionNode;
|
||||
|
||||
/**
|
||||
* Textual explainations of options, will be displayed in the gui tool and the
|
||||
* descriptions.txt file.
|
||||
|
@ -12,6 +12,7 @@ import cc.co.evenprime.bukkit.nocheat.actions.types.Action;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.ConsolecommandAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.LogAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.SpecialAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionMapper;
|
||||
import cc.co.evenprime.bukkit.nocheat.log.LogLevel;
|
||||
|
||||
public class FlatFileAction {
|
||||
|
@ -8,8 +8,10 @@ import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.Action;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionMapper;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.OptionNode;
|
||||
import cc.co.evenprime.bukkit.nocheat.log.LogLevel;
|
||||
|
||||
public class FlatFileConfiguration extends Configuration {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.config.cache;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
||||
|
||||
/**
|
||||
* Configurations specific for the "BlockBreak" checks
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.config.cache;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.config.cache;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
||||
|
||||
public class CCChat {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.config.cache;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
||||
|
||||
public class CCFight {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.config.cache;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
||||
|
||||
/**
|
||||
* Configurations specific for the Move Checks. Every world gets one of these
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.actions;
|
||||
package cc.co.evenprime.bukkit.nocheat.config.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
@ -1,4 +1,4 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.config;
|
||||
package cc.co.evenprime.bukkit.nocheat.config.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
@ -1,4 +1,4 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.config;
|
||||
package cc.co.evenprime.bukkit.nocheat.config.util;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
@ -1,4 +1,4 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.actions.history;
|
||||
package cc.co.evenprime.bukkit.nocheat.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -11,7 +11,7 @@ import cc.co.evenprime.bukkit.nocheat.actions.types.Action;
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class ActionHistory {
|
||||
public class ActionData {
|
||||
|
||||
private static class ExecutionHistoryEntry {
|
||||
|
||||
@ -83,9 +83,11 @@ public class ActionHistory {
|
||||
|
||||
// Store data between Events
|
||||
// time + action + action-counter
|
||||
private final Map<Action, ExecutionHistoryEntry> executionHistory = new HashMap<Action, ExecutionHistoryEntry>();
|
||||
private final Map<Action, ExecutionHistoryEntry> executionHistory;
|
||||
|
||||
public ActionHistory() {}
|
||||
public ActionData() {
|
||||
executionHistory = new HashMap<Action, ExecutionHistoryEntry>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if the action should be executed, because all time
|
@ -2,8 +2,7 @@ package cc.co.evenprime.bukkit.nocheat.data;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class BaseData {
|
||||
public class BaseData extends Data {
|
||||
|
||||
public final BlockBreakData blockbreak;
|
||||
public final BlockPlaceData blockplace;
|
||||
@ -16,7 +15,6 @@ public class BaseData {
|
||||
|
||||
private long removalTime;
|
||||
|
||||
|
||||
public BaseData() {
|
||||
this.blockbreak = new BlockBreakData();
|
||||
this.blockplace = new BlockPlaceData();
|
||||
@ -27,7 +25,8 @@ public class BaseData {
|
||||
|
||||
this.removalTime = 0;
|
||||
|
||||
data = new Data[] { this.blockbreak, this.blockplace, this.chat, this.log, this.moving, this.fight };
|
||||
data = new Data[] {this.blockbreak, this.blockplace, this.chat,
|
||||
this.log, this.moving, this.fight};
|
||||
}
|
||||
|
||||
public void clearCriticalData() {
|
||||
@ -46,11 +45,11 @@ public class BaseData {
|
||||
if(removal) {
|
||||
// 1 minute in the future
|
||||
this.removalTime = System.currentTimeMillis() + 60000;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.removalTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldBeRemoved() {
|
||||
return removalTime != 0 && removalTime < System.currentTimeMillis();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cc.co.evenprime.bukkit.nocheat.data;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
/**
|
||||
* Playerspecific data for the blockbreak check group
|
||||
*
|
||||
@ -14,5 +15,6 @@ public class BlockBreakData extends Data {
|
||||
public double directionViolationLevel = 0.0D;
|
||||
|
||||
public Location instaBrokeBlockLocation = null;
|
||||
public final ActionData history = new ActionData();
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.data;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Evenprime
|
||||
@ -9,4 +10,5 @@ public class BlockPlaceData extends Data {
|
||||
|
||||
public double onliquidViolationLevel = 0.0D;
|
||||
public double reachViolationLevel = 0.0D;
|
||||
public final ActionData history = new ActionData();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.data;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Evenprime
|
||||
@ -9,5 +10,6 @@ public class ChatData extends Data {
|
||||
|
||||
public int messageCount = 0;
|
||||
public int spamLasttime = 0;
|
||||
public final ActionData history = new ActionData();
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.data;
|
||||
|
||||
|
||||
public class FightData extends Data {
|
||||
|
||||
public double violationLevel = 0;
|
||||
public long directionLastViolationTime = 0;
|
||||
public final ActionData history = new ActionData();
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class LogData extends Data {
|
||||
|
||||
public void initialize(Player player) {
|
||||
this.player = player;
|
||||
check = "";
|
||||
toLocation = player.getLocation();
|
||||
this.check = "";
|
||||
this.toLocation = player.getLocation();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package cc.co.evenprime.bukkit.nocheat.data;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
/**
|
||||
* Player specific data for the moving check group
|
||||
*/
|
||||
@ -36,6 +37,8 @@ public class MovingData extends Data {
|
||||
|
||||
public int lastElapsedIngameSeconds;
|
||||
|
||||
public final ActionData history = new ActionData();
|
||||
|
||||
@Override
|
||||
public void initialize(Player player) {
|
||||
runflySetBackPoint = player.getLocation();
|
||||
|
Loading…
Reference in New Issue
Block a user