Added MunchHausen check.

This commit is contained in:
asofold 2012-12-06 05:43:30 +01:00
parent 6e62b7ee1b
commit d47c2cd533
8 changed files with 62 additions and 0 deletions

View File

@ -70,6 +70,7 @@ public enum CheckType {
COMBINED(CombinedConfig.factory, CombinedData.factory, Permissions.COMBINED),
COMBINED_BEDLEAVE(COMBINED, Permissions.COMBINED_BEDLEAVE),
COMBINED_IMPROBABLE(COMBINED, Permissions.COMBINED_IMPROBABLE),
COMBINED_MUNCHHAUSEN(COMBINED, Permissions.COMBINED_MUNCHHAUSEN),
FIGHT(FightConfig.factory, FightData.factory, Permissions.FIGHT),
FIGHT_ANGLE(FIGHT, Permissions.FIGHT_ANGLE),

View File

@ -63,6 +63,9 @@ public class CombinedConfig extends ACheckConfig {
public final int invulnerableModifierDefault;
public final boolean invulnerableTriggerAlways;
public final boolean invulnerableTriggerFallDistance;
public final boolean munchHausenCheck;
public final ActionList munchHausenActions;
// Last yaw tracking
public final float yawRate;
@ -117,6 +120,10 @@ public class CombinedConfig extends ACheckConfig {
if (error) LogUtil.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);
munchHausenCheck = config.getBoolean(ConfPaths.COMBINED_MUNCHHAUSEN_CHECK);
munchHausenActions = config.getOptimizedActionList(ConfPaths.COMBINED_MUNCHHAUSEN_ACTIONS, Permissions.COMBINED_MUNCHHAUSEN);
yawRate = config.getInt(ConfPaths.COMBINED_YAWRATE_RATE);
yawRateImprobable = config.getBoolean(ConfPaths.COMBINED_YAWRATE_IMPROBABLE);
yawRatePenaltyFactor = (float) config.getDouble(ConfPaths.COMBINED_YAWRATE_PENALTY_FACTOR);

View File

@ -53,6 +53,7 @@ public class CombinedData extends ACheckData {
// VLs
public double bedLeaveVL = 0;
public double improbableVL = 0;
public double munchHausenVL = 0;
// Invulnerable management:
/** This is the tick from which on the player is vulnerable again. */

View File

@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.event.player.PlayerToggleSprintEvent;
@ -25,6 +26,8 @@ import fr.neatmonster.nocheatplus.utilities.TickTask;
public class CombinedListener extends CheckListener {
protected final Improbable improbable;
protected final MunchHausen munchHausen = new MunchHausen();
public CombinedListener(){
super(CheckType.COMBINED);
@ -101,5 +104,14 @@ public class CombinedListener extends CheckListener {
// Check also in case of cancelled events.
if (Improbable.check(event.getPlayer(), 0.35f, System.currentTimeMillis())) event.setCancelled(true);
}
@EventHandler(priority=EventPriority.LOWEST)
public void onPlayerFish(final PlayerFishEvent event){
// Check also in case of cancelled events.
final Player player = event.getPlayer();
if (munchHausen.isEnabled(player) && munchHausen.checkFish(player, event.getCaught(), event.getState())){
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,33 @@
package fr.neatmonster.nocheatplus.checks.combined;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerFishEvent.State;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
/**
* Very, very important check.
* @author mc_dev
*
*/
public class MunchHausen extends Check {
public MunchHausen(){
super(CheckType.COMBINED_MUNCHHAUSEN);
}
public boolean checkFish(final Player player, final Entity caught, final State state) {
if (caught == null || !(caught instanceof Player)) return false;
final Player caughtPlayer = (Player) caught;
final CombinedData data = CombinedData.getData(player);
if (player.equals(caughtPlayer)){
data.munchHausenVL += 1.0;
if (executeActions(player, data.munchHausenVL, 1.0, CombinedConfig.getConfig(player).munchHausenActions)){
return true;
}
}
else data.munchHausenVL *= 0.96;
return false;
}
}

View File

@ -322,6 +322,9 @@ public abstract class ConfPaths {
public static final String COMBINED_INVULNERABLE_TRIGGERS_ALWAYS = COMBINED_INVULNERABLE_TRIGGERS + "always";
public static final String COMBINED_INVULNERABLE_TRIGGERS_FALLDISTANCE = COMBINED_INVULNERABLE_TRIGGERS + "falldistance";
public static final String COMBINED_MUNCHHAUSEN = COMBINED + "munchhausen.";
public static final String COMBINED_MUNCHHAUSEN_CHECK = COMBINED_MUNCHHAUSEN + "active";
public static final String COMBINED_MUNCHHAUSEN_ACTIONS = COMBINED_MUNCHHAUSEN + "actions";
private static final String COMBINED_YAWRATE = COMBINED + "yawrate.";
public static final String COMBINED_YAWRATE_RATE = COMBINED_YAWRATE + "rate";

View File

@ -253,6 +253,9 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.COMBINED_INVULNERABLE_IGNORE, Arrays.asList("FALL"));
set(ConfPaths.COMBINED_INVULNERABLE_MODIFIERS + ".all", 0);
set(ConfPaths.COMBINED_MUNCHHAUSEN_CHECK, false);
set(ConfPaths.COMBINED_MUNCHHAUSEN_ACTIONS, "cancel vl>100 cancel log:munchhausen:0:60:if");
set(ConfPaths.COMBINED_YAWRATE_RATE , 380);
set(ConfPaths.COMBINED_YAWRATE_PENALTY_FACTOR, 1.0);
set(ConfPaths.COMBINED_YAWRATE_PENALTY_MIN, 250);
@ -442,6 +445,7 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.STRINGS + ".kickwb", "ncp kick [player] Block breaking out of sync!");
set(ConfPaths.STRINGS + ".knockback", start + "tried to do a knockback but wasn't technically sprinting" + end);
set(ConfPaths.STRINGS + ".morepackets", start + "sent [packets] more packet(s) than expected" + end);
set(ConfPaths.STRINGS + ".munchhausen", start + "almost made it off the pit" + end);
set(ConfPaths.STRINGS + ".nofall", start + "tried to avoid fall damage" + end);
set(ConfPaths.STRINGS + ".chatfast", start + "acted like spamming (IP: [ip])" + end);
set(ConfPaths.STRINGS + ".noswing", start + "didn't swing arm" + end);

View File

@ -122,6 +122,7 @@ public class Permissions {
public static final String COMBINED = CHECKS + ".combined";
public static final String COMBINED_BEDLEAVE = COMBINED + ".bedleave";
public static final String COMBINED_IMPROBABLE = COMBINED + ".improbable";
public static final String COMBINED_MUNCHHAUSEN = COMBINED + ".munchhausen";
/*
* 888'Y88 ,e, 888 d8