mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-28 03:17:53 +01:00
Use the same Location instance for passable and nofall.
This commit is contained in:
parent
dfc8e7c5a7
commit
0c59487a0a
@ -560,13 +560,17 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The players location.
|
||||||
|
// TODO: Change to getLocation(moveInfo.loc) once 1.4.5 support is dropped.
|
||||||
|
final Location loc = (cc.noFallCheck || cc.passableCheck) ? player.getLocation() : null;
|
||||||
|
|
||||||
Location newTo = null;
|
Location newTo = null;
|
||||||
|
|
||||||
// Check passable first to prevent set-back override.
|
// Check passable first to prevent set-back override.
|
||||||
// TODO: Redesign to set set-backs later (queue + invalidate).
|
// TODO: Redesign to set set-backs later (queue + invalidate).
|
||||||
if (newTo == null && cc.passableCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_PASSABLE) && !player.hasPermission(Permissions.MOVING_PASSABLE)) {
|
if (newTo == null && cc.passableCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_PASSABLE) && !player.hasPermission(Permissions.MOVING_PASSABLE)) {
|
||||||
// Passable is checked first to get the original set-back locations from the other checks, if needed.
|
// Passable is checked first to get the original set-back locations from the other checks, if needed.
|
||||||
newTo = passable.check(player, pFrom, pTo, data, cc);
|
newTo = passable.check(player, loc, pFrom, pTo, data, cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check which fly check to check.
|
// Check which fly check to check.
|
||||||
@ -612,12 +616,12 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||||||
}
|
}
|
||||||
// NoFall.
|
// NoFall.
|
||||||
if (checkNf){
|
if (checkNf){
|
||||||
noFall.check(player, pFrom, pTo, data, cc);
|
noFall.check(player, loc, pFrom, pTo, data, cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if (checkNf && cc.sfFallDamage){
|
if (checkNf && cc.sfFallDamage){
|
||||||
noFall.checkDamage(player, data, Math.min(from.getY(), to.getY()));
|
noFall.checkDamage(player, data, Math.min(Math.min(from.getY(), to.getY()), loc.getY()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -652,6 +656,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||||||
// TODO: data.sfHoverTicks ?
|
// TODO: data.sfHoverTicks ?
|
||||||
|
|
||||||
// Set new to-location.
|
// Set new to-location.
|
||||||
|
// TODO: Clone here for the case of using loc with loc = player.getLocation(moveInfo.loc).
|
||||||
event.setTo(newTo);
|
event.setTo(newTo);
|
||||||
|
|
||||||
// Remember where we send the player to.
|
// Remember where we send the player to.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.moving;
|
package fr.neatmonster.nocheatplus.checks.moving;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
@ -86,7 +87,7 @@ public class NoFall extends Check {
|
|||||||
* @param to
|
* @param to
|
||||||
* the to
|
* the to
|
||||||
*/
|
*/
|
||||||
public void check(final Player player, final PlayerLocation from, final PlayerLocation to, final MovingData data, final MovingConfig cc) {
|
public void check(final Player player, final Location loc, final PlayerLocation from, final PlayerLocation to, final MovingData data, final MovingConfig cc) {
|
||||||
|
|
||||||
final double fromY = from.getY();
|
final double fromY = from.getY();
|
||||||
final double toY = to.getY();
|
final double toY = to.getY();
|
||||||
@ -115,7 +116,7 @@ public class NoFall extends Check {
|
|||||||
|
|
||||||
// TODO: early returns (...)
|
// TODO: early returns (...)
|
||||||
|
|
||||||
final double pY = player.getLocation().getY();
|
final double pY = loc.getY();
|
||||||
final double minY = Math.min(fromY, Math.min(toY, pY));
|
final double minY = Math.min(fromY, Math.min(toY, pY));
|
||||||
|
|
||||||
if (fromReset){
|
if (fromReset){
|
||||||
|
@ -22,7 +22,7 @@ public class Passable extends Check {
|
|||||||
rayTracing.setMaxSteps(60); // TODO: Configurable ?
|
rayTracing.setMaxSteps(60); // TODO: Configurable ?
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location check(final Player player, final PlayerLocation from, final PlayerLocation to, final MovingData data, final MovingConfig cc)
|
public Location check(final Player player, Location loc, final PlayerLocation from, final PlayerLocation to, final MovingData data, final MovingConfig cc)
|
||||||
{
|
{
|
||||||
// Simple check (only from, to, player.getLocation).
|
// Simple check (only from, to, player.getLocation).
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ public class Passable extends Check {
|
|||||||
|
|
||||||
// Check the players location if different from others.
|
// Check the players location if different from others.
|
||||||
// (It provides a better set-back for some exploits.)
|
// (It provides a better set-back for some exploits.)
|
||||||
Location loc = player.getLocation();
|
// Location loc = player.getLocation();
|
||||||
final int lbX = loc.getBlockX();
|
final int lbX = loc.getBlockX();
|
||||||
final int lbY = loc.getBlockY();
|
final int lbY = loc.getBlockY();
|
||||||
final int lbZ = loc.getBlockZ();
|
final int lbZ = loc.getBlockZ();
|
||||||
|
Loading…
Reference in New Issue
Block a user