Add tags to improbable. Currently only the tags triggering the violation

are shown, probably useful for debugging.
This commit is contained in:
asofold 2013-01-29 03:16:10 +01:00
parent d8701a7ea6
commit c40b9fac22
7 changed files with 14 additions and 10 deletions

View File

@ -62,7 +62,7 @@ public class WrongBlock extends Check {
if (score > cc.wrongBLockLevel){
if (executeActions(player, score, 1D, cc.wrongBlockActions))
cancel = true;
if (Improbable.check(player, 2.0f, now))
if (Improbable.check(player, 2.0f, now, "blockbreak.wrongblock"))
cancel = true;
}
}

View File

@ -258,7 +258,7 @@ public class BlockPlaceListener extends CheckListener {
// If the check was positive, cancel the event.
event.setCancelled(true);
}
else if (Improbable.check(player, 0.6f, now)){
else if (Improbable.check(player, 0.6f, now, "blockplace.speed")){
// Combined fighting speed.
event.setCancelled(true);
}

View File

@ -149,7 +149,7 @@ public class Combined {
final float amount = ((total - threshold) / threshold * 1000f);
data.timeFreeze = Math.max(data.timeFreeze, now + (long) Math.min(Math.max(cc.yawRatePenaltyFactor * amount , cc.yawRatePenaltyMin), cc.yawRatePenaltyMax));
// TODO: balance (100 ... 200 ) ?
if (cc.yawRateImprobable && Improbable.check(player, amount / 100f, now))
if (cc.yawRateImprobable && Improbable.check(player, amount / 100f, now, "combined.yawrate"))
cancel = true;
}
if (now < data.timeFreeze){

View File

@ -2,8 +2,10 @@ package fr.neatmonster.nocheatplus.checks.combined;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.actions.ParameterName;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.utilities.TickTask;
/**
@ -24,8 +26,8 @@ public class Improbable extends Check {
* @param now
* @return
*/
public static final boolean check(final Player player, final float weight, final long now){
return instance.checkImprobable(player, weight, now);
public static final boolean check(final Player player, final float weight, final long now, final String tags){
return instance.checkImprobable(player, weight, now, tags);
}
/**
@ -47,7 +49,7 @@ public class Improbable extends Check {
instance = this;
}
private boolean checkImprobable(final Player player, final float weight, final long now) {
private boolean checkImprobable(final Player player, final float weight, final long now, final String tags) {
if (!isEnabled(player)) return false;
final CombinedData data = CombinedData.getData(player);
final CombinedConfig cc = CombinedConfig.getConfig(player);
@ -74,7 +76,9 @@ public class Improbable extends Check {
if (violated){
// Execute actions
data.improbableVL += violation / 10.0;
cancel = executeActions(player, data.improbableVL, violation / 10.0, cc.improbableActions);
final ViolationData vd = new ViolationData(this, player, data.improbableVL, violation, cc.improbableActions);
if (tags != null && !tags.isEmpty()) vd.setParameter(ParameterName.TAGS, tags);
cancel = executeActions(vd);
}
else
data.improbableVL *= 0.95;

View File

@ -147,7 +147,7 @@ public class FightListener extends CheckListener {
// Still feed the improbable.
Improbable.feed(player, 2f, now);
}
else if (normalizedMove > 2.0 && Improbable.check(player, 1f, now)){
else if (normalizedMove > 2.0 && Improbable.check(player, 1f, now, "fight.speed")){
// Feed improbable in case of ok-moves too.
// TODO: consider only feeding if attacking with higher average speed (!)
cancelled = true;

View File

@ -111,7 +111,7 @@ public class Reach extends Check {
// 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.reachVL, violation, cc.reachActions);
if (Improbable.check(player, (float) violation, System.currentTimeMillis()))
if (Improbable.check(player, (float) violation, System.currentTimeMillis(), "fight.reach"))
cancel = true;
if (cancel)
// If we should cancel, remember the current time too.

View File

@ -99,7 +99,7 @@ public class InventoryListener extends CheckListener {
// The check requested the event to be cancelled.
event.setCancelled(true);
}
else if (Improbable.check(player, 0.6f, now)){
else if (Improbable.check(player, 0.6f, now, "inventory.instantbow")){
// Combined fighting speed (Else if: Matter of taste, preventing extreme cascading and actions spam).
event.setCancelled(true);
}