mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-09 20:20:11 +01:00
Small optimization for violation handling.
This commit is contained in:
parent
24eede78fe
commit
a5c37a884b
@ -150,5 +150,9 @@ public class ViolationData {
|
||||
public void setParameter(final ParameterName parameterName, String value){
|
||||
if (parameters != null) parameters.put(parameterName, value);
|
||||
}
|
||||
|
||||
public boolean needsParameters() {
|
||||
return parameters != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class FastBreak extends Check {
|
||||
// TODO: maybe add one absolute penalty time for big amounts to stop breaking until then
|
||||
data.fastBreakVL += missingTime;
|
||||
final ViolationData vd = new ViolationData(this, player, data.fastBreakVL, missingTime, cc.fastBreakActions);
|
||||
vd.setParameter(ParameterName.BLOCK_ID, "" + id);
|
||||
if (vd.needsParameters()) vd.setParameter(ParameterName.BLOCK_ID, "" + id);
|
||||
cancel = executeActions(vd);
|
||||
}
|
||||
// else: still within contention limits.
|
||||
|
@ -132,9 +132,11 @@ public class CreativeFly extends Check {
|
||||
// Execute whatever actions are associated with this check and the violation level and find out if we
|
||||
// should cancel the event.
|
||||
final ViolationData vd = new ViolationData(this, player, data.creativeFlyVL, result, cc.creativeFlyActions);
|
||||
vd.setParameter(ParameterName.LOCATION_FROM, String.format(Locale.US, "%.2f, %.2f, %.2f", from.getX(), from.getY(), from.getZ()));
|
||||
vd.setParameter(ParameterName.LOCATION_TO, String.format(Locale.US, "%.2f, %.2f, %.2f", to.getX(), to.getY(), to.getZ()));
|
||||
vd.setParameter(ParameterName.DISTANCE, String.format(Locale.US, "%.2f", to.getLocation().distance(from.getLocation())));
|
||||
if (vd.needsParameters()){
|
||||
vd.setParameter(ParameterName.LOCATION_FROM, String.format(Locale.US, "%.2f, %.2f, %.2f", from.getX(), from.getY(), from.getZ()));
|
||||
vd.setParameter(ParameterName.LOCATION_TO, String.format(Locale.US, "%.2f, %.2f, %.2f", to.getX(), to.getY(), to.getZ()));
|
||||
vd.setParameter(ParameterName.DISTANCE, String.format(Locale.US, "%.2f", to.getLocation().distance(from.getLocation())));
|
||||
}
|
||||
if (executeActions(vd))
|
||||
// Compose a new location based on coordinates of "newTo" and viewing direction of "event.getTo()"
|
||||
// to allow the player to look somewhere else despite getting pulled back by NoCheatPlus.
|
||||
|
@ -29,7 +29,7 @@ public class Passable extends Check {
|
||||
// Return the reset position.
|
||||
data.passableVL += 1d;
|
||||
final ViolationData vd = new ViolationData(this, player, data.passableVL, 1, cc.passableActions);
|
||||
vd.setParameter(ParameterName.BLOCK_ID, "" + toId);
|
||||
if (vd.needsParameters()) vd.setParameter(ParameterName.BLOCK_ID, "" + toId);
|
||||
if (executeActions(vd)){
|
||||
final Location newTo = from.getLocation();
|
||||
newTo.setYaw(to.getYaw());
|
||||
|
@ -330,9 +330,11 @@ public class SurvivalFly extends Check {
|
||||
// If the other plugins haven't decided to cancel the execution of the actions, then do it. If one of the
|
||||
// actions was a cancel, cancel it.
|
||||
final ViolationData vd = new ViolationData(this, player, data.survivalFlyVL, result, cc.survivalFlyActions);
|
||||
vd.setParameter(ParameterName.LOCATION_FROM, String.format(Locale.US, "%.2f, %.2f, %.2f", from.getX(), from.getY(), from.getZ()));
|
||||
vd.setParameter(ParameterName.LOCATION_TO, String.format(Locale.US, "%.2f, %.2f, %.2f", to.getX(), to.getY(), to.getZ()));
|
||||
vd.setParameter(ParameterName.DISTANCE, String.format(Locale.US, "%.2f", to.getLocation().distance(from.getLocation())));
|
||||
if (vd.needsParameters()){
|
||||
vd.setParameter(ParameterName.LOCATION_FROM, String.format(Locale.US, "%.2f, %.2f, %.2f", from.getX(), from.getY(), from.getZ()));
|
||||
vd.setParameter(ParameterName.LOCATION_TO, String.format(Locale.US, "%.2f, %.2f, %.2f", to.getX(), to.getY(), to.getZ()));
|
||||
vd.setParameter(ParameterName.DISTANCE, String.format(Locale.US, "%.2f", to.getLocation().distance(from.getLocation())));
|
||||
}
|
||||
if (executeActions(vd)){
|
||||
// Compose a new location based on coordinates of "newTo" and viewing direction of "event.getTo()" to
|
||||
// allow the player to look somewhere else despite getting pulled back by NoCheatPlus.
|
||||
|
Loading…
Reference in New Issue
Block a user