mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-10 04:30:30 +01:00
Small optimization for violation handling.
This commit is contained in:
parent
24eede78fe
commit
a5c37a884b
@ -151,4 +151,8 @@ public class ViolationData {
|
|||||||
if (parameters != null) parameters.put(parameterName, 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
|
// TODO: maybe add one absolute penalty time for big amounts to stop breaking until then
|
||||||
data.fastBreakVL += missingTime;
|
data.fastBreakVL += missingTime;
|
||||||
final ViolationData vd = new ViolationData(this, player, data.fastBreakVL, missingTime, cc.fastBreakActions);
|
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);
|
cancel = executeActions(vd);
|
||||||
}
|
}
|
||||||
// else: still within contention limits.
|
// 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
|
// Execute whatever actions are associated with this check and the violation level and find out if we
|
||||||
// should cancel the event.
|
// should cancel the event.
|
||||||
final ViolationData vd = new ViolationData(this, player, data.creativeFlyVL, result, cc.creativeFlyActions);
|
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()));
|
if (vd.needsParameters()){
|
||||||
vd.setParameter(ParameterName.LOCATION_TO, String.format(Locale.US, "%.2f, %.2f, %.2f", to.getX(), to.getY(), to.getZ()));
|
vd.setParameter(ParameterName.LOCATION_FROM, String.format(Locale.US, "%.2f, %.2f, %.2f", from.getX(), from.getY(), from.getZ()));
|
||||||
vd.setParameter(ParameterName.DISTANCE, String.format(Locale.US, "%.2f", to.getLocation().distance(from.getLocation())));
|
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))
|
if (executeActions(vd))
|
||||||
// Compose a new location based on coordinates of "newTo" and viewing direction of "event.getTo()"
|
// 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.
|
// 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.
|
// Return the reset position.
|
||||||
data.passableVL += 1d;
|
data.passableVL += 1d;
|
||||||
final ViolationData vd = new ViolationData(this, player, data.passableVL, 1, cc.passableActions);
|
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)){
|
if (executeActions(vd)){
|
||||||
final Location newTo = from.getLocation();
|
final Location newTo = from.getLocation();
|
||||||
newTo.setYaw(to.getYaw());
|
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
|
// 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.
|
// actions was a cancel, cancel it.
|
||||||
final ViolationData vd = new ViolationData(this, player, data.survivalFlyVL, result, cc.survivalFlyActions);
|
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()));
|
if (vd.needsParameters()){
|
||||||
vd.setParameter(ParameterName.LOCATION_TO, String.format(Locale.US, "%.2f, %.2f, %.2f", to.getX(), to.getY(), to.getZ()));
|
vd.setParameter(ParameterName.LOCATION_FROM, String.format(Locale.US, "%.2f, %.2f, %.2f", from.getX(), from.getY(), from.getZ()));
|
||||||
vd.setParameter(ParameterName.DISTANCE, String.format(Locale.US, "%.2f", to.getLocation().distance(from.getLocation())));
|
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)){
|
if (executeActions(vd)){
|
||||||
// Compose a new location based on coordinates of "newTo" and viewing direction of "event.getTo()" to
|
// 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.
|
// allow the player to look somewhere else despite getting pulled back by NoCheatPlus.
|
||||||
|
Loading…
Reference in New Issue
Block a user