mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-03-02 10:31:25 +01:00
Change signature of MCAccess.isIllegal to AlmostBoolean.
This commit is contained in:
parent
b397c491fc
commit
e2a1fc6a2d
@ -10,7 +10,8 @@ import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
/**
|
||||
* Compatibility interface to get properties for Bukkit instances that need access of CraftBukkit or Minecraft classes.<br>
|
||||
* NOTE: Expect API changes in the near future!
|
||||
* NOTE: All methods returning AlmostBoolean must never return null, unless stated otherwise.<br>
|
||||
* NOTE: Expect API changes in the near future!<br>
|
||||
* <hr>
|
||||
* TODO: Make minimal (do we need WorldServer yet)?
|
||||
* @author mc_dev
|
||||
@ -71,7 +72,7 @@ public interface MCAccess {
|
||||
* @param player
|
||||
* @return null If undecided, true / false if decided.
|
||||
*/
|
||||
public Boolean isIllegalBounds(Player player);
|
||||
public AlmostBoolean isIllegalBounds(Player player);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -92,17 +92,17 @@ public class MCAccessCB2511 implements MCAccess {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isIllegalBounds(final Player player) {
|
||||
public AlmostBoolean isIllegalBounds(final Player player) {
|
||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||
if (entityPlayer.dead) return false;
|
||||
if (entityPlayer.dead) return AlmostBoolean.NO;
|
||||
final AxisAlignedBB box = entityPlayer.boundingBox;
|
||||
if (!entityPlayer.isSleeping()){
|
||||
// This can not really test stance but height of bounding box.
|
||||
final double dY = Math.abs(box.e - box.b);
|
||||
if (dY > 1.8) return true; // dY > 1.65D ||
|
||||
if (dY < 0.1D) return true;
|
||||
if (dY > 1.8) return AlmostBoolean.YES; // dY > 1.65D ||
|
||||
if (dY < 0.1D) return AlmostBoolean.YES;
|
||||
}
|
||||
return null;
|
||||
return AlmostBoolean.MAYBE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,17 +91,17 @@ public class MCAccessCB2512 implements MCAccess{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isIllegalBounds(final Player player) {
|
||||
public AlmostBoolean isIllegalBounds(final Player player) {
|
||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||
if (entityPlayer.dead) return false;
|
||||
if (entityPlayer.dead) return AlmostBoolean.NO;
|
||||
final AxisAlignedBB box = entityPlayer.boundingBox;
|
||||
if (!entityPlayer.isSleeping()){
|
||||
// This can not really test stance but height of bounding box.
|
||||
final double dY = Math.abs(box.e - box.b);
|
||||
if (dY > 1.8) return true; // dY > 1.65D ||
|
||||
if (dY < 0.1D) return true;
|
||||
if (dY > 1.8) return AlmostBoolean.YES; // dY > 1.65D ||
|
||||
if (dY < 0.1D) return AlmostBoolean.YES;
|
||||
}
|
||||
return null;
|
||||
return AlmostBoolean.MAYBE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
|
||||
/*
|
||||
* MM"""""""`YM dP
|
||||
@ -569,8 +569,8 @@ public class PlayerLocation {
|
||||
* @return
|
||||
*/
|
||||
public boolean isIllegal() {
|
||||
final Boolean spec = NoCheatPlus.getMCAccess().isIllegalBounds(player);
|
||||
if (spec != null) return spec.booleanValue();
|
||||
final AlmostBoolean spec = NoCheatPlus.getMCAccess().isIllegalBounds(player);
|
||||
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;
|
||||
// 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;
|
||||
else return false;
|
||||
|
Loading…
Reference in New Issue
Block a user