mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-28 03:17:53 +01:00
Store MCAccess in PlayerLocation and MoveInfo.
This commit is contained in:
parent
817ac36f8b
commit
432c7607aa
@ -46,7 +46,7 @@ public class Critical extends Check {
|
|||||||
|
|
||||||
// We'll need the PlayerLocation to know some important stuff.
|
// We'll need the PlayerLocation to know some important stuff.
|
||||||
final Location loc = player.getLocation();
|
final Location loc = player.getLocation();
|
||||||
final PlayerLocation location = new PlayerLocation(mcAccess.getBlockCache(loc.getWorld()));
|
final PlayerLocation location = new PlayerLocation(mcAccess, mcAccess.getBlockCache(loc.getWorld()));
|
||||||
location.set(loc, player);
|
location.set(loc, player);
|
||||||
if (location.isIllegal()) {
|
if (location.isIllegal()) {
|
||||||
location.cleanup();
|
location.cleanup();
|
||||||
|
@ -39,6 +39,7 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
|
|||||||
import fr.neatmonster.nocheatplus.checks.combined.BedLeave;
|
import fr.neatmonster.nocheatplus.checks.combined.BedLeave;
|
||||||
import fr.neatmonster.nocheatplus.checks.combined.Combined;
|
import fr.neatmonster.nocheatplus.checks.combined.Combined;
|
||||||
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
|
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
|
||||||
|
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||||
@ -73,9 +74,16 @@ import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
|||||||
public class MovingListener extends CheckListener{
|
public class MovingListener extends CheckListener{
|
||||||
|
|
||||||
private static final class MoveInfo{
|
private static final class MoveInfo{
|
||||||
public final BlockCache cache = NoCheatPlus.getMCAccess().getBlockCache(null);
|
public final BlockCache cache;
|
||||||
public final PlayerLocation from = new PlayerLocation(null);
|
public final PlayerLocation from;
|
||||||
public final PlayerLocation to = new PlayerLocation(null);
|
public final PlayerLocation to;
|
||||||
|
|
||||||
|
public MoveInfo(final MCAccess mcAccess){
|
||||||
|
cache = mcAccess.getBlockCache(null);
|
||||||
|
from = new PlayerLocation(mcAccess, null);
|
||||||
|
to = new PlayerLocation(mcAccess, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Demands at least setting from.
|
* Demands at least setting from.
|
||||||
* @param player
|
* @param player
|
||||||
@ -355,7 +363,7 @@ public class MovingListener extends CheckListener{
|
|||||||
// Use existent locations if possible.
|
// Use existent locations if possible.
|
||||||
final MoveInfo moveInfo;
|
final MoveInfo moveInfo;
|
||||||
final PlayerLocation pFrom, pTo;
|
final PlayerLocation pFrom, pTo;
|
||||||
if (parkedInfo.isEmpty()) moveInfo = new MoveInfo();
|
if (parkedInfo.isEmpty()) moveInfo = new MoveInfo(mcAccess);
|
||||||
else moveInfo = parkedInfo.remove(parkedInfo.size() - 1);
|
else moveInfo = parkedInfo.remove(parkedInfo.size() - 1);
|
||||||
pFrom = moveInfo.from;
|
pFrom = moveInfo.from;
|
||||||
pTo = moveInfo.to;
|
pTo = moveInfo.to;
|
||||||
@ -479,7 +487,7 @@ public class MovingListener extends CheckListener{
|
|||||||
{
|
{
|
||||||
// This might get extended to a check-like thing.
|
// This might get extended to a check-like thing.
|
||||||
boolean restored = false;
|
boolean restored = false;
|
||||||
final PlayerLocation pLoc = new PlayerLocation(null);
|
final PlayerLocation pLoc = new PlayerLocation(NoCheatPlus.getMCAccess(), null);
|
||||||
// (Mind that we don't set the block cache here).
|
// (Mind that we don't set the block cache here).
|
||||||
if (!restored && data.setBack != null) {
|
if (!restored && data.setBack != null) {
|
||||||
pLoc.set(data.setBack, player);
|
pLoc.set(data.setBack, player);
|
||||||
@ -795,7 +803,7 @@ public class MovingListener extends CheckListener{
|
|||||||
boolean allowReset = true;
|
boolean allowReset = true;
|
||||||
if (!data.noFallSkipAirCheck){
|
if (!data.noFallSkipAirCheck){
|
||||||
final MoveInfo moveInfo;
|
final MoveInfo moveInfo;
|
||||||
if (parkedInfo.isEmpty()) moveInfo = new MoveInfo();
|
if (parkedInfo.isEmpty()) moveInfo = new MoveInfo(mcAccess);
|
||||||
else moveInfo = parkedInfo.remove(parkedInfo.size() - 1);
|
else moveInfo = parkedInfo.remove(parkedInfo.size() - 1);
|
||||||
moveInfo.set(player, loc, null, cc.noFallyOnGround);
|
moveInfo.set(player, loc, null, cc.noFallyOnGround);
|
||||||
// NOTE: No isIllegal check here.
|
// NOTE: No isIllegal check here.
|
||||||
|
@ -245,7 +245,7 @@ public class BlockProperties {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static BlockCache blockCache = NoCheatPlus.getMCAccess().getBlockCache(null);
|
private static BlockCache blockCache = NoCheatPlus.getMCAccess().getBlockCache(null);
|
||||||
private static final PlayerLocation pLoc = new PlayerLocation(null);
|
private static final PlayerLocation pLoc = new PlayerLocation(NoCheatPlus.getMCAccess(), null);
|
||||||
|
|
||||||
protected static final long[] blockFlags = new long[maxBlocks];
|
protected static final long[] blockFlags = new long[maxBlocks];
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
|
||||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||||
|
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MM"""""""`YM dP
|
* MM"""""""`YM dP
|
||||||
@ -33,6 +33,9 @@ import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
|||||||
*/
|
*/
|
||||||
public class PlayerLocation {
|
public class PlayerLocation {
|
||||||
|
|
||||||
|
// Final members //
|
||||||
|
private final MCAccess mcAccess;
|
||||||
|
|
||||||
// Simple members //
|
// Simple members //
|
||||||
|
|
||||||
/** Y parameter for growing the bounding box with the isOnGround check. */
|
/** Y parameter for growing the bounding box with the isOnGround check. */
|
||||||
@ -101,7 +104,8 @@ public class PlayerLocation {
|
|||||||
private BlockCache blockCache = null;
|
private BlockCache blockCache = null;
|
||||||
|
|
||||||
|
|
||||||
public PlayerLocation(final BlockCache blockCache){
|
public PlayerLocation(final MCAccess mcAccess, final BlockCache blockCache){
|
||||||
|
this.mcAccess = mcAccess;
|
||||||
this.blockCache = blockCache;
|
this.blockCache = blockCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,7 +526,7 @@ public class PlayerLocation {
|
|||||||
// maxY = y + entityPlayer.boundingBox.e + dY;
|
// maxY = y + entityPlayer.boundingBox.e + dY;
|
||||||
// maxZ = z + entityPlayer.boundingBox.f + dZ;
|
// maxZ = z + entityPlayer.boundingBox.f + dZ;
|
||||||
// // TODO: inset, outset ?
|
// // TODO: inset, outset ?
|
||||||
this.width = NoCheatPlus.getMCAccess().getWidthOrLength(player);
|
this.width = mcAccess.getWidthOrLength(player);
|
||||||
final double dxz = this.width / 2;
|
final double dxz = this.width / 2;
|
||||||
|
|
||||||
// final double dX = (entityPlayer.boundingBox.d - entityPlayer.boundingBox.a) / 2D;
|
// final double dX = (entityPlayer.boundingBox.d - entityPlayer.boundingBox.a) / 2D;
|
||||||
@ -574,7 +578,7 @@ public class PlayerLocation {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isIllegal() {
|
public boolean isIllegal() {
|
||||||
final AlmostBoolean spec = NoCheatPlus.getMCAccess().isIllegalBounds(player);
|
final AlmostBoolean spec = mcAccess.isIllegalBounds(player);
|
||||||
if (spec != AlmostBoolean.MAYBE) return spec.decide();
|
if (spec != AlmostBoolean.MAYBE) return spec.decide();
|
||||||
else if (Math.abs(minX) > 3.2E7D || Math.abs(maxX) > 3.2E7D || Math.abs(minY) > 3.2E7D || Math.abs(maxY) > 3.2E7D || Math.abs(minZ) > 3.2E7D || Math.abs(maxZ) > 3.2E7D) return true;
|
else if (Math.abs(minX) > 3.2E7D || Math.abs(maxX) > 3.2E7D || Math.abs(minY) > 3.2E7D || Math.abs(maxY) > 3.2E7D || Math.abs(minZ) > 3.2E7D || Math.abs(maxZ) > 3.2E7D) return true;
|
||||||
// if (Math.abs(box.a) > 3.2E7D || Math.abs(box.b) > 3.2E7D || Math.abs(box.c) > 3.2E7D || Math.abs(box.d) > 3.2E7D || Math.abs(box.e) > 3.2E7D || Math.abs(box.f) > 3.2E7D) return true;
|
// if (Math.abs(box.a) > 3.2E7D || Math.abs(box.b) > 3.2E7D || Math.abs(box.c) > 3.2E7D || Math.abs(box.d) > 3.2E7D || Math.abs(box.e) > 3.2E7D || Math.abs(box.f) > 3.2E7D) return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user