mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-10-31 07:40:16 +01:00
Further adjustments to Improbable (feed).
Just feed weights to improbable instead of checking for some places, getting rid of some unnecessary violations cascading. Also feed for fighting speed violations.
This commit is contained in:
parent
05c7699937
commit
f4680da0d4
@ -108,14 +108,11 @@ public class BlockPlaceListener extends CheckListener {
|
||||
if (fastPlace.check(player, block))
|
||||
cancelled = true;
|
||||
else{
|
||||
// Combined speed.
|
||||
if (Improbable.check(player, 0.5f, System.currentTimeMillis())){
|
||||
cancelled = true;
|
||||
// Feed the improbable.
|
||||
Improbable.feed(player, 0.5f, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Second, the no swing check (player doesn't swing his arm when placing a lily pad).
|
||||
if (!cancelled && mat != Material.WATER_LILY && noSwing.isEnabled(player)
|
||||
&& noSwing.check(player))
|
||||
|
@ -74,12 +74,6 @@ public class CombinedListener extends CheckListener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOW)
|
||||
public void onPlayerToggleSprint(final PlayerToggleSprintEvent event){
|
||||
// Check also in case of cancelled events.
|
||||
if (Improbable.check(event.getPlayer(), 0.35f, System.currentTimeMillis())) event.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* A workaround for cancelled PlayerToggleSprintEvents.
|
||||
*
|
||||
@ -93,13 +87,15 @@ public class CombinedListener extends CheckListener {
|
||||
// and rewards them by reducing their hunger bar as if they were walking instead of sprinting.
|
||||
if (event.isCancelled() && event.isSprinting())
|
||||
event.setCancelled(false);
|
||||
// Feed the improbable.
|
||||
Improbable.feed(event.getPlayer(), 0.35f, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOW)
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onPlayerToggleSneak(final PlayerToggleSneakEvent event){
|
||||
// Check also in case of cancelled events.
|
||||
// TODO: Maybe this is not good to cancel.
|
||||
if (Improbable.check(event.getPlayer(), 0.35f, System.currentTimeMillis())) event.setCancelled(true);
|
||||
// Feed the improbable.
|
||||
Improbable.feed(event.getPlayer(), 0.35f, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
|
@ -27,6 +27,16 @@ public class Improbable extends Check {
|
||||
return instance.checkImprobable(player, weight, now);
|
||||
}
|
||||
|
||||
/**
|
||||
* Feed the check but no violations processing (convenience method).
|
||||
* @param player
|
||||
* @param weight
|
||||
* @param now
|
||||
*/
|
||||
public static final void feed(final Player player, final float weight, final long now){
|
||||
CombinedData.getData(player).improbableCount.add(now, weight);
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// Instance methods.
|
||||
///////////////////////////////////
|
||||
|
@ -110,12 +110,17 @@ public class FightListener extends CheckListener {
|
||||
|
||||
// Run through the main checks.
|
||||
if (!cancelled && speed.isEnabled(player)){
|
||||
if (speed.check(player, now))
|
||||
if (speed.check(player, now)){
|
||||
cancelled = true;
|
||||
// Combined speed:
|
||||
else if (Improbable.check(player, 1f, now))
|
||||
// Still feed the improbable.
|
||||
Improbable.feed(player, 1f, now);
|
||||
}
|
||||
else if (Improbable.check(player, 1f, now)){
|
||||
// Feed improbable in case of ok-moves too.
|
||||
// TODO: consider only feeding if attacking with higher average speed (!)
|
||||
cancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (angle.isEnabled(player)) {
|
||||
// The "fast turning" checks are checked in any case because they accumulate data.
|
||||
|
@ -116,9 +116,10 @@ public class Reach extends Check {
|
||||
data.reachLastViolationTime = System.currentTimeMillis();
|
||||
}
|
||||
else if (lenpRel - distanceLimit * reachMod > 0){
|
||||
// Silent cancel.
|
||||
data.reachLastViolationTime = Math.max(data.reachLastViolationTime, System.currentTimeMillis() - cc.reachPenalty / 2);
|
||||
cancel = true;
|
||||
Improbable.check(player, (float) (lenpRel - distanceLimit * reachMod) / 2f, System.currentTimeMillis());
|
||||
Improbable.feed(player, (float) (lenpRel - distanceLimit * reachMod) / 2f, System.currentTimeMillis());
|
||||
}
|
||||
else{
|
||||
// Player passed the check, reward him.
|
||||
|
@ -172,10 +172,8 @@ public class InventoryListener extends CheckListener {
|
||||
// The check requested the event to be cancelled.
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (Improbable.check(player, 0.7f, System.currentTimeMillis())){
|
||||
// Combined speed:
|
||||
// event.setCancelled(true);
|
||||
}
|
||||
// Feed the improbable.
|
||||
Improbable.feed(player, 0.7f, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user