From 84555c4e51f9cc4e615f479f128c1efc7b5177c9 Mon Sep 17 00:00:00 2001 From: asofold Date: Wed, 3 Oct 2012 17:47:29 +0200 Subject: [PATCH] Add triggers to combined.invulnerable to keep it more minimal. --- .../checks/combined/CombinedConfig.java | 4 ++++ .../checks/combined/CombinedListener.java | 4 ++-- .../nocheatplus/config/ConfPaths.java | 16 ++++++++++------ .../nocheatplus/config/DefaultConfig.java | 2 ++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java b/src/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java index 38193f0c..b965fb0b 100644 --- a/src/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java @@ -54,6 +54,8 @@ public class CombinedConfig extends ACheckConfig { public final Set invulnerableIgnore = new HashSet(); public final Map invulnerableModifiers = new HashMap(); public final int invulnerableModifierDefault; + public final boolean invulnerableTriggerAlways; + public final boolean invulnerableTriggerFallDistance; // Last yaw tracking public final float yawRate; @@ -98,6 +100,8 @@ public class CombinedConfig extends ACheckConfig { } invulnerableModifierDefault = defaultMod; if (error) CheckUtils.logInfo("[NoCheatPlus] Damage causes can be: " + CheckUtils.join(Arrays.asList(DamageCause.values()), ", ")); + invulnerableTriggerAlways = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_ALWAYS); + invulnerableTriggerFallDistance = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_FALLDISTANCE); yawRate = config.getInt(ConfPaths.COMBINED_YAWRATE_RATE); yawRateImprobable = config.getBoolean(ConfPaths.COMBINED_YAWRATE_IMPROBABLE); } diff --git a/src/fr/neatmonster/nocheatplus/checks/combined/CombinedListener.java b/src/fr/neatmonster/nocheatplus/checks/combined/CombinedListener.java index 12470510..df15d1fa 100644 --- a/src/fr/neatmonster/nocheatplus/checks/combined/CombinedListener.java +++ b/src/fr/neatmonster/nocheatplus/checks/combined/CombinedListener.java @@ -72,8 +72,8 @@ public class CombinedListener implements Listener { final CombinedData data = CombinedData.getData(player); final CombinedConfig cc = CombinedConfig.getConfig(player); - if (cc.invulnerableCheck){ - // TODO: maybe allow to set a different number of ticks ! + if (cc.invulnerableCheck && (cc.invulnerableTriggerAlways || cc.invulnerableTriggerFallDistance && player.getFallDistance() > 0)){ + // TODO: maybe make a heuristic for small fall distances with ground under feet (prevents future abuse with jumping) ? final EntityPlayer mcPlayer= ((CraftPlayer) player).getHandle(); final int ticks = cc.invulnerableInitialTicksJoin >= 0 ? cc.invulnerableInitialTicksJoin : mcPlayer.invulnerableTicks; data.invulnerableTick = TickTask.getTick() + ticks; diff --git a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java index d2a7af93..052ea229 100644 --- a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -304,12 +304,15 @@ public abstract class ConfPaths { public static final String COMBINED_IMPROBABLE_ACTIONS = COMBINED_IMPROBABLE + "actions"; - private static final String COMBINED_INVULNERABLE = COMBINED + "invulnerable."; - public static final String COMBINED_INVULNERABLE_CHECK = COMBINED_INVULNERABLE + "active"; - private static final String COMBINED_INVULNERABLE_INITIALTICKS = COMBINED_INVULNERABLE + "initialticks."; - public static final String COMBINED_INVULNERABLE_INITIALTICKS_JOIN = COMBINED_INVULNERABLE_INITIALTICKS + "join"; - public static final String COMBINED_INVULNERABLE_IGNORE = COMBINED_INVULNERABLE + "ignore"; - public static final String COMBINED_INVULNERABLE_MODIFIERS = COMBINED_INVULNERABLE + "modifiers"; + private static final String COMBINED_INVULNERABLE = COMBINED + "invulnerable."; + public static final String COMBINED_INVULNERABLE_CHECK = COMBINED_INVULNERABLE + "active"; + private static final String COMBINED_INVULNERABLE_INITIALTICKS = COMBINED_INVULNERABLE + "initialticks."; + public static final String COMBINED_INVULNERABLE_INITIALTICKS_JOIN = COMBINED_INVULNERABLE_INITIALTICKS + "join"; + public static final String COMBINED_INVULNERABLE_IGNORE = COMBINED_INVULNERABLE + "ignore"; + public static final String COMBINED_INVULNERABLE_MODIFIERS = COMBINED_INVULNERABLE + "modifiers"; // no dot ! + private static final String COMBINED_INVULNERABLE_TRIGGERS = COMBINED_INVULNERABLE + "triggers."; + public static final String COMBINED_INVULNERABLE_TRIGGERS_ALWAYS = COMBINED_INVULNERABLE_TRIGGERS + "always"; + public static final String COMBINED_INVULNERABLE_TRIGGERS_FALLDISTANCE = COMBINED_INVULNERABLE_TRIGGERS + "falldistance"; private static final String COMBINED_YAWRATE = COMBINED + "yawrate."; @@ -478,4 +481,5 @@ public abstract class ConfPaths { * "8",P" */ public static final String STRINGS = "strings"; + } diff --git a/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java b/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java index bd322b68..806b0ef5 100644 --- a/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java +++ b/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java @@ -235,6 +235,8 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.COMBINED_INVULNERABLE_CHECK, true); + set(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_ALWAYS, false); + set(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_FALLDISTANCE, true); set(ConfPaths.COMBINED_INVULNERABLE_INITIALTICKS_JOIN, -1); set(ConfPaths.COMBINED_INVULNERABLE_IGNORE, new LinkedList(Arrays.asList(new String[]{"FALL"}))); set(ConfPaths.COMBINED_INVULNERABLE_MODIFIERS + ".all", 0);