mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-02-12 17:51:30 +01:00
Move: Only get data and config once and pass as arguments.
This commit is contained in:
parent
d35617a862
commit
dc18dded88
@ -56,9 +56,9 @@ public class CreativeFly extends Check {
|
|||||||
* the to
|
* the to
|
||||||
* @return the location
|
* @return the location
|
||||||
*/
|
*/
|
||||||
public Location check(final Player player, final PlayerLocation from, final PlayerLocation to) {
|
public Location check(final Player player, final MovingData data, final MovingConfig cc) {
|
||||||
final MovingConfig cc = MovingConfig.getConfig(player);
|
final PlayerLocation from = data.from;
|
||||||
final MovingData data = MovingData.getData(player);
|
final PlayerLocation to = data.to;
|
||||||
|
|
||||||
// If we have no setback, define one now.
|
// If we have no setback, define one now.
|
||||||
if (data.setBack == null)
|
if (data.setBack == null)
|
||||||
|
@ -60,11 +60,12 @@ public class MorePackets extends Check {
|
|||||||
* the to
|
* the to
|
||||||
* @return the location
|
* @return the location
|
||||||
*/
|
*/
|
||||||
public Location check(final Player player, final PlayerLocation from, final PlayerLocation to) {
|
public Location check(final Player player, final MovingData data, final MovingConfig cc) {
|
||||||
|
final PlayerLocation from = data.from;
|
||||||
|
final PlayerLocation to = data.to;
|
||||||
// Take time once, first:
|
// Take time once, first:
|
||||||
final long time = System.currentTimeMillis();
|
final long time = System.currentTimeMillis();
|
||||||
|
|
||||||
final MovingData data = MovingData.getData(player);
|
|
||||||
|
|
||||||
Location newTo = null;
|
Location newTo = null;
|
||||||
|
|
||||||
|
@ -324,6 +324,7 @@ public class MovingListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
final MovingData data = MovingData.getData(player);
|
final MovingData data = MovingData.getData(player);
|
||||||
|
final MovingConfig cc = MovingConfig.getConfig(player);
|
||||||
|
|
||||||
// Just try to estimate velocities over time. Not very precise, but works good enough most of the time. Do
|
// Just try to estimate velocities over time. Not very precise, but works good enough most of the time. Do
|
||||||
// general data modifications one for each event.
|
// general data modifications one for each event.
|
||||||
@ -351,21 +352,21 @@ public class MovingListener implements Listener {
|
|||||||
|
|
||||||
if ((player.getGameMode() == GameMode.CREATIVE || player.getAllowFlight()) && creativeFly.isEnabled(player))
|
if ((player.getGameMode() == GameMode.CREATIVE || player.getAllowFlight()) && creativeFly.isEnabled(player))
|
||||||
// If the player is handled by the creative fly check, execute it.
|
// If the player is handled by the creative fly check, execute it.
|
||||||
newTo = creativeFly.check(player, data.from, data.to);
|
newTo = creativeFly.check(player, data, cc);
|
||||||
else if (survivalFly.isEnabled(player)) {
|
else if (survivalFly.isEnabled(player)) {
|
||||||
// If he is handled by the survival fly check, execute it.
|
// If he is handled by the survival fly check, execute it.
|
||||||
newTo = survivalFly.check(player, data.from, data.to);
|
newTo = survivalFly.check(player, data, cc);
|
||||||
// If don't have a new location and if he is handled by the no fall check, execute it.
|
// If don't have a new location and if he is handled by the no fall check, execute it.
|
||||||
if (newTo == null && noFall.isEnabled(player))
|
if (newTo == null && noFall.isEnabled(player))
|
||||||
// NOTE: noFall might set yOnGround for the positions.
|
// NOTE: noFall might set yOnGround for the positions.
|
||||||
noFall.check(player, data.from, data.to);
|
noFall.check(player, data, cc);
|
||||||
} else
|
} else
|
||||||
// He isn't handled by any fly check, clear his data.
|
// He isn't handled by any fly check, clear his data.
|
||||||
data.clearFlyData();
|
data.clearFlyData();
|
||||||
|
|
||||||
if (newTo == null && morePackets.isEnabled(player))
|
if (newTo == null && morePackets.isEnabled(player))
|
||||||
// If he hasn't been stopped by any other check and is handled by the more packets check, execute it.
|
// If he hasn't been stopped by any other check and is handled by the more packets check, execute it.
|
||||||
newTo = morePackets.check(player, data.from, data.to);
|
newTo = morePackets.check(player, data, cc);
|
||||||
else
|
else
|
||||||
// Otherwise we need to clear his data.
|
// Otherwise we need to clear his data.
|
||||||
data.clearMorePacketsData();
|
data.clearMorePacketsData();
|
||||||
|
@ -46,10 +46,10 @@ 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) {
|
public void check(final Player player, final MovingData data, final MovingConfig cc) {
|
||||||
final MovingConfig cc = MovingConfig.getConfig(player);
|
final PlayerLocation from = data.from;
|
||||||
final MovingData data = MovingData.getData(player);
|
final PlayerLocation to = data.to;
|
||||||
|
|
||||||
if (from.getY() > to.getY()){
|
if (from.getY() > to.getY()){
|
||||||
// Reset the on ground properties only if necessary.
|
// Reset the on ground properties only if necessary.
|
||||||
if (from.getyOnGround() != cc.noFallyOnGround && (from.getY() - (double) Location.locToBlock(from.getY()) < cc.noFallyOnGround))
|
if (from.getyOnGround() != cc.noFallyOnGround && (from.getY() - (double) Location.locToBlock(from.getY()) < cc.noFallyOnGround))
|
||||||
|
@ -77,9 +77,9 @@ public class SurvivalFly extends Check {
|
|||||||
* the to
|
* the to
|
||||||
* @return the location
|
* @return the location
|
||||||
*/
|
*/
|
||||||
public Location check(final Player player, final PlayerLocation from, final PlayerLocation to) {
|
public Location check(final Player player, final MovingData data, final MovingConfig cc) {
|
||||||
final MovingConfig cc = MovingConfig.getConfig(player);
|
final PlayerLocation from = data.from;
|
||||||
final MovingData data = MovingData.getData(player);
|
final PlayerLocation to = data.to;
|
||||||
|
|
||||||
// A player is considered sprinting if the flag is set and if he has enough food level.
|
// A player is considered sprinting if the flag is set and if he has enough food level.
|
||||||
final boolean sprinting = player.isSprinting() && player.getFoodLevel() > 5;
|
final boolean sprinting = player.isSprinting() && player.getFoodLevel() > 5;
|
||||||
|
Loading…
Reference in New Issue
Block a user