Add configuration for ender-pearl checks to the combined section.

This commit is contained in:
asofold 2013-05-03 11:13:53 +02:00
parent 3e96d7d9a2
commit 384c3483ca
6 changed files with 28 additions and 4 deletions

View File

@ -14,6 +14,7 @@ import org.bukkit.inventory.ItemStack;
import fr.neatmonster.nocheatplus.checks.CheckListener;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
/*
@ -90,7 +91,10 @@ public class BlockInteractListener extends CheckListener {
final ItemStack stack = player.getItemInHand();
if (stack != null && stack.getTypeId() == Material.ENDER_PEARL.getId()){
if (!BlockProperties.isPassable(block.getTypeId())){
event.setUseItemInHand(Result.DENY);
final CombinedConfig ccc = CombinedConfig.getConfig(player);
if (ccc.enderPearlCheck && ccc.enderPearlPreventClickBlock){
event.setUseItemInHand(Result.DENY);
}
}
}
break;

View File

@ -21,6 +21,7 @@ import org.bukkit.inventory.ItemStack;
import fr.neatmonster.nocheatplus.checks.CheckListener;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.combined.Combined;
import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig;
import fr.neatmonster.nocheatplus.checks.combined.Improbable;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
@ -326,7 +327,11 @@ public class BlockPlaceListener extends CheckListener {
// Ender pearl glitch (ab-) use.
if (!cancel && type == EntityType.ENDER_PEARL){
if (!BlockProperties.isPassable(entity.getLocation())){
if (!CombinedConfig.getConfig(player).enderPearlCheck){
// Do nothing !
// TODO: Might have further flags?
}
else if (!BlockProperties.isPassable(entity.getLocation())){
// Launch into a block.
// TODO: This might be a general check later.
cancel = true;

View File

@ -34,7 +34,7 @@ public class CombinedConfig extends ACheckConfig {
private static final Map<String, CombinedConfig> worldsMap = new HashMap<String, CombinedConfig>();
protected static CombinedConfig getConfig(final Player player) {
public static CombinedConfig getConfig(final Player player) {
final String worldName = player.getWorld().getName();
CombinedConfig cc = worldsMap.get(worldName);
if (cc == null){
@ -48,6 +48,10 @@ public class CombinedConfig extends ACheckConfig {
// Bedleave check.
public final boolean bedLeaveCheck;
public final ActionList bedLeaveActions;
// Ender pearl
public final boolean enderPearlCheck;
public final boolean enderPearlPreventClickBlock;
// Improbable check
/** Do mind that this flag is not used by all components. */
@ -80,6 +84,9 @@ public class CombinedConfig extends ACheckConfig {
bedLeaveCheck = config.getBoolean(ConfPaths.COMBINED_BEDLEAVE_CHECK);
bedLeaveActions = config.getOptimizedActionList(ConfPaths.COMBINED_BEDLEAVE_ACTIONS, Permissions.COMBINED_BEDLEAVE);
enderPearlCheck = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_CHECK);
enderPearlPreventClickBlock = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_PREVENTCLICKBLOCK);
improbableCheck = config.getBoolean(ConfPaths.COMBINED_IMPROBABLE_CHECK);
improbableLevel = (float) config.getDouble(ConfPaths.COMBINED_IMPROBABLE_LEVEL);
improbableActions = config.getOptimizedActionList(ConfPaths.COMBINED_IMPROBABLE_ACTIONS, Permissions.COMBINED_IMPROBABLE);

View File

@ -43,6 +43,7 @@ import fr.neatmonster.nocheatplus.checks.CheckListener;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.combined.BedLeave;
import fr.neatmonster.nocheatplus.checks.combined.Combined;
import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig;
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
import fr.neatmonster.nocheatplus.command.INotifyReload;
import fr.neatmonster.nocheatplus.components.IData;
@ -903,7 +904,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
}
}
else if (cause == TeleportCause.ENDER_PEARL){
if (!BlockProperties.isPassable(to)){ // || !BlockProperties.isOnGroundOrResetCond(player, to, 1.0)){
if (CombinedConfig.getConfig(player). enderPearlCheck && !BlockProperties.isPassable(to)){ // || !BlockProperties.isOnGroundOrResetCond(player, to, 1.0)){
// Not check on-ground: Check the second throw.
cancel = true;
}

View File

@ -338,6 +338,10 @@ public abstract class ConfPaths {
public static final String COMBINED_BEDLEAVE_CHECK = COMBINED_BEDLEAVE + "active";
public static final String COMBINED_BEDLEAVE_ACTIONS = COMBINED_BEDLEAVE + "actions";
private static final String COMBINED_ENDERPEARL = COMBINED + "enderpearl.";
public static final String COMBINED_ENDERPEARL_CHECK = COMBINED_ENDERPEARL + "active";
public static final String COMBINED_ENDERPEARL_PREVENTCLICKBLOCK = COMBINED_ENDERPEARL + "preventclickblock";
private static final String COMBINED_IMPROBABLE = COMBINED + "improbable.";
public static final String COMBINED_IMPROBABLE_CHECK = COMBINED_IMPROBABLE + "active";
public static final String COMBINED_IMPROBABLE_LEVEL = COMBINED_IMPROBABLE + "level";

View File

@ -266,6 +266,9 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.COMBINED_BEDLEAVE_CHECK, true);
set(ConfPaths.COMBINED_BEDLEAVE_ACTIONS, "cancel log:bedleave:0:5:if cmd:kickbedleave");
set(ConfPaths.COMBINED_ENDERPEARL_CHECK, true);
set(ConfPaths.COMBINED_ENDERPEARL_PREVENTCLICKBLOCK, true);
set(ConfPaths.COMBINED_IMPROBABLE_CHECK , true);
set(ConfPaths.COMBINED_IMPROBABLE_LEVEL, 300);
// set(ConfPaths.COMBINED_IMPROBABLE_FASTBREAK_CHECK, false);