mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-10-06 18:37:29 +02:00
Removed player interact infinite durability check, as the exploit is
now fixed by bukkit itself.
This commit is contained in:
parent
a8342b0681
commit
e93f501271
@ -57,11 +57,6 @@ permissions:
|
||||
description: Allow a player to place blocks at maximum range (about 6-7 blocks)
|
||||
nocheat.checks.blockplace.onliquid:
|
||||
description: Allow a player to place non-liquid blocks on liquids
|
||||
nocheat.checks.interact:
|
||||
description: Allow the player to bypass all interact checks
|
||||
children:
|
||||
nocheat.checks.interact.durability:
|
||||
description: Allow a player to use an infinite durability item hack
|
||||
nocheat.checks.chat:
|
||||
description: Allow the player to bypass all chat checks
|
||||
children:
|
||||
|
@ -22,7 +22,6 @@ import cc.co.evenprime.bukkit.nocheat.events.BlockPlaceEventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.BlockBreakEventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.EventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.PlayerChatEventManager;
|
||||
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;
|
||||
@ -85,7 +84,6 @@ public class NoCheat extends JavaPlugin {
|
||||
|
||||
eventManagers.add(new PlayerMoveEventManager(this));
|
||||
eventManagers.add(new PlayerTeleportEventManager(this));
|
||||
eventManagers.add(new PlayerInteractEventManager(this));
|
||||
eventManagers.add(new PlayerChatEventManager(this));
|
||||
eventManagers.add(new BlockBreakEventManager(this));
|
||||
eventManagers.add(new BlockPlaceEventManager(this));
|
||||
|
@ -1,51 +0,0 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.checks.interact;
|
||||
|
||||
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.InteractData;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.LogData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class InteractCheck {
|
||||
|
||||
private final NoCheat plugin;
|
||||
private final ActionExecutor action;
|
||||
|
||||
public InteractCheck(NoCheat plugin) {
|
||||
this.plugin = plugin;
|
||||
action = new ActionExecutor(plugin);
|
||||
}
|
||||
|
||||
public boolean check(Player player, InteractData data, ConfigurationCache cc) {
|
||||
|
||||
boolean cancel = false;
|
||||
|
||||
final boolean durability = cc.interact.durabilityCheck && !player.hasPermission(Permissions.INTERACT_DURABILITY);
|
||||
|
||||
if(durability) {
|
||||
// It's so simple, I'll just do the check in place
|
||||
if(player.getInventory().getHeldItemSlot() == 9) {
|
||||
|
||||
data.violationLevel += 1;
|
||||
|
||||
LogData ldata = plugin.getDataManager().getLogData(player);
|
||||
ldata.check = "interact.durability";
|
||||
|
||||
cancel = action.executeActions(player, cc.interact.durabilityActions, (int) data.violationLevel, ldata, cc);
|
||||
}
|
||||
|
||||
data.violationLevel *= 0.95D; // Reduce level over time
|
||||
}
|
||||
|
||||
return cancel;
|
||||
}
|
||||
|
||||
}
|
@ -82,13 +82,6 @@ public abstract class Configuration {
|
||||
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 INTERACT = new OptionNode("interact", ROOT, DataType.PARENT);
|
||||
public final static OptionNode INTERACT_CHECK = new OptionNode("check", INTERACT, DataType.BOOLEAN);
|
||||
|
||||
public final static OptionNode INTERACT_DURABILITY = new OptionNode("durability", INTERACT, DataType.PARENT);
|
||||
public final static OptionNode INTERACT_DURABILITY_CHECK = new OptionNode("check", INTERACT_DURABILITY, DataType.BOOLEAN);
|
||||
public final static OptionNode INTERACT_DURABILITY_ACTIONS = new OptionNode("actions", INTERACT_DURABILITY, DataType.ACTIONLIST);
|
||||
|
||||
public final static OptionNode CHAT = new OptionNode("chat", ROOT, DataType.PARENT);
|
||||
public final static OptionNode CHAT_CHECK = new OptionNode("check", CHAT, DataType.BOOLEAN);
|
||||
|
||||
|
@ -124,17 +124,6 @@ public class DefaultConfiguration extends Configuration {
|
||||
|
||||
}
|
||||
|
||||
/*** INTERACT ***/
|
||||
{
|
||||
setValue(INTERACT_CHECK, true);
|
||||
setValue(INTERACT_DURABILITY_CHECK, true);
|
||||
|
||||
ActionList infiniteDurabilityActionList = new ActionList();
|
||||
infiniteDurabilityActionList.setActions(0, action.getActions("durabilityLog interactCancel".split(" ")));
|
||||
setValue(INTERACT_DURABILITY_ACTIONS, infiniteDurabilityActionList);
|
||||
|
||||
}
|
||||
|
||||
/*** CHAT ***/
|
||||
{
|
||||
setValue(CHAT_CHECK, true);
|
||||
@ -224,7 +213,6 @@ public class DefaultConfiguration extends Configuration {
|
||||
w(w, "# Some other log messages that are limited a bit by default, to avoid too extreme spam");
|
||||
w(w, "log reachLog 0 1 med NC: [player] failed [check]: tried to interact with a block over distance [reachdistance].");
|
||||
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, "log onliquidLog 2 1 med NC: [player] failed [check]: tried to place a [blocktype] block at [placelocation] against block at [placeagainst].");
|
||||
w(w, "log spamLog 0 4 med NC: [player] failed [check]: Last sent message \"[text]\".");
|
||||
w(w, "log nofallLog 0 1 med NC: [player] failed [check]: tried to avoid fall damage for ~[falldistance] blocks.");
|
||||
@ -240,7 +228,6 @@ public class DefaultConfiguration extends Configuration {
|
||||
w(w, "special moveCancel 0 0");
|
||||
w(w, "special blockbreakCancel 0 0");
|
||||
w(w, "special blockplaceCancel 0 0");
|
||||
w(w, "special interactCancel 0 0");
|
||||
w(w, "special spamCancel 0 0");
|
||||
w(w, "special nofallDamage 0 0");
|
||||
w(w, "");
|
||||
|
@ -3,7 +3,6 @@ package cc.co.evenprime.bukkit.nocheat.config;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Textual explainations of options, will be displayed in the gui tool and the
|
||||
* descriptions.txt file.
|
||||
@ -25,7 +24,7 @@ public class Explainations {
|
||||
set(Configuration.LOGGING_CHATLEVEL, "What log-level need messages to have to get displayed in the ingame chat. Values are:\n low: all messages\n med: med and high messages only\n high: high messages only\n off: no messages at all.");
|
||||
|
||||
set(Configuration.DEBUG_SHOWACTIVECHECKS, "Print to the console an overview of all checks that are enabled when NoCheat gets loaded.");
|
||||
|
||||
|
||||
set(Configuration.MOVING_CHECK, "If true, do various checks on PlayerMove events.");
|
||||
set(Configuration.MOVING_IDENTIFYCREATIVEMODE, "If true, NoCheat will automatically identify if players are in creative mode and will allow them to fly, avoid fall damage etc.");
|
||||
|
||||
@ -42,13 +41,12 @@ public class Explainations {
|
||||
set(Configuration.MOVING_RUNFLY_CHECKNOFALL, "If true, check if a player is avoiding fall damage by using a nofall hack. EXPERIMENTAL! Feedback is appreciated.");
|
||||
set(Configuration.MOVING_RUNFLY_NOFALLMULTIPLIER, "How many percent falldamage should be dealt to the player.\nNoCheat will almost always underestimate fall damage, using a value bigger than 100 is advised.\nUnit is percent of the estimated original fall damage, default is 200.");
|
||||
set(Configuration.MOVING_RUNFLY_NOFALLACTIONS, "What should be done if a player is detected as avoiding fall damage.\nUnit is number of blocks the player fell down.");
|
||||
|
||||
|
||||
set(Configuration.MOVING_RUNFLY_ALLOWLIMITEDFLYING, "If true, instead of doing the above checks for walking/sprinting/swimming/sneaking,\nallow flying and only limit the flying speed.");
|
||||
set(Configuration.MOVING_RUNFLY_FLYINGSPEEDLIMITVERTICAL, "Set the speed limit for moving vertical while flying.\nUnit is 1/100 of a block, default is 100.");
|
||||
set(Configuration.MOVING_RUNFLY_FLYINGSPEEDLIMITHORIZONTAL, "Set the speed limit for moving horizontal while flying.\nUnit is 1/100 of a block, default is 60.");
|
||||
set(Configuration.MOVING_RUNFLY_FLYINGACTIONS, "What should be done if a player flies faster than the speed limit(s). \nUnits are in 1/100 of a block above the speedlimit.");
|
||||
|
||||
|
||||
|
||||
set(Configuration.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(Configuration.MOVING_MOREPACKETS_ACTIONS, "What should be done if a player sends more 'move-packets' than normal.\nUnits are packets per second above the limit.");
|
||||
|
||||
@ -61,7 +59,7 @@ public class Explainations {
|
||||
set(Configuration.BLOCKBREAK_DIRECTION_CHECK, "If true, check if a player is looking at the block that he's breaking.");
|
||||
set(Configuration.BLOCKBREAK_DIRECTION_CHECKINSTABREAKBLOCKS, "If true, NoCheat will also check for direction for Instant-Breaking blocks.\nTHIS WILL CAUSE FALSE POSITIVES, when a player keeps his mouse button pressed and moves the mouse fast over the screen.");
|
||||
set(Configuration.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(Configuration.BLOCKPLACE_CHECK, "If true, do various checks on BlockPlace events.");
|
||||
|
||||
set(Configuration.BLOCKPLACE_REACH_CHECK, "If true, check if a player is placing blocks at locations too far away.");
|
||||
@ -70,11 +68,6 @@ public class Explainations {
|
||||
|
||||
set(Configuration.BLOCKPLACE_ONLIQUID_CHECK, "If true, check if a player is trying to place non-liquid blocks against liquid blocks\nIn a normal Minecraft game, it is impossible to place a block without it touching something that is considered solid (neither air nor a liquid).\nBut if people use a modified client, to can do that. This check tries to identify that trick.");
|
||||
set(Configuration.BLOCKPLACE_ONLIQUID_ACTIONS, "What should be done if a player is is trying to place non-liquid blocks against liquid blocks.\nUnit is number of place(attempt)s.");
|
||||
|
||||
set(Configuration.INTERACT_CHECK, "If true, do various checks on PlayerInteract events.");
|
||||
|
||||
set(Configuration.INTERACT_DURABILITY_CHECK, "If true, check if a player is using a hack that provides infinite durability items.");
|
||||
set(Configuration.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.");
|
||||
|
||||
set(Configuration.CHAT_CHECK, "If true, do various checks on PlayerChat events.");
|
||||
|
||||
|
@ -24,9 +24,6 @@ public class Permissions {
|
||||
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 INTERACT_DURABILITY = INTERACT + ".durability";
|
||||
|
||||
public final static String BLOCKPLACE = CHECKS + ".blockplace";
|
||||
public final static String BLOCKPLACE_ONLIQUID = BLOCKPLACE + ".onliquid";
|
||||
public final static String BLOCKPLACE_REACH = BLOCKPLACE + ".reach";
|
||||
|
@ -1,25 +0,0 @@
|
||||
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.DefaultConfiguration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class CCInteract {
|
||||
|
||||
public final boolean check;
|
||||
|
||||
public final boolean durabilityCheck;
|
||||
public final ActionList durabilityActions;
|
||||
|
||||
public CCInteract(Configuration data) {
|
||||
|
||||
check = data.getBoolean(DefaultConfiguration.INTERACT_CHECK);
|
||||
durabilityCheck = data.getBoolean(DefaultConfiguration.INTERACT_DURABILITY_CHECK);
|
||||
durabilityActions = data.getActionList(DefaultConfiguration.INTERACT_DURABILITY_ACTIONS);
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ public class ConfigurationCache {
|
||||
public final CCMoving moving;
|
||||
public final CCLogging logging;
|
||||
public final CCBlockBreak blockbreak;
|
||||
public final CCInteract interact;
|
||||
public final CCBlockPlace blockplace;
|
||||
public final CCChat chat;
|
||||
public final CCDebug debug;
|
||||
@ -32,7 +31,6 @@ public class ConfigurationCache {
|
||||
moving = new CCMoving(data);
|
||||
blockbreak = new CCBlockBreak(data);
|
||||
blockplace = new CCBlockPlace(data);
|
||||
interact = new CCInteract(data);
|
||||
chat = new CCChat(data);
|
||||
logging = new CCLogging(data, worldSpecificFileLogger);
|
||||
debug = new CCDebug(data);
|
||||
|
@ -17,7 +17,6 @@ public class DataManager {
|
||||
// Store data between Events
|
||||
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>();
|
||||
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>();
|
||||
@ -58,21 +57,6 @@ 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;
|
||||
}
|
||||
|
||||
public BlockPlaceData getBlockPlaceData(Player player) {
|
||||
BlockPlaceData data;
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.data;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class InteractData {
|
||||
|
||||
public double violationLevel = 0.0D;
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.events;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
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.checks.interact.InteractCheck;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.Permissions;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.InteractData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class PlayerInteractEventManager extends PlayerListener implements EventManager {
|
||||
|
||||
private final NoCheat plugin;
|
||||
private final InteractCheck interactCheck;
|
||||
|
||||
public PlayerInteractEventManager(NoCheat plugin) {
|
||||
|
||||
this.plugin = plugin;
|
||||
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 = plugin.getConfigurationManager().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 = plugin.getDataManager().getInteractData(player);
|
||||
|
||||
cancel = interactCheck.check(player, data, cc);
|
||||
|
||||
if(cancel) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
||||
if(cc.interact.check && cc.interact.durabilityCheck)
|
||||
s.add("interact.durability");
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
||||
if(!(cc.interact.check && cc.interact.durabilityCheck))
|
||||
s.add("interact.durability");
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user