mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-28 03:17:53 +01:00
Added infinite durability hack check
Deactivated parts of the NoClip check, until I can work on it
This commit is contained in:
parent
92620c4fd4
commit
848d2b3623
14
plugin.yml
14
plugin.yml
@ -3,7 +3,7 @@ name: NoCheat
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||
version: 2.00
|
||||
version: 2.00a
|
||||
|
||||
permissions:
|
||||
|
||||
@ -18,6 +18,7 @@ permissions:
|
||||
children:
|
||||
nocheat.checks.moving.*: true
|
||||
nocheat.checks.blockbreak.*: true
|
||||
nocheat.checks.interact.*: true
|
||||
|
||||
nocheat.checks.moving.*:
|
||||
description: Allow the player to bypass all moving checks
|
||||
@ -35,8 +36,13 @@ permissions:
|
||||
nocheat.checks.blockbreak.reach: true
|
||||
nocheat.checks.blockbreak.direction: true
|
||||
|
||||
nocheat.checks.interact.*:
|
||||
description: Allow the player to bypass all interact checks
|
||||
children:
|
||||
nocheat.checks.interact.durability: true
|
||||
|
||||
nocheat.checks.moving.flying:
|
||||
description: Allow a player to move free through the air (implicitly deactivates the "running" check)
|
||||
description: Allow a player to move free through the air (if given, the "running" check will be ignored anyway)
|
||||
default: op
|
||||
nocheat.checks.moving.running:
|
||||
description: Allow a player to move free, only limited by the flying check, if active (implicitly deactivates the "swimming" and "sneaking" check)
|
||||
@ -60,6 +66,10 @@ permissions:
|
||||
nocheat.checks.blockbreak.direction:
|
||||
description: Allow a player to break blocks that are not in front of them
|
||||
default: op
|
||||
|
||||
nocheat.checks.interact.durability:
|
||||
description: Allow a player to use an infinite durability item hack
|
||||
default: op
|
||||
|
||||
nocheat.admin.*:
|
||||
description: Give a player all admin rights
|
||||
|
@ -126,12 +126,12 @@ public class DefaultConfiguration {
|
||||
ParentOption noclipNode = new ParentOption("noclip");
|
||||
movingNode.add(noclipNode);
|
||||
|
||||
noclipNode.add(new BooleanOption("check", true, true));
|
||||
noclipNode.add(new BooleanOption("check", false, true));
|
||||
ActionListOption actions = new ActionListOption("actions");
|
||||
|
||||
noclipNode.add(actions);
|
||||
|
||||
actions.add(1, "noclipLog moveCancel");
|
||||
actions.add(1, "noclipLog");
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,6 +171,28 @@ public class DefaultConfiguration {
|
||||
actions.add(0, "directionLog blockbreakCancel");
|
||||
}
|
||||
}
|
||||
|
||||
/****** INTERACT ******/
|
||||
{
|
||||
ParentOption interactNode = new ParentOption("interact");
|
||||
root.add(interactNode);
|
||||
|
||||
interactNode.add(new BooleanOption("check", true, true));
|
||||
|
||||
/**** BLOCKBREAK.REACH ****/
|
||||
{
|
||||
ParentOption durabilityNode = new ParentOption("durability");
|
||||
interactNode.add(durabilityNode);
|
||||
|
||||
durabilityNode.add(new BooleanOption("check", true, true));
|
||||
|
||||
ActionListOption actions = new ActionListOption("actions");
|
||||
|
||||
durabilityNode.add(actions);
|
||||
|
||||
actions.add(0, "durabilityLog interactCancel");
|
||||
}
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
@ -238,6 +260,7 @@ public class DefaultConfiguration {
|
||||
w(w, "log noclipLog 0 1 high NC: [player] failed [check]: at [location] to [locationto].");
|
||||
w(w, "log reachLog 0 1 med NC: [player] failed [check]: tried to destroy a block over distance [distance].");
|
||||
w(w, "log directionLog 2 1 med NC: [player] failed [check]: tried to destroy a block out of line of sight.");
|
||||
w(w, "log durabilityLog 0 1 med NC: [player] failed [check]: tried to use infinity durability hack.");
|
||||
w(w, "");
|
||||
w(w, "# SPECIAL Actions: They will do something check dependant, usually cancel an event.");
|
||||
w(w, "# - They start with the word 'special'");
|
||||
@ -249,6 +272,7 @@ public class DefaultConfiguration {
|
||||
w(w, "# Cancels the event in case of an violation. Always. No delay. These are equivalent. The different names are just for better readability");
|
||||
w(w, "special moveCancel 0 0");
|
||||
w(w, "special blockbreakCancel 0 0");
|
||||
w(w, "special interactCancel 0 0");
|
||||
w(w, "");
|
||||
w(w, "# CONSOLECOMMAND Actions: They will execute a command as if it were typed into the console.");
|
||||
w(w, "# - They start with the word 'consolecommand'");
|
||||
|
@ -41,7 +41,7 @@ public class Explainations {
|
||||
set("moving.morepackets.check", "If true, check if a player is sending too many 'move-packets' per second. In a normal game, the player won't send more than 22 packets per second.");
|
||||
set("moving.morepackets.actions", "What should be done if a player sends more 'move-packets' than normal.\nUnits are packets per second above the limit.");
|
||||
|
||||
set("moving.noclip.check", "If true, check if a player is moving into a solid wall. EXPERIMENTAL!");
|
||||
set("moving.noclip.check", "If true, check if a player is moving into a solid wall. EXPERIMENTAL! DOESN'T WORK RELIABLY! USE WITH CAUTION AND ONLY FOR NOTIFICATIONS!");
|
||||
set("moving.noclip.actions", "What should be done if a player moves into a wall.\nUnit is number of walls a player walks into/through.");
|
||||
|
||||
set("blockbreak.check", "If true, do various checks on PlayerInteract events.");
|
||||
@ -52,6 +52,9 @@ public class Explainations {
|
||||
|
||||
set("blockbreak.direction.check", "If true, check if a player is looking at the block that he's breaking.");
|
||||
set("blockbreak.direction.actions", "What should be done if a player is breaking blocks that are not in his line of sight.\nUnit is number of break(attempt)s outside the line of sight.");
|
||||
|
||||
set("interact.durability.check", "If true, check if a player is using a hack that provides infinite durability items.");
|
||||
set("interact.durability.actions", "What should be done if a player is trying to use the hack.\nUnit is number of uses or attempts to use the hack.");
|
||||
}
|
||||
|
||||
private static void set(String id, String text) {
|
||||
|
@ -9,6 +9,7 @@ import cc.co.evenprime.bukkit.nocheat.data.DataManager;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.events.BlockPlaceEventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.BlockBreakEventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.PlayerInteractEventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.PlayerMoveEventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.PlayerTeleportEventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.log.LogLevel;
|
||||
@ -32,6 +33,7 @@ public class NoCheat extends JavaPlugin {
|
||||
private PlayerMoveEventManager eventPlayerMoveManager;
|
||||
private PlayerTeleportEventManager eventPlayerTeleportManager;
|
||||
private BlockBreakEventManager eventBlockBreakManager;
|
||||
private PlayerInteractEventManager eventPlayerInteractManager;
|
||||
|
||||
private BlockPlaceEventManager eventBlockPlaceManager;
|
||||
|
||||
@ -64,6 +66,7 @@ public class NoCheat extends JavaPlugin {
|
||||
eventPlayerMoveManager = new PlayerMoveEventManager(this);
|
||||
eventPlayerTeleportManager = new PlayerTeleportEventManager(this);
|
||||
eventBlockBreakManager = new BlockBreakEventManager(this);
|
||||
eventPlayerInteractManager = new PlayerInteractEventManager(this);
|
||||
|
||||
eventBlockPlaceManager = new BlockPlaceEventManager(this);
|
||||
|
||||
|
@ -12,6 +12,7 @@ public class Permissions {
|
||||
private final static String _CHECKS = _NOCHEAT + ".checks";
|
||||
private final static String _MOVE = _CHECKS + ".moving";
|
||||
private final static String _BLOCKBREAK = _CHECKS + ".blockbreak";
|
||||
public final static String _INTERACT = _CHECKS + ".interact";
|
||||
|
||||
public final static String MOVE = _CHECKS + ".moving.*";
|
||||
public final static String MOVE_FLY = _MOVE + ".flying";
|
||||
@ -21,10 +22,13 @@ public class Permissions {
|
||||
public final static String MOVE_NOCLIP = _MOVE + ".noclip";
|
||||
public final static String MOVE_MOREPACKETS = _MOVE + ".morepackets";
|
||||
|
||||
public static final String BLOCKBREAK = _CHECKS + ".blockbreak.*";
|
||||
public final static String BLOCKBREAK = _CHECKS + ".blockbreak.*";
|
||||
public final static String BLOCKBREAK_REACH = _BLOCKBREAK + ".reach";
|
||||
public final static String BLOCKBREAK_DIRECTION = _BLOCKBREAK + ".direction";
|
||||
|
||||
public final static String INTERACT = _CHECKS + ".interact.*";
|
||||
public final static String DURABILITY = _INTERACT + ".durability";
|
||||
|
||||
private final static String _ADMIN = _NOCHEAT + ".admin";
|
||||
|
||||
public final static String ADMIN_CHATLOG = _ADMIN + ".chatlog";
|
||||
|
@ -0,0 +1,51 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.checks.interact;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.Permissions;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutor;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutorWithHistory;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.LogAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.InteractData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class InteractCheck {
|
||||
|
||||
private final ActionExecutor action;
|
||||
|
||||
public InteractCheck(NoCheat plugin) {
|
||||
action = new ActionExecutorWithHistory(plugin);
|
||||
}
|
||||
|
||||
public boolean check(Player player, InteractData data, ConfigurationCache cc) {
|
||||
|
||||
boolean cancel = false;
|
||||
|
||||
final boolean durability = cc.moving.morePacketsCheck && !player.hasPermission(Permissions.DURABILITY);
|
||||
|
||||
if(durability) {
|
||||
// It's so simple, I'll just do the check in place
|
||||
if(player.getInventory().getHeldItemSlot() == 9) {
|
||||
|
||||
data.violationLevel += 1;
|
||||
HashMap<String, String> params = new HashMap<String, String>();
|
||||
params.put(LogAction.CHECK, "interact.durability");
|
||||
|
||||
cancel = action.executeActions(player, cc.interact.durabilityActions, (int) data.violationLevel, params, cc);
|
||||
}
|
||||
|
||||
data.violationLevel *= 0.95D; // Reduce level over time
|
||||
}
|
||||
|
||||
return cancel;
|
||||
}
|
||||
|
||||
}
|
@ -122,9 +122,12 @@ public class NoclipCheck {
|
||||
params.put(LogAction.CHECK, "noclip");
|
||||
|
||||
boolean cancelled = action.executeActions(player, cc.moving.noclipActions, violationLevel, params, cc);
|
||||
if(cancelled) {
|
||||
return new Location(from.getWorld(), data.noclipX + 0.5, data.noclipY - ((int) bodyHeight), data.noclipZ + 0.5, to.getPitch(), to.getYaw());
|
||||
}
|
||||
|
||||
// TODO: UNCOMMENT, WHEN THE CHECK WORKS RELIABLY
|
||||
|
||||
//if(cancelled) {
|
||||
// return new Location(from.getWorld(), data.noclipX + 0.5, data.noclipY - ((int) bodyHeight), data.noclipZ + 0.5, to.getPitch(), to.getYaw());
|
||||
//}
|
||||
}
|
||||
|
||||
// We didn't cancel the noclipping, so store the new location
|
||||
|
26
src/cc/co/evenprime/bukkit/nocheat/config/cache/CCInteract.java
vendored
Normal file
26
src/cc/co/evenprime/bukkit/nocheat/config/cache/CCInteract.java
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.config.cache;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class CCInteract {
|
||||
|
||||
public final boolean check;
|
||||
|
||||
public final boolean durabilityCheck;
|
||||
|
||||
public final ActionList durabilityActions;
|
||||
|
||||
public CCInteract(Configuration data) {
|
||||
|
||||
check = data.getBoolean("interact.check");
|
||||
durabilityCheck = data.getBoolean("interact.durability.check");
|
||||
durabilityActions = data.getActionList("interact.durability.actions");
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,7 @@ public class ConfigurationCache {
|
||||
public final CCMoving moving;
|
||||
public final CCLogging logging;
|
||||
public final CCBlockBreak blockbreak;
|
||||
public final CCInteract interact;
|
||||
|
||||
/**
|
||||
* Instantiate a config cache and populate it with the data of a
|
||||
@ -27,6 +28,8 @@ public class ConfigurationCache {
|
||||
|
||||
moving = new CCMoving(data);
|
||||
blockbreak = new CCBlockBreak(data);
|
||||
interact = new CCInteract(data);
|
||||
logging = new CCLogging(data, worldSpecificFileLogger);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.events.InteractData;
|
||||
|
||||
/**
|
||||
* Provide secure access to player-specific data objects for various checks or
|
||||
* check groups
|
||||
@ -15,8 +17,9 @@ import org.bukkit.entity.Player;
|
||||
public class DataManager {
|
||||
|
||||
// Store data between Events
|
||||
private final Map<Player, MovingData> movingData = new HashMap<Player, MovingData>();
|
||||
private final Map<Player, MovingData> movingData = new HashMap<Player, MovingData>();
|
||||
private final Map<Player, BlockBreakData> blockbreakData = new HashMap<Player, BlockBreakData>();
|
||||
private final Map<Player, InteractData> interactData = new HashMap<Player, InteractData>();
|
||||
|
||||
public DataManager() {
|
||||
|
||||
@ -53,4 +56,19 @@ public class DataManager {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public InteractData getInteractData(Player player) {
|
||||
InteractData data;
|
||||
|
||||
// intentionally not thread-safe, because bukkit events are handled
|
||||
// in sequence anyway, so zero chance of two events of the same
|
||||
// player being handled at the same time
|
||||
data = interactData.get(player);
|
||||
if(data == null) {
|
||||
data = new InteractData();
|
||||
interactData.put(player, data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
12
src/cc/co/evenprime/bukkit/nocheat/events/InteractData.java
Normal file
12
src/cc/co/evenprime/bukkit/nocheat/events/InteractData.java
Normal file
@ -0,0 +1,12 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.events;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class InteractData {
|
||||
|
||||
public double violationLevel = 0.0D;
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.events;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.Permissions;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.interact.InteractCheck;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.ConfigurationManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.DataManager;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class PlayerInteractEventManager extends PlayerListener {
|
||||
|
||||
private final InteractCheck interactCheck;
|
||||
private final DataManager data;
|
||||
private final ConfigurationManager config;
|
||||
|
||||
public PlayerInteractEventManager(NoCheat plugin) {
|
||||
|
||||
this.data = plugin.getDataManager();
|
||||
this.config = plugin.getConfigurationManager();
|
||||
this.interactCheck = new InteractCheck(plugin);
|
||||
|
||||
PluginManager pm = Bukkit.getServer().getPluginManager();
|
||||
|
||||
pm.registerEvent(Event.Type.PLAYER_INTERACT, this, Priority.Lowest, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
|
||||
if(event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final ConfigurationCache cc = config.getConfigurationCacheForWorld(player.getWorld().getName());
|
||||
|
||||
// Find out if checks need to be done for that player
|
||||
if(cc.interact.check && !player.hasPermission(Permissions.INTERACT)) {
|
||||
|
||||
boolean cancel = false;
|
||||
|
||||
// Get the player-specific stored data that applies here
|
||||
final InteractData data = this.data.getInteractData(player);
|
||||
|
||||
cancel = interactCheck.check(player, data, cc);
|
||||
|
||||
if(cancel) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user