Remove fight.instantheal check.

This commit is contained in:
asofold 2012-10-03 02:42:03 +02:00
parent 07db0630fc
commit ee7be35fa0
8 changed files with 1 additions and 132 deletions

View File

@ -78,7 +78,6 @@ public enum CheckType {
FIGHT_CRITICAL(FIGHT, Permissions.FIGHT_CRITICAL),
FIGHT_DIRECTION(FIGHT, Permissions.FIGHT_DIRECTION),
FIGHT_GODMODE(FIGHT, Permissions.FIGHT_GODMODE),
FIGHT_INSTANTHEAL(FIGHT, Permissions.FIGHT_INSTANTHEAL),
FIGHT_KNOCKBACK(FIGHT, Permissions.FIGHT_KNOCKBACK),
FIGHT_NOSWING(FIGHT, Permissions.FIGHT_NOSWING),
FIGHT_REACH(FIGHT, Permissions.FIGHT_REACH),

View File

@ -79,9 +79,6 @@ public class FightConfig extends ACheckConfig {
public final boolean godModeCheck;
public final ActionList godModeActions;
public final boolean instantHealCheck;
public final ActionList instantHealActions;
public final boolean knockbackCheck;
public final long knockbackInterval;
public final ActionList knockbackActions;
@ -135,9 +132,6 @@ public class FightConfig extends ACheckConfig {
godModeCheck = data.getBoolean(ConfPaths.FIGHT_GODMODE_CHECK);
godModeActions = data.getActionList(ConfPaths.FIGHT_GODMODE_ACTIONS, Permissions.FIGHT_GODMODE);
instantHealCheck = data.getBoolean(ConfPaths.FIGHT_INSTANTHEAL_CHECK);
instantHealActions = data.getActionList(ConfPaths.FIGHT_INSTANTHEAL_ACTIONS, Permissions.FIGHT_INSTANTHEAL);
knockbackCheck = data.getBoolean(ConfPaths.FIGHT_KNOCKBACK_CHECK);
knockbackInterval = data.getLong(ConfPaths.FIGHT_KNOCKBACK_INTERVAL);
knockbackActions = data.getActionList(ConfPaths.FIGHT_KNOCKBACK_ACTIONS, Permissions.FIGHT_KNOCKBACK);
@ -182,8 +176,6 @@ public class FightConfig extends ACheckConfig {
return directionCheck;
case FIGHT_GODMODE:
return godModeCheck;
case FIGHT_INSTANTHEAL:
return instantHealCheck;
case FIGHT_KNOCKBACK:
return knockbackCheck;
case FIGHT_NOSWING:

View File

@ -74,7 +74,6 @@ public class FightData extends ACheckData {
public double criticalVL;
public double directionVL;
public double godModeVL;
public double instantHealVL;
public double knockbackVL;
public double noSwingVL;
public double reachVL;
@ -99,10 +98,6 @@ public class FightData extends ACheckData {
public int godModeLastAge;
public long godModeLastTime;
// Data of the instant heal check.
public long instantHealBuffer;
public long instantHealLastTime;
// Data of the knockback check.
public long knockbackSprintTime;

View File

@ -10,8 +10,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerToggleSprintEvent;
@ -49,9 +47,6 @@ public class FightListener implements Listener {
/** The god mode check. */
private final GodMode godMode = new GodMode();
/** The instant heal check. */
private final InstantHeal instantHeal = new InstantHeal();
/** The knockback check. */
private final Knockback knockback = new Knockback();
@ -257,30 +252,6 @@ public class FightListener implements Listener {
godMode.death((Player) event.getEntity());
}
/**
* We listen to EntityRegainHealth events of type "satiated" for InstantHeal check.
*
* @param event
* the event
*/
@EventHandler(
ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onEntityRegainHealth(final EntityRegainHealthEvent event) {
/*
* _____ _ _ _ ____ _ _ _ _ _ _
* | ____|_ __ | |_(_) |_ _ _ | _ \ ___ __ _ __ _(_)_ __ | | | | ___ __ _| | |_| |__
* | _| | '_ \| __| | __| | | | | |_) / _ \/ _` |/ _` | | '_ \ | |_| |/ _ \/ _` | | __| '_ \
* | |___| | | | |_| | |_| |_| | | _ < __/ (_| | (_| | | | | | | _ | __/ (_| | | |_| | | |
* |_____|_| |_|\__|_|\__|\__, | |_| \_\___|\__, |\__,_|_|_| |_| |_| |_|\___|\__,_|_|\__|_| |_|
* |___/ |___/
*/
if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED) {
final Player player = (Player) event.getEntity();
if (instantHeal.isEnabled(player) && instantHeal.check(player))
event.setCancelled(true);
}
}
/**
* We listen to PlayerAnimation events because it is used for arm swinging.
*

View File

@ -1,79 +0,0 @@
package fr.neatmonster.nocheatplus.checks.fight;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
/*
* M""M dP dP M""MMMMM""MM dP
* M M 88 88 M MMMMM MM 88
* M M 88d888b. .d8888b. d8888P .d8888b. 88d888b. d8888P M `M .d8888b. .d8888b. 88
* M M 88' `88 Y8ooooo. 88 88' `88 88' `88 88 M MMMMM MM 88ooood8 88' `88 88
* M M 88 88 88 88 88. .88 88 88 88 M MMMMM MM 88. ... 88. .88 88
* M M dP dP `88888P' dP `88888P8 dP dP dP M MMMMM MM `88888P' `88888P8 dP
* MMMM MMMMMMMMMMMM
*/
/**
* The InstantHeal check should find out if a player has tried to artificially accelerate the health regeneration by
* food.
*/
public class InstantHeal extends Check {
/**
* Instantiates a new instant heal check.
*/
public InstantHeal() {
super(CheckType.FIGHT_INSTANTHEAL);
}
/**
* Check a player.
*
* @param player
* the player
* @return true, if successful
*/
public boolean check(final Player player) {
// Take time once.
final long time = System.currentTimeMillis();
final FightData data = FightData.getData(player);
boolean cancel = false;
// Security check if system time ran backwards.
if (data.instantHealLastTime > time) {
data.instantHealLastTime = 0L;
return false;
}
final long delta = time - (data.instantHealLastTime + 3000L);
data.instantHealBuffer += delta;
if (data.instantHealBuffer < 0) {
// Buffer has been fully consumed, increase the player's violation level;
data.instantHealVL -= data.instantHealBuffer / 1000D;
// Reset the buffer.
data.instantHealBuffer = 0L;
// Execute whatever actions are associated with this check and the violation level and find out if we should
// cancel the event.
cancel = executeActions(player, data.instantHealVL, -data.instantHealBuffer / 1000D,
FightConfig.getConfig(player).instantHealActions);
} else
// Decrease the violation level.
data.instantHealVL *= 0.9D;
// Buffer can't be bigger than 2 seconds.
if (data.instantHealBuffer > 2000L)
data.instantHealBuffer = 2000L;
if (!cancel)
// New reference time.
data.instantHealLastTime = time;
return cancel;
}
}

View File

@ -339,11 +339,7 @@ public abstract class ConfPaths {
private static final String FIGHT_GODMODE = FIGHT + "godmode.";
public static final String FIGHT_GODMODE_CHECK = FIGHT_GODMODE + "active";
public static final String FIGHT_GODMODE_ACTIONS = FIGHT_GODMODE + "actions";
private static final String FIGHT_INSTANTHEAL = FIGHT + "instantheal.";
public static final String FIGHT_INSTANTHEAL_CHECK = FIGHT_INSTANTHEAL + "active";
public static final String FIGHT_INSTANTHEAL_ACTIONS = FIGHT_INSTANTHEAL + "actions";
private static final String FIGHT_KNOCKBACK = FIGHT + "knockback.";
public static final String FIGHT_KNOCKBACK_CHECK = FIGHT_KNOCKBACK + "active";
public static final String FIGHT_KNOCKBACK_INTERVAL = FIGHT_KNOCKBACK + "interval";

View File

@ -264,9 +264,6 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.FIGHT_GODMODE_CHECK, true);
set(ConfPaths.FIGHT_GODMODE_ACTIONS, "log:godmode:2:5:if cancel");
set(ConfPaths.FIGHT_INSTANTHEAL_CHECK, false);
set(ConfPaths.FIGHT_INSTANTHEAL_ACTIONS, "log:instantheal:1:1:if cancel");
set(ConfPaths.FIGHT_KNOCKBACK_CHECK, true);
set(ConfPaths.FIGHT_KNOCKBACK_INTERVAL, 50L);
set(ConfPaths.FIGHT_KNOCKBACK_ACTIONS, "cancel vl>50 log:knockback:0:5:cif cancel");
@ -396,7 +393,6 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.STRINGS + ".improbable", start + "meets the improbable more than expected" + end);
set(ConfPaths.STRINGS + ".instantbow", start + "fires bow to fast" + end);
set(ConfPaths.STRINGS + ".instanteat", start + "eats food [food] too fast" + end);
set(ConfPaths.STRINGS + ".instantheal", start + "tried to regenerate health faster than normal" + end);
set(ConfPaths.STRINGS + ".kick", "kick [player]");
set(ConfPaths.STRINGS + ".kickcommands", "ncp tempkick [player] 1 You're not allowed to spam commands!");
set(ConfPaths.STRINGS + ".kickchatfast", "ncp kick [player] You're not allowed to spam in chat!");

View File

@ -131,7 +131,6 @@ public class Permissions {
public static final String FIGHT_CRITICAL = FIGHT + ".critical";
public static final String FIGHT_DIRECTION = FIGHT + ".direction";
public static final String FIGHT_GODMODE = FIGHT + ".godmode";
public static final String FIGHT_INSTANTHEAL = FIGHT + ".instantheal";
public static final String FIGHT_KNOCKBACK = FIGHT + ".knockback";
public static final String FIGHT_NOSWING = FIGHT + ".noswing";
public static final String FIGHT_REACH = FIGHT + ".reach";