mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-02-18 04:31:45 +01:00
Add tags to improbable. Currently only the tags triggering the violation
are shown, probably useful for debugging.
This commit is contained in:
parent
d8701a7ea6
commit
c40b9fac22
NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks
blockbreak
blockplace
combined
fight
inventory
@ -62,7 +62,7 @@ public class WrongBlock extends Check {
|
|||||||
if (score > cc.wrongBLockLevel){
|
if (score > cc.wrongBLockLevel){
|
||||||
if (executeActions(player, score, 1D, cc.wrongBlockActions))
|
if (executeActions(player, score, 1D, cc.wrongBlockActions))
|
||||||
cancel = true;
|
cancel = true;
|
||||||
if (Improbable.check(player, 2.0f, now))
|
if (Improbable.check(player, 2.0f, now, "blockbreak.wrongblock"))
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ public class BlockPlaceListener extends CheckListener {
|
|||||||
// If the check was positive, cancel the event.
|
// If the check was positive, cancel the event.
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
else if (Improbable.check(player, 0.6f, now)){
|
else if (Improbable.check(player, 0.6f, now, "blockplace.speed")){
|
||||||
// Combined fighting speed.
|
// Combined fighting speed.
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ public class Combined {
|
|||||||
final float amount = ((total - threshold) / threshold * 1000f);
|
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));
|
data.timeFreeze = Math.max(data.timeFreeze, now + (long) Math.min(Math.max(cc.yawRatePenaltyFactor * amount , cc.yawRatePenaltyMin), cc.yawRatePenaltyMax));
|
||||||
// TODO: balance (100 ... 200 ) ?
|
// 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;
|
cancel = true;
|
||||||
}
|
}
|
||||||
if (now < data.timeFreeze){
|
if (now < data.timeFreeze){
|
||||||
|
@ -2,8 +2,10 @@ package fr.neatmonster.nocheatplus.checks.combined;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
import fr.neatmonster.nocheatplus.checks.Check;
|
import fr.neatmonster.nocheatplus.checks.Check;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||||
|
import fr.neatmonster.nocheatplus.checks.ViolationData;
|
||||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,8 +26,8 @@ public class Improbable extends Check {
|
|||||||
* @param now
|
* @param now
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static final boolean check(final Player player, final float weight, final long now){
|
public static final boolean check(final Player player, final float weight, final long now, final String tags){
|
||||||
return instance.checkImprobable(player, weight, now);
|
return instance.checkImprobable(player, weight, now, tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +49,7 @@ public class Improbable extends Check {
|
|||||||
instance = this;
|
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;
|
if (!isEnabled(player)) return false;
|
||||||
final CombinedData data = CombinedData.getData(player);
|
final CombinedData data = CombinedData.getData(player);
|
||||||
final CombinedConfig cc = CombinedConfig.getConfig(player);
|
final CombinedConfig cc = CombinedConfig.getConfig(player);
|
||||||
@ -74,7 +76,9 @@ public class Improbable extends Check {
|
|||||||
if (violated){
|
if (violated){
|
||||||
// Execute actions
|
// Execute actions
|
||||||
data.improbableVL += violation / 10.0;
|
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
|
else
|
||||||
data.improbableVL *= 0.95;
|
data.improbableVL *= 0.95;
|
||||||
|
@ -147,7 +147,7 @@ public class FightListener extends CheckListener {
|
|||||||
// Still feed the improbable.
|
// Still feed the improbable.
|
||||||
Improbable.feed(player, 2f, now);
|
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.
|
// Feed improbable in case of ok-moves too.
|
||||||
// TODO: consider only feeding if attacking with higher average speed (!)
|
// TODO: consider only feeding if attacking with higher average speed (!)
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
|
@ -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
|
// Execute whatever actions are associated with this check and the violation level and find out if we should
|
||||||
// cancel the event.
|
// cancel the event.
|
||||||
cancel = executeActions(player, data.reachVL, violation, cc.reachActions);
|
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;
|
cancel = true;
|
||||||
if (cancel)
|
if (cancel)
|
||||||
// If we should cancel, remember the current time too.
|
// If we should cancel, remember the current time too.
|
||||||
|
@ -99,7 +99,7 @@ public class InventoryListener extends CheckListener {
|
|||||||
// The check requested the event to be cancelled.
|
// The check requested the event to be cancelled.
|
||||||
event.setCancelled(true);
|
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).
|
// Combined fighting speed (Else if: Matter of taste, preventing extreme cascading and actions spam).
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user