mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-06-26 06:14:42 +02:00
[BLEEDING][BREAKING] Registry changes concerning MCAccess.
Main objective is to get rid of too complex setMCAccess methods and to be able to store handles rather permanently instead. * Remove MCAccessHolder. * Add/refine interfaces and implementations. * Change constructors.
This commit is contained in:
parent
92252a9dc4
commit
b6088c3e3a
|
@ -13,13 +13,12 @@ import org.bukkit.event.entity.EntityPortalEnterEvent;
|
|||
|
||||
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.location.LocUtil;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.compat.versions.ServerVersion;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.MCAccessHolder;
|
||||
import fr.neatmonster.nocheatplus.logging.Streams;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.WrapBlockCache;
|
||||
|
||||
/**
|
||||
* Hot fix for 1.9 and 1.10 (possibly later?): falling block duplication via end
|
||||
|
@ -30,7 +29,7 @@ import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
|||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public class HotFixFallingBlockPortalEnter implements Listener, MCAccessHolder {
|
||||
public class HotFixFallingBlockPortalEnter implements Listener {
|
||||
|
||||
public static void testAvailability() {
|
||||
if (ReflectionUtil.getClass("org.bukkit.event.entity.EntityPortalEnterEvent") == null
|
||||
|
@ -45,11 +44,11 @@ public class HotFixFallingBlockPortalEnter implements Listener, MCAccessHolder {
|
|||
/** Temporary use only: setWorld(null) after use. */
|
||||
private final Location useLoc = new Location(null, 0, 0, 0);
|
||||
|
||||
private MCAccess mcAccess;
|
||||
private BlockCache blockCache;
|
||||
private final WrapBlockCache wrapBlockCache; // TODO: Fetch a getter from the registry.
|
||||
|
||||
public HotFixFallingBlockPortalEnter() {
|
||||
testAvailability();
|
||||
wrapBlockCache = new WrapBlockCache();
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
|
@ -75,6 +74,7 @@ public class HotFixFallingBlockPortalEnter implements Listener, MCAccessHolder {
|
|||
final Location loc = entity.getLocation(useLoc);
|
||||
final World world = loc.getWorld();
|
||||
if (InventoryConfig.getConfig(world).hotFixFallingBlockEndPortalActive) {
|
||||
final BlockCache blockCache = wrapBlockCache.getBlockCache();
|
||||
blockCache.setAccess(world);
|
||||
final boolean nearbyPortal = BlockProperties.collidesId(blockCache, loc.getX() - 2.0, loc.getY() - 2.0, loc.getZ() - 2.0, loc.getX() + 3.0, loc.getY() + 3.0, loc.getZ() + 3.0, Material.ENDER_PORTAL);
|
||||
blockCache.cleanup();
|
||||
|
@ -91,15 +91,4 @@ public class HotFixFallingBlockPortalEnter implements Listener, MCAccessHolder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMCAccess(MCAccess mcAccess) {
|
||||
this.mcAccess = mcAccess;
|
||||
this.blockCache = mcAccess.getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCAccess getMCAccess() {
|
||||
return mcAccess;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,11 +33,12 @@ public class BlockCacheBukkit extends BlockCache {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
public BlockCache setAccess(World world) {
|
||||
this.world = world;
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
|
@ -72,6 +72,11 @@ public class MCAccessBukkitBase implements MCAccess {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheBukkit(world);
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.bukkit.entity.Entity;
|
|||
import fr.neatmonster.nocheatplus.compat.bukkit.BlockCacheBukkit;
|
||||
import fr.neatmonster.nocheatplus.compat.cbreflect.reflect.ReflectHelper;
|
||||
import fr.neatmonster.nocheatplus.compat.cbreflect.reflect.ReflectHelper.ReflectFailureException;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheCBReflect extends BlockCacheBukkit {
|
||||
|
||||
|
@ -35,9 +36,10 @@ public class BlockCacheCBReflect extends BlockCacheBukkit {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
public BlockCache setAccess(World world) {
|
||||
super.setAccess(world);
|
||||
this.nmsWorld = world == null ? null : helper.getHandle(world);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,12 +17,6 @@ package fr.neatmonster.nocheatplus.compat.cb2512;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_4_5.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_4_5.IBlockAccess;
|
||||
import net.minecraft.server.v1_4_5.Material;
|
||||
import net.minecraft.server.v1_4_5.TileEntity;
|
||||
import net.minecraft.server.v1_4_5.Vec3DPool;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_4_5.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_4_5.entity.CraftEntity;
|
||||
|
@ -30,112 +24,118 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_4_5.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_4_5.IBlockAccess;
|
||||
import net.minecraft.server.v1_4_5.Material;
|
||||
import net.minecraft.server.v1_4_5.TileEntity;
|
||||
import net.minecraft.server.v1_4_5.Vec3DPool;
|
||||
|
||||
public class BlockCacheCB2512 extends BlockCache implements IBlockAccess{
|
||||
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
protected net.minecraft.server.v1_4_5.World world;
|
||||
|
||||
public BlockCacheCB2512(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
}
|
||||
protected net.minecraft.server.v1_4_5.World world;
|
||||
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
public BlockCacheCB2512(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_4_5.Block block = net.minecraft.server.v1_4_5.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.v(), block.x(), block.z(), block.w(), block.y(), block.A()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_4_5.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_4_5.Entity other = (net.minecraft.server.v1_4_5.Entity) iterator.next();
|
||||
final EntityType type = other.getBukkitEntity().getType();
|
||||
if (type != EntityType.BOAT && type != EntityType.MINECART) continue;
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_4_5.Block block = net.minecraft.server.v1_4_5.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
@Override
|
||||
public boolean isBlockFacePowered(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.isBlockFacePowered(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.v(), block.x(), block.z(), block.w(), block.y(), block.A()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_4_5.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_4_5.Entity other = (net.minecraft.server.v1_4_5.Entity) iterator.next();
|
||||
final EntityType type = other.getBukkitEntity().getType();
|
||||
if (type != EntityType.BOAT && type != EntityType.MINECART) continue;
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockFacePowered(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.isBlockFacePowered(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean t(final int x, final int y, final int z) {
|
||||
return world.t(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean t(final int x, final int y, final int z) {
|
||||
return world.t(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,11 @@ public class MCAccessCB2512 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB2512(world);
|
||||
|
|
|
@ -17,12 +17,6 @@ package fr.neatmonster.nocheatplus.compat.cb2545;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_4_6.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_4_6.IBlockAccess;
|
||||
import net.minecraft.server.v1_4_6.Material;
|
||||
import net.minecraft.server.v1_4_6.TileEntity;
|
||||
import net.minecraft.server.v1_4_6.Vec3DPool;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_4_6.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_4_6.entity.CraftEntity;
|
||||
|
@ -30,112 +24,118 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_4_6.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_4_6.IBlockAccess;
|
||||
import net.minecraft.server.v1_4_6.Material;
|
||||
import net.minecraft.server.v1_4_6.TileEntity;
|
||||
import net.minecraft.server.v1_4_6.Vec3DPool;
|
||||
|
||||
public class BlockCacheCB2545 extends BlockCache implements IBlockAccess{
|
||||
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
protected net.minecraft.server.v1_4_6.World world;
|
||||
|
||||
public BlockCacheCB2545(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
}
|
||||
protected net.minecraft.server.v1_4_6.World world;
|
||||
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
public BlockCacheCB2545(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_4_6.Block block = net.minecraft.server.v1_4_6.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.v(), block.x(), block.z(), block.w(), block.y(), block.A()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_4_6.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_4_6.Entity other = (net.minecraft.server.v1_4_6.Entity) iterator.next();
|
||||
final EntityType type = other.getBukkitEntity().getType();
|
||||
if (type != EntityType.BOAT && type != EntityType.MINECART) continue;
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_4_6.Block block = net.minecraft.server.v1_4_6.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
@Override
|
||||
public boolean isBlockFacePowered(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.isBlockFacePowered(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.v(), block.x(), block.z(), block.w(), block.y(), block.A()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_4_6.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_4_6.Entity other = (net.minecraft.server.v1_4_6.Entity) iterator.next();
|
||||
final EntityType type = other.getBukkitEntity().getType();
|
||||
if (type != EntityType.BOAT && type != EntityType.MINECART) continue;
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockFacePowered(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.isBlockFacePowered(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean t(final int x, final int y, final int z) {
|
||||
return world.t(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean t(final int x, final int y, final int z) {
|
||||
return world.t(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,11 @@ public class MCAccessCB2545 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB2545(world);
|
||||
|
|
|
@ -32,111 +32,112 @@ import org.bukkit.entity.Entity;
|
|||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheCB2602 extends BlockCache implements IBlockAccess{
|
||||
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
protected net.minecraft.server.v1_4_R1.World world;
|
||||
|
||||
public BlockCacheCB2602(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
}
|
||||
protected net.minecraft.server.v1_4_R1.World world;
|
||||
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
public BlockCacheCB2602(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_4_R1.Block block = net.minecraft.server.v1_4_R1.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.v(), block.x(), block.z(), block.w(), block.y(), block.A()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_4_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_4_R1.Entity other = (net.minecraft.server.v1_4_R1.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_4_R1.Block block = net.minecraft.server.v1_4_R1.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
@Override
|
||||
public boolean isBlockFacePowered(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.isBlockFacePowered(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.v(), block.x(), block.z(), block.w(), block.y(), block.A()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_4_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_4_R1.Entity other = (net.minecraft.server.v1_4_R1.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockFacePowered(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.isBlockFacePowered(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean t(final int x, final int y, final int z) {
|
||||
return world.t(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean t(final int x, final int y, final int z) {
|
||||
return world.t(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,6 +65,11 @@ public class MCAccessCB2602 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB2602(world);
|
||||
|
|
|
@ -17,6 +17,12 @@ package fr.neatmonster.nocheatplus.compat.cb2645;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_5_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_5_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_5_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_5_R1.EntityBoat;
|
||||
import net.minecraft.server.v1_5_R1.IBlockAccess;
|
||||
|
@ -24,123 +30,117 @@ import net.minecraft.server.v1_5_R1.Material;
|
|||
import net.minecraft.server.v1_5_R1.TileEntity;
|
||||
import net.minecraft.server.v1_5_R1.Vec3DPool;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_5_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_5_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheCB2645 extends BlockCache implements IBlockAccess{
|
||||
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
protected net.minecraft.server.v1_5_R1.World world;
|
||||
|
||||
public BlockCacheCB2645(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
}
|
||||
protected net.minecraft.server.v1_5_R1.World world;
|
||||
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
public BlockCacheCB2645(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_5_R1.Block block = net.minecraft.server.v1_5_R1.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_5_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_5_R1.Entity other = (net.minecraft.server.v1_5_R1.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_5_R1.Block block = net.minecraft.server.v1_5_R1.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_5_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_5_R1.Entity other = (net.minecraft.server.v1_5_R1.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||
return world.u(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||
return world.u(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,13 +14,6 @@
|
|||
*/
|
||||
package fr.neatmonster.nocheatplus.compat.cb2645;
|
||||
|
||||
import net.minecraft.server.v1_5_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_5_R1.Block;
|
||||
import net.minecraft.server.v1_5_R1.DamageSource;
|
||||
import net.minecraft.server.v1_5_R1.EntityComplexPart;
|
||||
import net.minecraft.server.v1_5_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_5_R1.MobEffectList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
@ -36,6 +29,12 @@ import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
|||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
import net.minecraft.server.v1_5_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_5_R1.Block;
|
||||
import net.minecraft.server.v1_5_R1.DamageSource;
|
||||
import net.minecraft.server.v1_5_R1.EntityComplexPart;
|
||||
import net.minecraft.server.v1_5_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_5_R1.MobEffectList;
|
||||
|
||||
public class MCAccessCB2645 implements MCAccess{
|
||||
|
||||
|
@ -65,6 +64,11 @@ public class MCAccessCB2645 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB2645(world);
|
||||
|
|
|
@ -17,6 +17,12 @@ package fr.neatmonster.nocheatplus.compat.cb2691;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_5_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_5_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_5_R2.EntityBoat;
|
||||
import net.minecraft.server.v1_5_R2.IBlockAccess;
|
||||
|
@ -24,123 +30,117 @@ import net.minecraft.server.v1_5_R2.Material;
|
|||
import net.minecraft.server.v1_5_R2.TileEntity;
|
||||
import net.minecraft.server.v1_5_R2.Vec3DPool;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_5_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheCB2691 extends BlockCache implements IBlockAccess{
|
||||
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
protected net.minecraft.server.v1_5_R2.World world;
|
||||
|
||||
public BlockCacheCB2691(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
}
|
||||
protected net.minecraft.server.v1_5_R2.World world;
|
||||
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
public BlockCacheCB2691(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_5_R2.Block block = net.minecraft.server.v1_5_R2.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_5_R2.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_5_R2.Entity other = (net.minecraft.server.v1_5_R2.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_5_R2.Block block = net.minecraft.server.v1_5_R2.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_5_R2.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_5_R2.Entity other = (net.minecraft.server.v1_5_R2.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||
return world.u(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||
return world.u(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,13 +14,6 @@
|
|||
*/
|
||||
package fr.neatmonster.nocheatplus.compat.cb2691;
|
||||
|
||||
import net.minecraft.server.v1_5_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_5_R2.Block;
|
||||
import net.minecraft.server.v1_5_R2.DamageSource;
|
||||
import net.minecraft.server.v1_5_R2.EntityComplexPart;
|
||||
import net.minecraft.server.v1_5_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_5_R2.MobEffectList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
@ -36,6 +29,12 @@ import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
|||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
import net.minecraft.server.v1_5_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_5_R2.Block;
|
||||
import net.minecraft.server.v1_5_R2.DamageSource;
|
||||
import net.minecraft.server.v1_5_R2.EntityComplexPart;
|
||||
import net.minecraft.server.v1_5_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_5_R2.MobEffectList;
|
||||
|
||||
public class MCAccessCB2691 implements MCAccess{
|
||||
|
||||
|
@ -65,6 +64,11 @@ public class MCAccessCB2691 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB2691(world);
|
||||
|
|
|
@ -17,6 +17,12 @@ package fr.neatmonster.nocheatplus.compat.cb2763;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_5_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_5_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_5_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_5_R3.EntityBoat;
|
||||
import net.minecraft.server.v1_5_R3.IBlockAccess;
|
||||
|
@ -24,123 +30,117 @@ import net.minecraft.server.v1_5_R3.Material;
|
|||
import net.minecraft.server.v1_5_R3.TileEntity;
|
||||
import net.minecraft.server.v1_5_R3.Vec3DPool;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_5_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_5_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheCB2763 extends BlockCache implements IBlockAccess{
|
||||
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
protected net.minecraft.server.v1_5_R3.World world;
|
||||
|
||||
public BlockCacheCB2763(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
}
|
||||
protected net.minecraft.server.v1_5_R3.World world;
|
||||
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
public BlockCacheCB2763(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_5_R3.Block block = net.minecraft.server.v1_5_R3.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_5_R3.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_5_R3.Entity other = (net.minecraft.server.v1_5_R3.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_5_R3.Block block = net.minecraft.server.v1_5_R3.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_5_R3.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_5_R3.Entity other = (net.minecraft.server.v1_5_R3.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||
return world.u(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||
return world.u(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,13 +14,6 @@
|
|||
*/
|
||||
package fr.neatmonster.nocheatplus.compat.cb2763;
|
||||
|
||||
import net.minecraft.server.v1_5_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_5_R3.Block;
|
||||
import net.minecraft.server.v1_5_R3.DamageSource;
|
||||
import net.minecraft.server.v1_5_R3.EntityComplexPart;
|
||||
import net.minecraft.server.v1_5_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_5_R3.MobEffectList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
@ -36,6 +29,12 @@ import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
|||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
import net.minecraft.server.v1_5_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_5_R3.Block;
|
||||
import net.minecraft.server.v1_5_R3.DamageSource;
|
||||
import net.minecraft.server.v1_5_R3.EntityComplexPart;
|
||||
import net.minecraft.server.v1_5_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_5_R3.MobEffectList;
|
||||
|
||||
public class MCAccessCB2763 implements MCAccess{
|
||||
|
||||
|
@ -65,6 +64,11 @@ public class MCAccessCB2763 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB2763(world);
|
||||
|
|
|
@ -17,6 +17,12 @@ package fr.neatmonster.nocheatplus.compat.cb2794;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_6_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_6_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_6_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_6_R1.EntityBoat;
|
||||
import net.minecraft.server.v1_6_R1.IBlockAccess;
|
||||
|
@ -24,123 +30,117 @@ import net.minecraft.server.v1_6_R1.Material;
|
|||
import net.minecraft.server.v1_6_R1.TileEntity;
|
||||
import net.minecraft.server.v1_6_R1.Vec3DPool;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_6_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_6_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheCB2794 extends BlockCache implements IBlockAccess{
|
||||
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
protected net.minecraft.server.v1_6_R1.World world;
|
||||
|
||||
public BlockCacheCB2794(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
}
|
||||
protected net.minecraft.server.v1_6_R1.World world;
|
||||
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
public BlockCacheCB2794(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_6_R1.Block block = net.minecraft.server.v1_6_R1.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_6_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_6_R1.Entity other = (net.minecraft.server.v1_6_R1.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_6_R1.Block block = net.minecraft.server.v1_6_R1.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_6_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_6_R1.Entity other = (net.minecraft.server.v1_6_R1.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||
return world.u(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||
return world.u(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,11 @@ public class MCAccessCB2794 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB2794(world);
|
||||
|
|
|
@ -17,6 +17,12 @@ package fr.neatmonster.nocheatplus.compat.cb2808;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_6_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_6_R2.EntityBoat;
|
||||
import net.minecraft.server.v1_6_R2.IBlockAccess;
|
||||
|
@ -24,123 +30,117 @@ import net.minecraft.server.v1_6_R2.Material;
|
|||
import net.minecraft.server.v1_6_R2.TileEntity;
|
||||
import net.minecraft.server.v1_6_R2.Vec3DPool;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheCB2808 extends BlockCache implements IBlockAccess{
|
||||
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
protected net.minecraft.server.v1_6_R2.World world;
|
||||
|
||||
public BlockCacheCB2808(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
}
|
||||
protected net.minecraft.server.v1_6_R2.World world;
|
||||
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
public BlockCacheCB2808(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_6_R2.Block block = net.minecraft.server.v1_6_R2.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_6_R2.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_6_R2.Entity other = (net.minecraft.server.v1_6_R2.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_6_R2.Block block = net.minecraft.server.v1_6_R2.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_6_R2.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_6_R2.Entity other = (net.minecraft.server.v1_6_R2.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||
return world.u(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||
return world.u(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,6 +65,11 @@ public class MCAccessCB2808 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB2808(world);
|
||||
|
|
|
@ -17,6 +17,12 @@ package fr.neatmonster.nocheatplus.compat.cb2882;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_6_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_6_R3.EntityBoat;
|
||||
import net.minecraft.server.v1_6_R3.IBlockAccess;
|
||||
|
@ -24,123 +30,117 @@ import net.minecraft.server.v1_6_R3.Material;
|
|||
import net.minecraft.server.v1_6_R3.TileEntity;
|
||||
import net.minecraft.server.v1_6_R3.Vec3DPool;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheCB2882 extends BlockCache implements IBlockAccess{
|
||||
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
protected net.minecraft.server.v1_6_R3.World world;
|
||||
|
||||
public BlockCacheCB2882(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
}
|
||||
protected net.minecraft.server.v1_6_R3.World world;
|
||||
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
public BlockCacheCB2882(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_6_R3.Block block = net.minecraft.server.v1_6_R3.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_6_R3.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_6_R3.Entity other = (net.minecraft.server.v1_6_R3.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_6_R3.Block block = net.minecraft.server.v1_6_R3.Block.byId[id];
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_6_R3.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_6_R3.Entity other = (net.minecraft.server.v1_6_R3.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(final int x, final int y, final int z) {
|
||||
return world.getMaterial(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||
return world.u(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||
return world.u(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,6 +66,11 @@ public class MCAccessCB2882 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB2882(world);
|
||||
|
|
|
@ -17,6 +17,12 @@ package fr.neatmonster.nocheatplus.compat.cb2922;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_7_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R1.Block;
|
||||
import net.minecraft.server.v1_7_R1.EntityBoat;
|
||||
|
@ -24,118 +30,112 @@ import net.minecraft.server.v1_7_R1.IBlockAccess;
|
|||
import net.minecraft.server.v1_7_R1.TileEntity;
|
||||
import net.minecraft.server.v1_7_R1.Vec3DPool;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheCB2922 extends BlockCache implements IBlockAccess{
|
||||
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
protected net.minecraft.server.v1_7_R1.WorldServer world;
|
||||
|
||||
public BlockCacheCB2922(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
}
|
||||
protected net.minecraft.server.v1_7_R1.WorldServer world;
|
||||
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
public BlockCacheCB2922(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_7_R1.Block block = net.minecraft.server.v1_7_R1.Block.e(id);
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.x(), block.z(), block.B(), block.y(), block.A(), block.C()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_7_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_7_R1.Entity other = (net.minecraft.server.v1_7_R1.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
@Override
|
||||
public Block getType(int x, int y, int z) {
|
||||
return world.getType(x, y, z);
|
||||
}
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_7_R1.Block block = net.minecraft.server.v1_7_R1.Block.e(id);
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.x(), block.z(), block.B(), block.y(), block.A(), block.C()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_7_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_7_R1.Entity other = (net.minecraft.server.v1_7_R1.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getType(int x, int y, int z) {
|
||||
return world.getType(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3DPool getVec3DPool() {
|
||||
return world.getVec3DPool();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,6 +66,11 @@ public class MCAccessCB2922 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB2922(world);
|
||||
|
|
|
@ -17,119 +17,119 @@ package fr.neatmonster.nocheatplus.compat.cb3026;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_7_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R2.Block;
|
||||
import net.minecraft.server.v1_7_R2.EntityBoat;
|
||||
import net.minecraft.server.v1_7_R2.IBlockAccess;
|
||||
import net.minecraft.server.v1_7_R2.TileEntity;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_7_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_7_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R2.Block;
|
||||
import net.minecraft.server.v1_7_R2.EntityBoat;
|
||||
import net.minecraft.server.v1_7_R2.IBlockAccess;
|
||||
import net.minecraft.server.v1_7_R2.TileEntity;
|
||||
|
||||
public class BlockCacheCB3026 extends BlockCache implements IBlockAccess{
|
||||
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
protected net.minecraft.server.v1_7_R2.WorldServer world;
|
||||
|
||||
public BlockCacheCB3026(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
}
|
||||
protected net.minecraft.server.v1_7_R2.WorldServer world;
|
||||
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
public BlockCacheCB3026(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_7_R2.Block block = net.minecraft.server.v1_7_R2.Block.e(id);
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.x(), block.z(), block.B(), block.y(), block.A(), block.C()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_7_R2.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_7_R2.Entity other = (net.minecraft.server.v1_7_R2.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_7_R2.Block block = net.minecraft.server.v1_7_R2.Block.e(id);
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.x(), block.z(), block.B(), block.y(), block.A(), block.C()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_7_R2.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_7_R2.Entity other = (net.minecraft.server.v1_7_R2.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getType(int x, int y, int z) {
|
||||
return world.getType(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getType(int x, int y, int z) {
|
||||
return world.getType(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,6 +66,11 @@ public class MCAccessCB3026 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB3026(world);
|
||||
|
|
|
@ -17,119 +17,119 @@ package fr.neatmonster.nocheatplus.compat.cb3043;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_7_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R3.Block;
|
||||
import net.minecraft.server.v1_7_R3.EntityBoat;
|
||||
import net.minecraft.server.v1_7_R3.IBlockAccess;
|
||||
import net.minecraft.server.v1_7_R3.TileEntity;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_7_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R3.Block;
|
||||
import net.minecraft.server.v1_7_R3.EntityBoat;
|
||||
import net.minecraft.server.v1_7_R3.IBlockAccess;
|
||||
import net.minecraft.server.v1_7_R3.TileEntity;
|
||||
|
||||
public class BlockCacheCB3043 extends BlockCache implements IBlockAccess{
|
||||
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
protected net.minecraft.server.v1_7_R3.WorldServer world;
|
||||
|
||||
public BlockCacheCB3043(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
}
|
||||
protected net.minecraft.server.v1_7_R3.WorldServer world;
|
||||
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
public BlockCacheCB3043(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_7_R3.Block block = net.minecraft.server.v1_7_R3.Block.e(id);
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.x(), block.z(), block.B(), block.y(), block.A(), block.C()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_7_R3.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_7_R3.Entity other = (net.minecraft.server.v1_7_R3.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return world.getData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
|
||||
// TODO: change api for this / use nodes (!)
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_7_R3.Block block = net.minecraft.server.v1_7_R3.Block.e(id);
|
||||
if (block == null) return null;
|
||||
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{block.x(), block.z(), block.B(), block.y(), block.A(), block.C()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||
try{
|
||||
// TODO: Probably check other ids too before doing this ?
|
||||
|
||||
final net.minecraft.server.v1_7_R3.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List list = world.getEntities(mcEntity, box);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_7_R3.Entity other = (net.minecraft.server.v1_7_R3.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||
return true;
|
||||
}
|
||||
// Still check this for some reason.
|
||||
final AxisAlignedBB otherBox = other.boundingBox;
|
||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t){
|
||||
// Ignore exceptions (Context: DisguiseCraft).
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getType(int x, int y, int z) {
|
||||
return world.getType(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getType(int x, int y, int z) {
|
||||
return world.getType(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,6 +66,11 @@ public class MCAccessCB3043 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB3043(world);
|
||||
|
|
|
@ -17,18 +17,17 @@ package fr.neatmonster.nocheatplus.compat.cb3100;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R4.Block;
|
||||
import net.minecraft.server.v1_7_R4.EntityBoat;
|
||||
import net.minecraft.server.v1_7_R4.IBlockAccess;
|
||||
import net.minecraft.server.v1_7_R4.TileEntity;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R4.Block;
|
||||
import net.minecraft.server.v1_7_R4.EntityBoat;
|
||||
import net.minecraft.server.v1_7_R4.IBlockAccess;
|
||||
import net.minecraft.server.v1_7_R4.TileEntity;
|
||||
|
||||
public class BlockCacheCB3100 extends BlockCache implements IBlockAccess{
|
||||
|
||||
|
@ -42,13 +41,14 @@ public class BlockCacheCB3100 extends BlockCache implements IBlockAccess{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
} else {
|
||||
this.world = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,6 +66,11 @@ public class MCAccessCB3100 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCB3100(world);
|
||||
|
|
|
@ -42,7 +42,7 @@ public class BlockCacheCBDev extends BlockCache implements IBlockAccess {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
|
@ -51,6 +51,7 @@ public class BlockCacheCBDev extends BlockCache implements IBlockAccess {
|
|||
this.world = null;
|
||||
this.bukkitWorld = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
|
@ -111,6 +111,11 @@ public class MCAccessCBDev implements MCAccess {
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheCBDev(world);
|
||||
|
|
|
@ -17,6 +17,12 @@ package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R1;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_8_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R1.EntityBoat;
|
||||
|
@ -25,13 +31,6 @@ import net.minecraft.server.v1_8_R1.IBlockAccess;
|
|||
import net.minecraft.server.v1_8_R1.IBlockData;
|
||||
import net.minecraft.server.v1_8_R1.TileEntity;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheSpigotCB1_8_R1 extends BlockCache implements IBlockAccess{
|
||||
|
||||
protected net.minecraft.server.v1_8_R1.WorldServer world;
|
||||
|
@ -42,7 +41,7 @@ public class BlockCacheSpigotCB1_8_R1 extends BlockCache implements IBlockAccess
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
|
@ -51,6 +50,7 @@ public class BlockCacheSpigotCB1_8_R1 extends BlockCache implements IBlockAccess
|
|||
this.world = null;
|
||||
this.bukkitWorld = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
|
@ -66,6 +66,11 @@ public class MCAccessSpigotCB1_8_R1 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheSpigotCB1_8_R1(world);
|
||||
|
|
|
@ -17,6 +17,12 @@ package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R2;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_8_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R2.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R2.EntityBoat;
|
||||
|
@ -25,13 +31,6 @@ import net.minecraft.server.v1_8_R2.IBlockAccess;
|
|||
import net.minecraft.server.v1_8_R2.IBlockData;
|
||||
import net.minecraft.server.v1_8_R2.TileEntity;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheSpigotCB1_8_R2 extends BlockCache implements IBlockAccess{
|
||||
|
||||
protected net.minecraft.server.v1_8_R2.WorldServer world;
|
||||
|
@ -42,7 +41,7 @@ public class BlockCacheSpigotCB1_8_R2 extends BlockCache implements IBlockAccess
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
|
@ -51,6 +50,7 @@ public class BlockCacheSpigotCB1_8_R2 extends BlockCache implements IBlockAccess
|
|||
this.world = null;
|
||||
this.bukkitWorld = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
|
@ -66,6 +66,11 @@ public class MCAccessSpigotCB1_8_R2 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheSpigotCB1_8_R2(world);
|
||||
|
|
|
@ -17,6 +17,12 @@ package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R3;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R3.EntityBoat;
|
||||
|
@ -25,13 +31,6 @@ import net.minecraft.server.v1_8_R3.IBlockAccess;
|
|||
import net.minecraft.server.v1_8_R3.IBlockData;
|
||||
import net.minecraft.server.v1_8_R3.TileEntity;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheSpigotCB1_8_R3 extends BlockCache implements IBlockAccess{
|
||||
|
||||
protected net.minecraft.server.v1_8_R3.WorldServer world;
|
||||
|
@ -42,7 +41,7 @@ public class BlockCacheSpigotCB1_8_R3 extends BlockCache implements IBlockAccess
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
|
@ -51,6 +50,7 @@ public class BlockCacheSpigotCB1_8_R3 extends BlockCache implements IBlockAccess
|
|||
this.world = null;
|
||||
this.bukkitWorld = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
|
@ -86,6 +86,11 @@ public class MCAccessSpigotCB1_8_R3 implements MCAccess{
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheSpigotCB1_8_R3(world);
|
||||
|
|
|
@ -17,6 +17,12 @@ package fr.neatmonster.nocheatplus.compat.spigotcb1_9_R1;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_9_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_9_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_9_R1.EntityBoat;
|
||||
|
@ -26,13 +32,6 @@ import net.minecraft.server.v1_9_R1.IBlockAccess;
|
|||
import net.minecraft.server.v1_9_R1.IBlockData;
|
||||
import net.minecraft.server.v1_9_R1.TileEntity;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheSpigotCB1_9_R1 extends BlockCache implements IBlockAccess {
|
||||
|
||||
protected net.minecraft.server.v1_9_R1.WorldServer world;
|
||||
|
@ -43,7 +42,7 @@ public class BlockCacheSpigotCB1_9_R1 extends BlockCache implements IBlockAccess
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
|
@ -52,6 +51,7 @@ public class BlockCacheSpigotCB1_9_R1 extends BlockCache implements IBlockAccess
|
|||
this.world = null;
|
||||
this.bukkitWorld = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
|
@ -111,6 +111,11 @@ public class MCAccessSpigotCB1_9_R1 implements MCAccess {
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheSpigotCB1_9_R1(world);
|
||||
|
|
|
@ -17,6 +17,12 @@ package fr.neatmonster.nocheatplus.compat.spigotcb1_9_R2;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import net.minecraft.server.v1_9_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_9_R2.BlockPosition;
|
||||
import net.minecraft.server.v1_9_R2.EntityBoat;
|
||||
|
@ -26,13 +32,6 @@ import net.minecraft.server.v1_9_R2.IBlockAccess;
|
|||
import net.minecraft.server.v1_9_R2.IBlockData;
|
||||
import net.minecraft.server.v1_9_R2.TileEntity;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheSpigotCB1_9_R2 extends BlockCache implements IBlockAccess {
|
||||
|
||||
protected net.minecraft.server.v1_9_R2.WorldServer world;
|
||||
|
@ -43,7 +42,7 @@ public class BlockCacheSpigotCB1_9_R2 extends BlockCache implements IBlockAccess
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
|
@ -52,6 +51,7 @@ public class BlockCacheSpigotCB1_9_R2 extends BlockCache implements IBlockAccess
|
|||
this.world = null;
|
||||
this.bukkitWorld = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
|
@ -111,6 +111,11 @@ public class MCAccessSpigotCB1_9_R2 implements MCAccess {
|
|||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheSpigotCB1_9_R2(world);
|
||||
|
|
|
@ -27,7 +27,7 @@ import fr.neatmonster.nocheatplus.checks.access.ICheckConfig;
|
|||
import fr.neatmonster.nocheatplus.checks.access.ICheckData;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.components.debug.IDebugPlayer;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.MCAccessHolder;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IGenericInstanceHandle;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPHookManager;
|
||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||
import fr.neatmonster.nocheatplus.players.ExecutionHistory;
|
||||
|
@ -71,7 +71,7 @@ import fr.neatmonster.nocheatplus.utilities.TickTask;
|
|||
* actual check.</li>
|
||||
*
|
||||
*/
|
||||
public abstract class Check implements MCAccessHolder, IDebugPlayer {
|
||||
public abstract class Check implements IDebugPlayer {
|
||||
|
||||
// TODO: Do these get cleaned up ?
|
||||
/** The execution histories of each check. */
|
||||
|
@ -94,7 +94,7 @@ public abstract class Check implements MCAccessHolder, IDebugPlayer {
|
|||
/** The type. */
|
||||
protected final CheckType type;
|
||||
|
||||
protected MCAccess mcAccess;
|
||||
protected final IGenericInstanceHandle<MCAccess> mcAccess;
|
||||
|
||||
/**
|
||||
* Instantiates a new check.
|
||||
|
@ -104,7 +104,7 @@ public abstract class Check implements MCAccessHolder, IDebugPlayer {
|
|||
*/
|
||||
public Check(final CheckType type) {
|
||||
this.type = type;
|
||||
mcAccess = NCPAPIProvider.getNoCheatPlusAPI().getMCAccess();
|
||||
mcAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstanceHandle(MCAccess.class);
|
||||
ViolationHistory.checkTypeMap.put(getClass().getName(), type);
|
||||
DataManager.registerExecutionHistory(type, histories);
|
||||
}
|
||||
|
@ -232,16 +232,6 @@ public abstract class Check implements MCAccessHolder, IDebugPlayer {
|
|||
return CheckUtils.hasBypass(type, player, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMCAccess(MCAccess mcAccess) {
|
||||
this.mcAccess = mcAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCAccess getMCAccess() {
|
||||
return mcAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(final Player player, final String message) {
|
||||
CheckUtils.debug(player, type, message);
|
||||
|
|
|
@ -24,8 +24,8 @@ import org.bukkit.entity.Player;
|
|||
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.components.debug.IDebugPlayer;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IGenericInstanceHandle;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.IHoldSubComponents;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.MCAccessHolder;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.NCPListener;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
|
||||
|
@ -35,18 +35,18 @@ import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
|||
* @author mc_dev
|
||||
*
|
||||
*/
|
||||
public class CheckListener extends NCPListener implements MCAccessHolder, IHoldSubComponents, IDebugPlayer {
|
||||
public class CheckListener extends NCPListener implements IHoldSubComponents, IDebugPlayer {
|
||||
|
||||
/** Check group / type which this listener is for. */
|
||||
protected final CheckType checkType;
|
||||
protected MCAccess mcAccess;
|
||||
protected final IGenericInstanceHandle<MCAccess> mcAccess;
|
||||
|
||||
/** */
|
||||
protected final List<Object> queuedComponents = new LinkedList<Object>();
|
||||
|
||||
public CheckListener(CheckType checkType){
|
||||
this.checkType = checkType;
|
||||
this.mcAccess = NCPAPIProvider.getNoCheatPlusAPI().getMCAccess();
|
||||
this.mcAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstanceHandle(MCAccess.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,16 +55,6 @@ public class CheckListener extends NCPListener implements MCAccessHolder, IHoldS
|
|||
return checkType == null ? part : part + "_" + checkType.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMCAccess(MCAccess mcAccess) {
|
||||
this.mcAccess = mcAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCAccess getMCAccess() {
|
||||
return mcAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to add checks as components to NCP with a delay (IHoldSubComponent).
|
||||
* This should not be used after having added the check to the ComponentRegistry (NCP-API).
|
||||
|
|
|
@ -30,15 +30,15 @@ import fr.neatmonster.nocheatplus.checks.ViolationData;
|
|||
import fr.neatmonster.nocheatplus.checks.moving.location.LocUtil;
|
||||
import fr.neatmonster.nocheatplus.checks.net.NetData;
|
||||
import fr.neatmonster.nocheatplus.checks.net.model.DataPacketFlying;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.TrigUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.WrapBlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.collision.InteractRayTracing;
|
||||
|
||||
public class Visible extends Check {
|
||||
|
||||
private BlockCache blockCache;
|
||||
private final WrapBlockCache wrapBlockCache;
|
||||
|
||||
/**
|
||||
* Strict set to false, due to false positives.
|
||||
|
@ -52,20 +52,10 @@ public class Visible extends Check {
|
|||
|
||||
public Visible() {
|
||||
super(CheckType.BLOCKINTERACT_VISIBLE);
|
||||
blockCache = mcAccess.getBlockCache(null);
|
||||
wrapBlockCache = new WrapBlockCache();
|
||||
rayTracing.setMaxSteps(60); // TODO: Configurable ?
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.neatmonster.nocheatplus.checks.Check#setMCAccess(fr.neatmonster.nocheatplus.compat.MCAccess)
|
||||
*/
|
||||
@Override
|
||||
public void setMCAccess(MCAccess mcAccess) {
|
||||
super.setMCAccess(mcAccess);
|
||||
// Renew the BlockCache instance.
|
||||
blockCache = mcAccess.getBlockCache(null);
|
||||
}
|
||||
|
||||
public boolean check(final Player player, final Location loc, final Block block, final BlockFace face, final Action action, final BlockInteractData data, final BlockInteractConfig cc) {
|
||||
// TODO: This check might make parts of interact/blockbreak/... + direction (+?) obsolete.
|
||||
// TODO: Might confine what to check for (left/right-click, target blocks depending on item in hand, container blocks).
|
||||
|
@ -87,6 +77,7 @@ public class Visible extends Check {
|
|||
// Ray-tracing.
|
||||
Vector direction = loc.getDirection();
|
||||
// Initialize.
|
||||
final BlockCache blockCache = this.wrapBlockCache.getBlockCache();
|
||||
blockCache.setAccess(loc.getWorld());
|
||||
rayTracing.setBlockCache(blockCache);
|
||||
collides = checkRayTracing(eyeX, eyeY, eyeZ, direction.getX(), direction.getY(), direction.getZ(), blockX, blockY, blockZ, face, tags, data.debug);
|
||||
|
|
|
@ -380,7 +380,7 @@ public class BlockPlaceListener extends CheckListener {
|
|||
else {
|
||||
final Material mat = player.getLocation(useLoc).getBlock().getType();
|
||||
final long flags = BlockProperties.F_CLIMBABLE | BlockProperties.F_LIQUID | BlockProperties.F_IGN_PASSABLE;
|
||||
if (!BlockProperties.isAir(mat) && (BlockProperties.getBlockFlags(mat) & flags) == 0 && !mcAccess.hasGravity(mat)) {
|
||||
if (!BlockProperties.isAir(mat) && (BlockProperties.getBlockFlags(mat) & flags) == 0 && !mcAccess.getHandle().hasGravity(mat)) {
|
||||
// Still fails on piston traps etc.
|
||||
if (!BlockProperties.isPassable(player.getLocation(), projectile.getLocation()) && !BlockProperties.isOnGroundOrResetCond(player, player.getLocation(), MovingConfig.getConfig(player).yOnGround)) {
|
||||
cancel = true;
|
||||
|
|
|
@ -40,18 +40,18 @@ import fr.neatmonster.nocheatplus.utilities.TickTask;
|
|||
*
|
||||
*/
|
||||
public class CombinedListener extends CheckListener {
|
||||
|
||||
protected final Improbable improbable = addCheck(new Improbable());
|
||||
|
||||
protected final MunchHausen munchHausen = addCheck(new MunchHausen());
|
||||
|
||||
private final Counters counters = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(Counters.class);
|
||||
|
||||
protected final Improbable improbable = addCheck(new Improbable());
|
||||
|
||||
protected final MunchHausen munchHausen = addCheck(new MunchHausen());
|
||||
|
||||
private final Counters counters = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(Counters.class);
|
||||
private final int idFakeInvulnerable = counters.registerKey("fakeinvulnerable");
|
||||
|
||||
public CombinedListener(){
|
||||
super(CheckType.COMBINED);
|
||||
}
|
||||
|
||||
public CombinedListener(){
|
||||
super(CheckType.COMBINED);
|
||||
}
|
||||
|
||||
/**
|
||||
* We listen to this event to prevent players from leaving while falling, so from avoiding fall damages.
|
||||
*
|
||||
|
@ -61,26 +61,26 @@ public class CombinedListener extends CheckListener {
|
|||
@EventHandler(
|
||||
priority = EventPriority.LOWEST)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
|
||||
|
||||
// TODO: EventPriority
|
||||
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final CombinedData data = CombinedData.getData(player);
|
||||
final CombinedConfig cc = CombinedConfig.getConfig(player);
|
||||
|
||||
|
||||
if (cc.invulnerableCheck && (cc.invulnerableTriggerAlways || cc.invulnerableTriggerFallDistance && player.getFallDistance() > 0)){
|
||||
// TODO: maybe make a heuristic for small fall distances with ground under feet (prevents future abuse with jumping) ?
|
||||
final int invulnerableTicks = mcAccess.getInvulnerableTicks(player);
|
||||
final int invulnerableTicks = mcAccess.getHandle().getInvulnerableTicks(player);
|
||||
if (invulnerableTicks == Integer.MAX_VALUE) {
|
||||
// TODO: Maybe log a warning.
|
||||
} else {
|
||||
final int ticks = cc.invulnerableInitialTicksJoin >= 0 ? cc.invulnerableInitialTicksJoin : invulnerableTicks;
|
||||
data.invulnerableTick = TickTask.getTick() + ticks;
|
||||
mcAccess.setInvulnerableTicks(player, 0);
|
||||
mcAccess.getHandle().setInvulnerableTicks(player, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityDamage(final EntityDamageEvent event){
|
||||
final Entity entity = event.getEntity();
|
||||
|
@ -101,7 +101,7 @@ public class CombinedListener extends CheckListener {
|
|||
event.setCancelled(true);
|
||||
counters.addPrimaryThread(idFakeInvulnerable, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A workaround for cancelled PlayerToggleSprintEvents.
|
||||
*
|
||||
|
@ -110,29 +110,29 @@ public class CombinedListener extends CheckListener {
|
|||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR) // HIGHEST)
|
||||
public void onPlayerToggleSprintHighest(final PlayerToggleSprintEvent event) {
|
||||
// // TODO: Check the un-cancelling.
|
||||
// // Some plugins cancel "sprinting", which makes no sense at all because it doesn't stop people from sprinting
|
||||
// // and rewards them by reducing their hunger bar as if they were walking instead of sprinting.
|
||||
// if (event.isCancelled() && event.isSprinting())
|
||||
// event.setCancelled(false);
|
||||
// // TODO: Check the un-cancelling.
|
||||
// // Some plugins cancel "sprinting", which makes no sense at all because it doesn't stop people from sprinting
|
||||
// // and rewards them by reducing their hunger bar as if they were walking instead of sprinting.
|
||||
// if (event.isCancelled() && event.isSprinting())
|
||||
// event.setCancelled(false);
|
||||
// Feed the improbable.
|
||||
Improbable.feed(event.getPlayer(), 0.35f, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onPlayerToggleSneak(final PlayerToggleSneakEvent event){
|
||||
// Check also in case of cancelled events.
|
||||
// Feed the improbable.
|
||||
// Feed the improbable.
|
||||
Improbable.feed(event.getPlayer(), 0.35f, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onPlayerFish(final PlayerFishEvent event){
|
||||
// Check also in case of cancelled events.
|
||||
final Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
if (munchHausen.isEnabled(player) && munchHausen.checkFish(player, event.getCaught(), event.getState())){
|
||||
event.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import fr.neatmonster.nocheatplus.checks.moving.model.LiftOffEnvelope;
|
|||
import fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveInfo;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.util.AuxMoving;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.util.MovingUtil;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
||||
|
@ -50,11 +49,6 @@ public class Critical extends Check {
|
|||
super(CheckType.FIGHT_CRITICAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMCAccess(MCAccess mcAccess) {
|
||||
super.setMCAccess(mcAccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a player.
|
||||
*
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.bukkit.util.Vector;
|
|||
import fr.neatmonster.nocheatplus.checks.Check;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.location.tracking.LocationTrace.ITraceEntry;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.TrigUtil;
|
||||
|
||||
/**
|
||||
|
@ -51,6 +52,8 @@ public class Direction extends Check {
|
|||
final FightData data, final FightConfig cc) {
|
||||
boolean cancel = false;
|
||||
|
||||
final MCAccess mcAccess = this.mcAccess.getHandle();
|
||||
|
||||
// Safeguard, if entity is complex, this check will fail due to giant and hard to define hitboxes.
|
||||
// if (damaged instanceof EntityComplex || damaged instanceof EntityComplexPart)
|
||||
if (!damagedIsFake && mcAccess.isComplexPart(damaged)) {
|
||||
|
@ -123,6 +126,7 @@ public class Direction extends Check {
|
|||
context.damagedWidth = 0.6;
|
||||
}
|
||||
else {
|
||||
final MCAccess mcAccess = this.mcAccess.getHandle();
|
||||
context.damagedComplex = mcAccess.isComplexPart(damaged);
|
||||
context.damagedWidth = mcAccess.getWidth(damaged);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ import fr.neatmonster.nocheatplus.compat.Bridge1_9;
|
|||
import fr.neatmonster.nocheatplus.compat.BridgeEnchant;
|
||||
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
|
||||
import fr.neatmonster.nocheatplus.compat.IBridgeCrossPlugin;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.JoinLeaveListener;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.stats.Counters;
|
||||
|
@ -117,11 +116,6 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
|||
super(CheckType.FIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMCAccess(MCAccess mcAccess) {
|
||||
super.setMCAccess(mcAccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* A player attacked something with DamageCause ENTITY_ATTACK.
|
||||
*
|
||||
|
@ -197,7 +191,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
|||
// }
|
||||
// Log.
|
||||
if (data.debug && damagedPlayer.hasPermission(Permissions.ADMINISTRATION_DEBUG)) {
|
||||
damagedPlayer.sendMessage("Attacked by " + player.getName() + ": inv=" + mcAccess.getInvulnerableTicks(damagedPlayer) + " ndt=" + damagedPlayer.getNoDamageTicks());
|
||||
damagedPlayer.sendMessage("Attacked by " + player.getName() + ": inv=" + mcAccess.getHandle().getInvulnerableTicks(damagedPlayer) + " ndt=" + damagedPlayer.getNoDamageTicks());
|
||||
}
|
||||
// Check for self hit exploits (mind that projectiles are excluded from this.)
|
||||
if (selfHit.isEnabled(player) && selfHit.check(player, damagedPlayer, data, cc)) {
|
||||
|
@ -416,7 +410,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
|||
boolean cancelled = false;
|
||||
|
||||
// (Might pass generic context to factories, for shared + heavy properties.)
|
||||
final SharedContext sharedContext = new SharedContext(damaged, damagedIsFake, mcAccess);
|
||||
final SharedContext sharedContext = new SharedContext(damaged, damagedIsFake, mcAccess.getHandle());
|
||||
final ReachContext reachContext = reachEnabled ? reach.getContext(player, loc, damaged, damagedLoc, data, cc, sharedContext) : null;
|
||||
final DirectionContext directionContext = directionEnabled ? direction.getContext(player, loc, damaged, damagedIsFake, damagedLoc, data, cc, sharedContext) : null;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class GodMode extends Check {
|
|||
final int tick = TickTask.getTick();
|
||||
|
||||
final int noDamageTicks = Math.max(0, player.getNoDamageTicks());
|
||||
final int invulnerabilityTicks = playerIsFake ? 0 : mcAccess.getInvulnerableTicks(player);
|
||||
final int invulnerabilityTicks = playerIsFake ? 0 : mcAccess.getHandle().getInvulnerableTicks(player);
|
||||
|
||||
// TODO: cleanup this leugique beume...
|
||||
|
||||
|
@ -204,9 +204,9 @@ public class GodMode extends Check {
|
|||
public void run() {
|
||||
try {
|
||||
// Check again if the player should be dead, and if the game didn't mark them as dead.
|
||||
if (mcAccess.shouldBeZombie(player)){
|
||||
if (mcAccess.getHandle().shouldBeZombie(player)){
|
||||
// Artificially "kill" them.
|
||||
mcAccess.setDead(player, 19);
|
||||
mcAccess.getHandle().setDead(player, 19);
|
||||
}
|
||||
} catch (final Exception e) {}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class Reach extends Check {
|
|||
final double distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : SURVIVAL_DISTANCE + getDistMod(damaged);
|
||||
final double distanceMin = (distanceLimit - DYNAMIC_RANGE) / distanceLimit;
|
||||
|
||||
final double height = damagedIsFake ? (damaged instanceof LivingEntity ? ((LivingEntity) damaged).getEyeHeight() : 1.75) : mcAccess.getHeight(damaged);
|
||||
final double height = damagedIsFake ? (damaged instanceof LivingEntity ? ((LivingEntity) damaged).getEyeHeight() : 1.75) : mcAccess.getHandle().getHeight(damaged);
|
||||
|
||||
// Refine y position.
|
||||
// TODO: Make a little more accurate by counting in the actual bounding box.
|
||||
|
|
|
@ -83,6 +83,7 @@ import fr.neatmonster.nocheatplus.compat.BridgeHealth;
|
|||
import fr.neatmonster.nocheatplus.compat.BridgeMisc;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.components.modifier.IAttributeAccess;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IGenericInstanceHandle;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.IData;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.IHaveCheckType;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.INeedConfig;
|
||||
|
@ -155,7 +156,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||
/** Auxiliary functionality. */
|
||||
private final AuxMoving aux = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(AuxMoving.class);
|
||||
|
||||
private IAttributeAccess attributeAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(IAttributeAccess.class);
|
||||
private IGenericInstanceHandle<IAttributeAccess> attributeAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstanceHandle(IAttributeAccess.class);
|
||||
|
||||
/** Statistics / debugging counters. */
|
||||
private final Counters counters = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(Counters.class);
|
||||
|
@ -494,7 +495,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||
data.resetTeleported();
|
||||
// Debug.
|
||||
if (data.debug) {
|
||||
outputMoveDebug(player, moveInfo.from, moveInfo.to, Math.max(cc.noFallyOnGround, cc.yOnGround), mcAccess);
|
||||
outputMoveDebug(player, moveInfo.from, moveInfo.to, Math.max(cc.noFallyOnGround, cc.yOnGround), mcAccess.getHandle());
|
||||
}
|
||||
// Check for illegal move and bounding box etc.
|
||||
if ((moveInfo.from.hasIllegalCoords() || moveInfo.to.hasIllegalCoords()) ||
|
||||
|
@ -543,7 +544,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||
// TODO: Collect all these properties within a context object (abstraction + avoid re-fetching).
|
||||
if (player.getFoodLevel() > 5 || player.getAllowFlight() || player.isFlying()) {
|
||||
data.timeSprinting = time;
|
||||
data.multSprinting = attributeAccess.getSprintAttributeMultiplier(player);
|
||||
data.multSprinting = attributeAccess.getHandle().getSprintAttributeMultiplier(player);
|
||||
if (data.multSprinting == Double.MAX_VALUE) {
|
||||
data.multSprinting = 1.30000002;
|
||||
}
|
||||
|
@ -2035,10 +2036,4 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMCAccess(MCAccess mcAccess) {
|
||||
super.setMCAccess(mcAccess);
|
||||
attributeAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(IAttributeAccess.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,10 @@ import org.bukkit.Location;
|
|||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IHandle;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.RichEntityLocation;
|
||||
import fr.neatmonster.nocheatplus.utilities.WrapBlockCache;
|
||||
|
||||
/**
|
||||
* Represent a move with start and end point. Short-term use of
|
||||
|
@ -37,12 +39,12 @@ public abstract class MoveInfo <REL extends RichEntityLocation, E extends Entity
|
|||
* in set. World is set to null on cleanup!
|
||||
*/
|
||||
public final Location useLoc = new Location(null, 0, 0, 0);
|
||||
public final BlockCache cache;
|
||||
public final WrapBlockCache wrapCache;
|
||||
public final REL from;
|
||||
public final REL to;
|
||||
|
||||
public MoveInfo(final MCAccess mcAccess, REL from, REL to){
|
||||
cache = mcAccess.getBlockCache(null);
|
||||
public MoveInfo(final IHandle<MCAccess> mcAccess, REL from, REL to){
|
||||
wrapCache = new WrapBlockCache();
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
@ -59,7 +61,8 @@ public abstract class MoveInfo <REL extends RichEntityLocation, E extends Entity
|
|||
* @param yOnGround
|
||||
*/
|
||||
public final void set(final E entity, final Location from, final Location to, final double yOnGround){
|
||||
this.cache.setAccess(from.getWorld());
|
||||
final BlockCache cache = wrapCache.getBlockCache();
|
||||
cache.setAccess(from.getWorld());
|
||||
this.from.setBlockCache(cache);
|
||||
set(this.from, from, entity, yOnGround);
|
||||
if (to != null){
|
||||
|
@ -88,6 +91,6 @@ public abstract class MoveInfo <REL extends RichEntityLocation, E extends Entity
|
|||
useLoc.setWorld(null);
|
||||
from.cleanup();
|
||||
to.cleanup();
|
||||
cache.cleanup();
|
||||
wrapCache.cleanup();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.bukkit.Location;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IHandle;
|
||||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
||||
|
||||
/**
|
||||
|
@ -28,7 +29,7 @@ import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
|||
*/
|
||||
public class PlayerMoveInfo extends MoveInfo<PlayerLocation, Player> {
|
||||
|
||||
public PlayerMoveInfo(final MCAccess mcAccess){
|
||||
public PlayerMoveInfo(final IHandle<MCAccess> mcAccess){
|
||||
super(mcAccess, new PlayerLocation(mcAccess, null), new PlayerLocation(mcAccess, null));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.bukkit.Location;
|
|||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IHandle;
|
||||
import fr.neatmonster.nocheatplus.utilities.RichEntityLocation;
|
||||
|
||||
public class VehicleMoveInfo extends MoveInfo<RichEntityLocation, Entity> {
|
||||
|
@ -25,7 +26,7 @@ public class VehicleMoveInfo extends MoveInfo<RichEntityLocation, Entity> {
|
|||
/** Add to fullWidth for the bounding box. */
|
||||
private double extendFullWidth = 0.0;
|
||||
|
||||
public VehicleMoveInfo(final MCAccess mcAccess){
|
||||
public VehicleMoveInfo(final IHandle<MCAccess> mcAccess){
|
||||
super(mcAccess, new RichEntityLocation(mcAccess, null), new RichEntityLocation(mcAccess, null));
|
||||
}
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ public class CreativeFly extends Check {
|
|||
|
||||
// TODO: Make this configurable ! [Speed effect should not affect flying if not on ground.]
|
||||
if (model.applyModifiers) {
|
||||
final double speedModifier = mcAccess.getFasterMovementAmplifier(player);
|
||||
final double speedModifier = mcAccess.getHandle().getFasterMovementAmplifier(player);
|
||||
if (speedModifier == Double.NEGATIVE_INFINITY) {
|
||||
fSpeed = 1.0;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class NoFall extends Check {
|
|||
* @param y
|
||||
*/
|
||||
private void handleOnGround(final Player player, final double y, final boolean reallyOnGround, final MovingData data, final MovingConfig cc) {
|
||||
// Damage to be dealt.
|
||||
// Damage to be dealt.
|
||||
final double maxD = estimateDamage(player, y, data);
|
||||
if (maxD >= 1.0) {
|
||||
// Check skipping conditions.
|
||||
|
@ -115,9 +115,9 @@ public class NoFall extends Check {
|
|||
|
||||
|
||||
private void dealFallDamage(final Player player, final double damage) {
|
||||
if (mcAccess.dealFallDamageFiresAnEvent().decide()) {
|
||||
if (mcAccess.getHandle().dealFallDamageFiresAnEvent().decide()) {
|
||||
// TODO: Better decideOptimistically?
|
||||
mcAccess.dealFallDamage(player, damage);
|
||||
mcAccess.getHandle().dealFallDamage(player, damage);
|
||||
}
|
||||
else {
|
||||
final EntityDamageEvent event = BridgeHealth.getEntityDamageEvent(player, DamageCause.FALL, damage);
|
||||
|
@ -125,7 +125,7 @@ public class NoFall extends Check {
|
|||
if (!event.isCancelled()) {
|
||||
// TODO: account for no damage ticks etc.
|
||||
player.setLastDamageCause(event);
|
||||
mcAccess.dealFallDamage(player, BridgeHealth.getDamage(event));
|
||||
mcAccess.getHandle().dealFallDamage(player, BridgeHealth.getDamage(event));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,11 +42,11 @@ import fr.neatmonster.nocheatplus.checks.moving.util.AuxMoving;
|
|||
import fr.neatmonster.nocheatplus.checks.workaround.WRPT;
|
||||
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
|
||||
import fr.neatmonster.nocheatplus.compat.BridgeEnchant;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker.BlockChangeEntry;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker.Direction;
|
||||
import fr.neatmonster.nocheatplus.components.modifier.IAttributeAccess;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IGenericInstanceHandle;
|
||||
import fr.neatmonster.nocheatplus.logging.Streams;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||
|
@ -89,9 +89,10 @@ public class SurvivalFly extends Check {
|
|||
|
||||
private final BlockChangeTracker blockChangeTracker;
|
||||
|
||||
// TODO: handle
|
||||
private final AuxMoving aux = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(AuxMoving.class);
|
||||
|
||||
private IAttributeAccess attributeAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(IAttributeAccess.class);
|
||||
private IGenericInstanceHandle<IAttributeAccess> attributeAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstanceHandle(IAttributeAccess.class);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -745,11 +746,11 @@ public class SurvivalFly extends Check {
|
|||
hAllowedDistance *= data.multSprinting;
|
||||
}
|
||||
// Note: Attributes count in slowness potions, thus leaving out isn't possible.
|
||||
final double attrMod = attributeAccess.getSpeedAttributeMultiplier(player);
|
||||
final double attrMod = attributeAccess.getHandle().getSpeedAttributeMultiplier(player);
|
||||
if (attrMod == Double.MAX_VALUE) {
|
||||
// TODO: Slowness potion.
|
||||
// Count in speed potions.
|
||||
final double speedAmplifier = mcAccess.getFasterMovementAmplifier(player);
|
||||
final double speedAmplifier = mcAccess.getHandle().getFasterMovementAmplifier(player);
|
||||
if (speedAmplifier != Double.NEGATIVE_INFINITY) {
|
||||
hAllowedDistance *= 1.0D + 0.2D * (speedAmplifier + 1);
|
||||
}
|
||||
|
@ -1949,10 +1950,4 @@ public class SurvivalFly extends Check {
|
|||
debug(player, "SurvivalFly Post violation handling tag update:\n" + StringUtil.join(tags, "+"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMCAccess(MCAccess mcAccess) {
|
||||
super.setMCAccess(mcAccess);
|
||||
attributeAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(IAttributeAccess.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,13 +21,14 @@ import org.bukkit.Location;
|
|||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveInfo;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveInfo;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IGenericInstanceHandle;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.IRegisterAsGenericInstance;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.MCAccessHolder;
|
||||
|
||||
/**
|
||||
* Non-static utility, (to be) registered as generic instance.
|
||||
|
@ -35,12 +36,10 @@ import fr.neatmonster.nocheatplus.components.registry.feature.MCAccessHolder;
|
|||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public class AuxMoving implements MCAccessHolder, IRegisterAsGenericInstance {
|
||||
public class AuxMoving implements IRegisterAsGenericInstance {
|
||||
|
||||
// TODO: Move more non-static stuff here.
|
||||
|
||||
private MCAccess mcAccess = null;
|
||||
|
||||
/**
|
||||
* Unused instances.<br>
|
||||
* Might be better due to cascading events in case of actions or plugins doing strange things.
|
||||
|
@ -53,6 +52,8 @@ public class AuxMoving implements MCAccessHolder, IRegisterAsGenericInstance {
|
|||
*/
|
||||
private final List<VehicleMoveInfo> parkedVehicleMoveInfo = new ArrayList<VehicleMoveInfo>(10);
|
||||
|
||||
private final IGenericInstanceHandle<MCAccess> mcAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstanceHandle(MCAccess.class);
|
||||
|
||||
public PlayerMoveInfo usePlayerMoveInfo() {
|
||||
if (parkedPlayerMoveInfo.isEmpty()) {
|
||||
return new PlayerMoveInfo(mcAccess);
|
||||
|
@ -96,7 +97,7 @@ public class AuxMoving implements MCAccessHolder, IRegisterAsGenericInstance {
|
|||
* @return
|
||||
*/
|
||||
public final double getJumpAmplifier(final Player player) {
|
||||
return MovingUtil.getJumpAmplifier(player, mcAccess);
|
||||
return MovingUtil.getJumpAmplifier(player, mcAccess.getHandle());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,17 +135,6 @@ public class AuxMoving implements MCAccessHolder, IRegisterAsGenericInstance {
|
|||
returnVehicleMoveInfo(vMoveInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMCAccess(MCAccess mcAccess) {
|
||||
this.mcAccess = mcAccess;
|
||||
clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCAccess getMCAccess() {
|
||||
return mcAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear parked MovingInfo instances. Called on reload and data removal and
|
||||
* setMCAccess.
|
||||
|
|
|
@ -88,7 +88,7 @@ public class MovingUtil {
|
|||
{
|
||||
// This might get extended to a check-like thing.
|
||||
boolean restored = false;
|
||||
final PlayerLocation pLoc = new PlayerLocation(NCPAPIProvider.getNoCheatPlusAPI().getMCAccess(), null);
|
||||
final PlayerLocation pLoc = new PlayerLocation(NCPAPIProvider.getNoCheatPlusAPI().getGenericInstanceHandle(MCAccess.class), null);
|
||||
// (Mind that we don't set the block cache here).
|
||||
final Location loc = player.getLocation();
|
||||
if (!restored && data.hasSetBack()) {
|
||||
|
|
|
@ -49,10 +49,10 @@ import fr.neatmonster.nocheatplus.checks.moving.util.AuxMoving;
|
|||
import fr.neatmonster.nocheatplus.checks.moving.util.MovingUtil;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.velocity.AccountEntry;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleEntry;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.components.location.IEntityAccessLastPositionAndLook;
|
||||
import fr.neatmonster.nocheatplus.components.location.IGetLocationWithLook;
|
||||
import fr.neatmonster.nocheatplus.components.location.SimplePositionWithLook;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IGenericInstanceHandle;
|
||||
import fr.neatmonster.nocheatplus.logging.StaticLog;
|
||||
import fr.neatmonster.nocheatplus.logging.Streams;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||
|
@ -99,7 +99,7 @@ public class VehicleChecks extends CheckListener {
|
|||
|
||||
/** Access last position fields for an entity. Updated on setMCAccess. */
|
||||
// TODO: Useless.
|
||||
private IEntityAccessLastPositionAndLook lastPosLook = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(IEntityAccessLastPositionAndLook.class);
|
||||
private final IGenericInstanceHandle<IEntityAccessLastPositionAndLook> lastPosLook = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstanceHandle(IEntityAccessLastPositionAndLook.class);
|
||||
|
||||
/** The vehicle more packets check. */
|
||||
private final VehicleMorePackets vehicleMorePackets = addCheck(new VehicleMorePackets());
|
||||
|
@ -111,13 +111,6 @@ public class VehicleChecks extends CheckListener {
|
|||
super(CheckType.MOVING_VEHICLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMCAccess(MCAccess mcAccess) {
|
||||
super.setMCAccess(mcAccess);
|
||||
// Also update posLook.
|
||||
lastPosLook = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(IEntityAccessLastPositionAndLook.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a vehicle moves, its player will be checked for various suspicious behaviors.
|
||||
*
|
||||
|
@ -313,7 +306,7 @@ public class VehicleChecks extends CheckListener {
|
|||
if (data.debug) {
|
||||
if (lastPosLook != null) {
|
||||
// Retrieve last pos.
|
||||
lastPosLook.getPositionAndLook(vehicle, usePos1);
|
||||
lastPosLook.getHandle().getPositionAndLook(vehicle, usePos1);
|
||||
debug(player, "Last position is reported as: " + LocUtil.simpleFormat(usePos1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
|
||||
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
||||
import fr.neatmonster.nocheatplus.logging.StaticLog;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
@ -44,7 +45,7 @@ public class CommandUtil {
|
|||
*/
|
||||
public static CommandMap getCommandMap() {
|
||||
try {
|
||||
return NCPAPIProvider.getNoCheatPlusAPI().getMCAccess().getCommandMap();
|
||||
return NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(MCAccess.class).getCommandMap();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
StaticLog.logSevere(t);
|
||||
|
|
|
@ -53,7 +53,7 @@ public class VersionCommand extends BaseCommand{
|
|||
|
||||
public static List<String> getVersionInfo() {
|
||||
final List<String> lines = new LinkedList<String>();
|
||||
final MCAccess mcAccess = NCPAPIProvider.getNoCheatPlusAPI().getMCAccess();
|
||||
final MCAccess mcAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(MCAccess.class);
|
||||
lines.addAll(Arrays.asList(new String[]{
|
||||
"---- Version information ----",
|
||||
"#### Server ####",
|
||||
|
@ -97,7 +97,7 @@ public class VersionCommand extends BaseCommand{
|
|||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
private static String alt(String x) {
|
||||
return x.replace('(', '~').replace(')', '~');
|
||||
}
|
||||
|
|
|
@ -20,20 +20,25 @@ import org.bukkit.command.CommandMap;
|
|||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.IGetBlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
|
||||
/**
|
||||
* Compatibility interface to get properties for Bukkit instances that need access of CraftBukkit or Minecraft classes.<br>
|
||||
* NOTE: All methods returning AlmostBoolean must never return null, unless stated otherwise.<br>
|
||||
* Compatibility interface to get properties for Bukkit instances that need
|
||||
* access of CraftBukkit or Minecraft classes.<br>
|
||||
* NOTE: All methods returning AlmostBoolean must never return null, unless
|
||||
* stated otherwise.<br>
|
||||
* NOTE: Expect API changes in the near future!<br>
|
||||
* NOTE: If an instance implements BlockPropertiesSetup, the setup method will be called after basic initialization but before configuration is applied.<br>
|
||||
* NOTE: If an instance implements BlockPropertiesSetup, the setup method will
|
||||
* be called after basic initialization but before configuration is applied.<br>
|
||||
* <hr>
|
||||
* TODO: Make minimal.
|
||||
* @author mc_dev
|
||||
*
|
||||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public interface MCAccess {
|
||||
public interface MCAccess extends IGetBlockCache {
|
||||
|
||||
/**
|
||||
* Simple version identifiers, if several must be separated by '|' like "1.4.2|1.4.4|1.4.5", to indicate multiple sub-versions supported use "1.5.x", use "?" to indicate general future support.
|
||||
|
@ -54,8 +59,16 @@ public interface MCAccess {
|
|||
public CommandMap getCommandMap();
|
||||
|
||||
/**
|
||||
* Get a BlockCache implementation.
|
||||
* @param world May be null to store an instance of BlockCache for future use.
|
||||
* Retrieve a new BlockCache instance with access set to null.
|
||||
*/
|
||||
@Override
|
||||
public BlockCache getBlockCache();
|
||||
|
||||
/**
|
||||
* Get a new BlockCache instance.
|
||||
*
|
||||
* @param world
|
||||
* May be null to store an instance of BlockCache for future use.
|
||||
* @return
|
||||
*/
|
||||
public BlockCache getBlockCache(World world);
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package fr.neatmonster.nocheatplus.components;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author asofold
|
||||
* @Deprecated To be removed, use instead:
|
||||
* fr.neatmonster.nocheatplus.components.registry.feature.MCAccessHolder
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MCAccessHolder extends fr.neatmonster.nocheatplus.components.registry.feature.MCAccessHolder {
|
||||
|
||||
}
|
|
@ -22,7 +22,6 @@ import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker;
|
|||
import fr.neatmonster.nocheatplus.components.registry.ComponentRegistry;
|
||||
import fr.neatmonster.nocheatplus.components.registry.ComponentRegistryProvider;
|
||||
import fr.neatmonster.nocheatplus.components.registry.GenericInstanceRegistry;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.MCAccessHolder;
|
||||
import fr.neatmonster.nocheatplus.logging.LogManager;
|
||||
|
||||
|
||||
|
@ -50,7 +49,7 @@ import fr.neatmonster.nocheatplus.logging.LogManager;
|
|||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public interface NoCheatPlusAPI extends ComponentRegistry<Object>, ComponentRegistryProvider, GenericInstanceRegistry, MCAccessHolder {
|
||||
public interface NoCheatPlusAPI extends ComponentRegistry<Object>, ComponentRegistryProvider, GenericInstanceRegistry {
|
||||
|
||||
/**
|
||||
* By default addComponent(Object) will register ComponentFactories as well.
|
||||
|
|
|
@ -25,7 +25,7 @@ package fr.neatmonster.nocheatplus.components.registry.event;
|
|||
* @param <T>
|
||||
* The type instances are registered for.
|
||||
*/
|
||||
public interface IGenericInstanceHandle<T> {
|
||||
public interface IGenericInstanceHandle<T> extends IHandle<T> {
|
||||
|
||||
// TODO: <? extends T> ?
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package fr.neatmonster.nocheatplus.components.registry.event;
|
||||
|
||||
/**
|
||||
* Somehow wrap an instance of a specified type.
|
||||
*
|
||||
* @author asofold
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface IHandle<T> {
|
||||
|
||||
/**
|
||||
* Retrieve the currently stored instance.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public T getHandle();
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package fr.neatmonster.nocheatplus.components.registry.feature;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
/**
|
||||
* Get a BlockCache instance. This may or may not be a new instance, to be
|
||||
* specified by the implementing class.
|
||||
*
|
||||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public interface IGetBlockCache {
|
||||
|
||||
/**
|
||||
* Retrieve a BlockCache instance. If this is always the same one, depends
|
||||
* on the implementation.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BlockCache getBlockCache();
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package fr.neatmonster.nocheatplus.components.registry.feature;
|
||||
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IHandle;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
/**
|
||||
* Wrap a BlockCache instance, update with changes of underlying
|
||||
* BlockCache/MCAccess implementations or other providers, store the same
|
||||
* instance as long as possible. It can not be guaranteed that the returned
|
||||
* instances are the same for two subsequent calls, references to overridden
|
||||
* MCAccess or BlockCache might be stored until the next call to getBlockCache
|
||||
* or getHandle().
|
||||
*
|
||||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public interface IWrapBlockCache extends IGetBlockCache, IHandle<BlockCache> {
|
||||
|
||||
/** Fail-safe convenience call for BlockCache.cleanup. */
|
||||
public void cleanup();
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package fr.neatmonster.nocheatplus.components.registry.feature;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
|
||||
/**
|
||||
* MCAccessHolder will be updated automatically with the current MCAccess.
|
||||
* <br>How to name this...
|
||||
* @author mc_dev
|
||||
*
|
||||
*/
|
||||
public interface MCAccessHolder {
|
||||
/**
|
||||
* Set access.
|
||||
* @param mcAccess
|
||||
*/
|
||||
public void setMCAccess(MCAccess mcAccess);
|
||||
|
||||
/**
|
||||
* Getter.
|
||||
* @return
|
||||
*/
|
||||
public MCAccess getMCAccess();
|
||||
}
|
|
@ -127,8 +127,9 @@ public abstract class BlockCache {
|
|||
*
|
||||
* @param world
|
||||
* the new access
|
||||
* @return This BlockCache instance for chaining.
|
||||
*/
|
||||
public abstract void setAccess(final World world);
|
||||
public abstract BlockCache setAccess(final World world);
|
||||
|
||||
/**
|
||||
* Fetch the type id from the underlying world.
|
||||
|
|
|
@ -43,6 +43,7 @@ import fr.neatmonster.nocheatplus.compat.Bridge1_9;
|
|||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.init.vanilla.VanillaBlocksFactory;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IHandle;
|
||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||
import fr.neatmonster.nocheatplus.config.RawConfigFile;
|
||||
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
|
||||
|
@ -73,22 +74,22 @@ public class BlockProperties {
|
|||
* @deprecated Will be replaced by a generic way to define tools.
|
||||
*/
|
||||
public static enum ToolType{
|
||||
|
||||
|
||||
/** The none. */
|
||||
NONE,
|
||||
|
||||
|
||||
/** The sword. */
|
||||
SWORD,
|
||||
|
||||
|
||||
/** The shears. */
|
||||
SHEARS,
|
||||
|
||||
|
||||
/** The spade. */
|
||||
SPADE,
|
||||
|
||||
|
||||
/** The axe. */
|
||||
AXE,
|
||||
|
||||
|
||||
/** The pickaxe. */
|
||||
PICKAXE,
|
||||
// HOE,
|
||||
|
@ -101,30 +102,30 @@ public class BlockProperties {
|
|||
* @deprecated Will be replaced by a generic way to define tools.
|
||||
*/
|
||||
public static enum MaterialBase{
|
||||
|
||||
|
||||
/** The none. */
|
||||
NONE(0, 1f),
|
||||
|
||||
|
||||
/** The wood. */
|
||||
WOOD(1, 2f),
|
||||
|
||||
|
||||
/** The stone. */
|
||||
STONE(2, 4f),
|
||||
|
||||
|
||||
/** The iron. */
|
||||
IRON(3, 6f),
|
||||
|
||||
|
||||
/** The diamond. */
|
||||
DIAMOND(4, 8f),
|
||||
|
||||
|
||||
/** The gold. */
|
||||
GOLD(5, 12f);
|
||||
/** Index for array. */
|
||||
public final int index;
|
||||
|
||||
|
||||
/** The break multiplier. */
|
||||
public final float breakMultiplier;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new material base.
|
||||
*
|
||||
|
@ -137,7 +138,7 @@ public class BlockProperties {
|
|||
this.index = index;
|
||||
this.breakMultiplier = breakMultiplier;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the by id.
|
||||
*
|
||||
|
@ -161,13 +162,13 @@ public class BlockProperties {
|
|||
* @deprecated Will be replaced by a generic way to define tools.
|
||||
*/
|
||||
public static class ToolProps{
|
||||
|
||||
|
||||
/** The tool type. */
|
||||
public final ToolType toolType;
|
||||
|
||||
|
||||
/** The material base. */
|
||||
public final MaterialBase materialBase;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new tool props.
|
||||
*
|
||||
|
@ -180,14 +181,14 @@ public class BlockProperties {
|
|||
this.toolType = toolType;
|
||||
this.materialBase = materialBase;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return "ToolProps("+toolType + "/"+materialBase+")";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate.
|
||||
*/
|
||||
|
@ -207,18 +208,18 @@ public class BlockProperties {
|
|||
* @deprecated Will be replaced by a generic way to define tools.
|
||||
*/
|
||||
public static class BlockProps{
|
||||
|
||||
|
||||
/** The tool. */
|
||||
public final ToolProps tool;
|
||||
|
||||
|
||||
/** The breaking times. */
|
||||
public final long[] breakingTimes;
|
||||
|
||||
|
||||
/** The hardness. */
|
||||
public final float hardness;
|
||||
/** Factor 2 = 2 times faster. */
|
||||
public final float efficiencyMod;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new block props.
|
||||
*
|
||||
|
@ -230,7 +231,7 @@ public class BlockProperties {
|
|||
public BlockProps(ToolProps tool, float hardness) {
|
||||
this(tool, hardness, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new block props.
|
||||
*
|
||||
|
@ -260,7 +261,7 @@ public class BlockProperties {
|
|||
}
|
||||
this.efficiencyMod = efficiencyMod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new block props.
|
||||
*
|
||||
|
@ -274,7 +275,7 @@ public class BlockProperties {
|
|||
public BlockProps(ToolProps tool, float hardness, long[] breakingTimes) {
|
||||
this(tool, hardness, breakingTimes, 1f);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new block props.
|
||||
*
|
||||
|
@ -293,14 +294,14 @@ public class BlockProperties {
|
|||
this.hardness = hardness;
|
||||
this.efficiencyMod = efficiencyMod;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return "BlockProps(" + hardness + " / " + tool.toString() + " / " + Arrays.toString(breakingTimes) + ")";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate.
|
||||
*/
|
||||
|
@ -473,13 +474,13 @@ public class BlockProperties {
|
|||
|
||||
/** The rt ray. */
|
||||
private static ICollidePassable rtRay = null;
|
||||
|
||||
|
||||
/** The rt axis. */
|
||||
private static ICollidePassable rtAxis = null;
|
||||
|
||||
|
||||
/** The block cache. */
|
||||
private static BlockCache blockCache = null;
|
||||
|
||||
private static WrapBlockCache wrapBlockCache = null;
|
||||
|
||||
/** The p loc. */
|
||||
private static PlayerLocation pLoc = null;
|
||||
|
||||
|
@ -488,7 +489,7 @@ public class BlockProperties {
|
|||
|
||||
/** Flag position for stairs. */
|
||||
public static final long F_STAIRS = 0x1;
|
||||
|
||||
|
||||
/** The Constant F_LIQUID. */
|
||||
public static final long F_LIQUID = 0x2;
|
||||
// TODO: maybe remove F_SOLID use (unless for setting F_GROUND on init).
|
||||
|
@ -496,10 +497,10 @@ public class BlockProperties {
|
|||
public static final long F_SOLID = 0x4;
|
||||
/** Compatibility flag: regard this block as passable always. */
|
||||
public static final long F_IGN_PASSABLE = 0x8;
|
||||
|
||||
|
||||
/** The Constant F_WATER. */
|
||||
public static final long F_WATER = 0x10;
|
||||
|
||||
|
||||
/** The Constant F_LAVA. */
|
||||
public static final long F_LAVA = 0x20;
|
||||
/** Override bounding box: 1.5 blocks high, like fences.<br>
|
||||
|
@ -634,8 +635,8 @@ public class BlockProperties {
|
|||
* @param worldConfigProvider
|
||||
* the world config provider
|
||||
*/
|
||||
public static void init(final MCAccess mcAccess, final WorldConfigProvider<?> worldConfigProvider) {
|
||||
blockCache = mcAccess.getBlockCache(null);
|
||||
public static void init(final IHandle<MCAccess> mcAccess, final WorldConfigProvider<?> worldConfigProvider) {
|
||||
wrapBlockCache = new WrapBlockCache();
|
||||
rtRay = new PassableRayTracing();
|
||||
rtAxis = new PassableAxisTracing();
|
||||
pLoc = new PlayerLocation(mcAccess, null);
|
||||
|
@ -680,7 +681,7 @@ public class BlockProperties {
|
|||
* @param worldConfigProvider
|
||||
* the world config provider
|
||||
*/
|
||||
private static void initTools(final MCAccess mcAccess, final WorldConfigProvider<?> worldConfigProvider) {
|
||||
private static void initTools(final IHandle<MCAccess> mcAccess, final WorldConfigProvider<?> worldConfigProvider) {
|
||||
tools.clear();
|
||||
tools.put(268, new ToolProps(ToolType.SWORD, MaterialBase.WOOD));
|
||||
tools.put(269, new ToolProps(ToolType.SPADE, MaterialBase.WOOD));
|
||||
|
@ -713,12 +714,13 @@ public class BlockProperties {
|
|||
/**
|
||||
* Inits the blocks.
|
||||
*
|
||||
* @param mcAccess
|
||||
* the mc access
|
||||
* @param mcAccessHandle
|
||||
* the mc access handle
|
||||
* @param worldConfigProvider
|
||||
* the world config provider
|
||||
*/
|
||||
private static void initBlocks(final MCAccess mcAccess, final WorldConfigProvider<?> worldConfigProvider) {
|
||||
private static void initBlocks(final IHandle<MCAccess> mcAccessHandle, final WorldConfigProvider<?> worldConfigProvider) {
|
||||
final MCAccess mcAccess = mcAccessHandle.getHandle();
|
||||
// Reset tool props.
|
||||
Arrays.fill(blocks, null);
|
||||
// Initialize block flags
|
||||
|
@ -1346,6 +1348,7 @@ public class BlockProperties {
|
|||
* @return the breaking duration
|
||||
*/
|
||||
public static long getBreakingDuration(final int blockId, final ItemStack itemInHand, final ItemStack helmet, final Player player, final Location location) {
|
||||
final BlockCache blockCache = wrapBlockCache.getBlockCache();
|
||||
blockCache.setAccess(location.getWorld());
|
||||
pLoc.setBlockCache(blockCache);
|
||||
pLoc.set(location, player, 0.3);
|
||||
|
@ -1750,6 +1753,7 @@ public class BlockProperties {
|
|||
*/
|
||||
public static boolean isInLiquid(final Player player, final Location location, final double yOnGround) {
|
||||
// Bit fat workaround, maybe put the object through from check listener ?
|
||||
final BlockCache blockCache = wrapBlockCache.getBlockCache();
|
||||
blockCache.setAccess(location.getWorld());
|
||||
pLoc.setBlockCache(blockCache);
|
||||
pLoc.set(location, player, yOnGround);
|
||||
|
@ -1772,6 +1776,7 @@ public class BlockProperties {
|
|||
*/
|
||||
public static boolean isInWeb(final Player player, final Location location, final double yOnGround) {
|
||||
// Bit fat workaround, maybe put the object through from check listener ?
|
||||
final BlockCache blockCache = wrapBlockCache.getBlockCache();
|
||||
blockCache.setAccess(location.getWorld());
|
||||
pLoc.setBlockCache(blockCache);
|
||||
pLoc.set(location, player, yOnGround);
|
||||
|
@ -1794,6 +1799,7 @@ public class BlockProperties {
|
|||
*/
|
||||
public static boolean isOnGround(final Player player, final Location location, final double yOnGround) {
|
||||
// Bit fat workaround, maybe put the object through from check listener ?
|
||||
final BlockCache blockCache = wrapBlockCache.getBlockCache();
|
||||
blockCache.setAccess(location.getWorld());
|
||||
pLoc.setBlockCache(blockCache);
|
||||
pLoc.set(location, player, yOnGround);
|
||||
|
@ -1815,6 +1821,7 @@ public class BlockProperties {
|
|||
* @return true, if is on ground or reset cond
|
||||
*/
|
||||
public static boolean isOnGroundOrResetCond(final Player player, final Location location, final double yOnGround) {
|
||||
final BlockCache blockCache = wrapBlockCache.getBlockCache();
|
||||
blockCache.setAccess(location.getWorld());
|
||||
pLoc.setBlockCache(blockCache);
|
||||
pLoc.set(location, player, yOnGround);
|
||||
|
@ -1836,6 +1843,7 @@ public class BlockProperties {
|
|||
* @return true, if is reset cond
|
||||
*/
|
||||
public static boolean isResetCond(final Player player, final Location location, final double yOnGround) {
|
||||
final BlockCache blockCache = wrapBlockCache.getBlockCache();
|
||||
blockCache.setAccess(location.getWorld());
|
||||
pLoc.setBlockCache(blockCache);
|
||||
pLoc.set(location, player, yOnGround);
|
||||
|
@ -2733,6 +2741,7 @@ public class BlockProperties {
|
|||
* @return true, if is passable
|
||||
*/
|
||||
public static final boolean isPassable(final World world, final double x, final double y, final double z) {
|
||||
final BlockCache blockCache = wrapBlockCache.getBlockCache();
|
||||
blockCache.setAccess(world);
|
||||
boolean res = isPassable(blockCache, x, y, z, blockCache.getTypeId(x, y, z));
|
||||
blockCache.cleanup();
|
||||
|
@ -2777,6 +2786,7 @@ public class BlockProperties {
|
|||
* @return true, if is passable
|
||||
*/
|
||||
private static boolean isPassable(final ICollidePassable rt, final Location from, final Location to) {
|
||||
final BlockCache blockCache = wrapBlockCache.getBlockCache();
|
||||
blockCache.setAccess(from.getWorld());
|
||||
rt.setMaxSteps(60); // TODO: Configurable ?
|
||||
rt.setBlockCache(blockCache);
|
||||
|
@ -3837,8 +3847,8 @@ public class BlockProperties {
|
|||
public static void cleanup() {
|
||||
pLoc.cleanup();
|
||||
pLoc = null;
|
||||
blockCache.cleanup();
|
||||
blockCache = null;
|
||||
wrapBlockCache.cleanup();
|
||||
wrapBlockCache = null;
|
||||
// TODO: might empty mappings...
|
||||
}
|
||||
|
||||
|
|
|
@ -433,8 +433,9 @@ public class FakeBlockCache extends BlockCache {
|
|||
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#setAccess(org.bukkit.World)
|
||||
*/
|
||||
@Override
|
||||
public void setAccess(World world) {
|
||||
public BlockCache setAccess(World world) {
|
||||
// Ignore.
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IHandle;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
|
@ -41,9 +42,9 @@ public class PlayerLocation extends RichEntityLocation {
|
|||
* @param mcAccess
|
||||
* the mc access
|
||||
* @param blockCache
|
||||
* the block cache
|
||||
* BlockCache instance, may be null.
|
||||
*/
|
||||
public PlayerLocation(final MCAccess mcAccess, final BlockCache blockCache) {
|
||||
public PlayerLocation(final IHandle<MCAccess> mcAccess, final BlockCache blockCache) {
|
||||
super(mcAccess, blockCache);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
|
|||
|
||||
/** Horizontal margin for the bounding box (center towards edge). */
|
||||
double boxMarginHorizontal;
|
||||
|
||||
|
||||
/** Vertical margin for the bounding box (y towards top). */
|
||||
double boxMarginVertical;
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
|
|||
* Instantiates a new rich bounds location.
|
||||
*
|
||||
* @param blockCache
|
||||
* the block cache
|
||||
* BlockCache instance, may be null.
|
||||
*/
|
||||
public RichBoundsLocation(final BlockCache blockCache) {
|
||||
this.blockCache = blockCache;
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IHandle;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
|
@ -31,7 +32,7 @@ public class RichEntityLocation extends RichBoundsLocation {
|
|||
|
||||
/** The mc access. */
|
||||
// Final members //
|
||||
private final MCAccess mcAccess;
|
||||
private final IHandle<MCAccess> mcAccess;
|
||||
|
||||
|
||||
// Simple members //
|
||||
|
@ -67,9 +68,9 @@ public class RichEntityLocation extends RichBoundsLocation {
|
|||
* @param mcAccess
|
||||
* the mc access
|
||||
* @param blockCache
|
||||
* the block cache
|
||||
* BlockCache instance, may be null.
|
||||
*/
|
||||
public RichEntityLocation(final MCAccess mcAccess, final BlockCache blockCache) {
|
||||
public RichEntityLocation(final IHandle<MCAccess> mcAccess, final BlockCache blockCache) {
|
||||
super(blockCache);
|
||||
this.mcAccess = mcAccess;
|
||||
}
|
||||
|
@ -120,11 +121,21 @@ public class RichEntityLocation extends RichBoundsLocation {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieve the internally stored MCAccess instance.
|
||||
* Retrieve the currently registered MCAccess instance.
|
||||
*
|
||||
* @return the MC access
|
||||
*/
|
||||
public MCAccess getMCAccess() {
|
||||
return mcAccess.getHandle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the internally stored IHandle instance for retrieving the currently
|
||||
* registered instance of MCAccess.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IHandle<MCAccess> getMCAccessHandle() {
|
||||
return mcAccess;
|
||||
}
|
||||
|
||||
|
@ -275,6 +286,7 @@ public class RichEntityLocation extends RichBoundsLocation {
|
|||
* the y on ground
|
||||
*/
|
||||
public void set(final Location location, final Entity entity, final double yOnGround) {
|
||||
final MCAccess mcAccess = this.mcAccess.getHandle();
|
||||
doSet(location, entity, mcAccess.getWidth(entity), mcAccess.getHeight(entity), yOnGround);
|
||||
}
|
||||
|
||||
|
@ -292,6 +304,7 @@ public class RichEntityLocation extends RichBoundsLocation {
|
|||
* the y on ground
|
||||
*/
|
||||
public void set(final Location location, final Entity entity, double fullHeight, final double yOnGround) {
|
||||
final MCAccess mcAccess = this.mcAccess.getHandle();
|
||||
doSet(location, entity, mcAccess.getWidth(entity), fullHeight, yOnGround);
|
||||
}
|
||||
|
||||
|
@ -339,6 +352,7 @@ public class RichEntityLocation extends RichBoundsLocation {
|
|||
eyeHeight = fullHeight;
|
||||
}
|
||||
this.entity = entity;
|
||||
final MCAccess mcAccess = this.mcAccess.getHandle();
|
||||
this.width = mcAccess.getWidth(entity);
|
||||
this.height = mcAccess.getHeight(entity);
|
||||
standsOnEntity = false;
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package fr.neatmonster.nocheatplus.utilities;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IGenericInstanceHandle;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.IWrapBlockCache;
|
||||
|
||||
/**
|
||||
* Wrap a BlockCache instance, and ensure on getting, that it is the latest
|
||||
* registered implementation. Default implementation returned with the
|
||||
* NoCheatPlusAPI. This might keep references to previously used
|
||||
* implementations, which could leak memory.
|
||||
*
|
||||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public class WrapBlockCache implements IWrapBlockCache {
|
||||
|
||||
private final IGenericInstanceHandle<MCAccess> mcAccess;
|
||||
private MCAccess lastMCAccess;
|
||||
|
||||
private BlockCache blockCache;
|
||||
|
||||
public WrapBlockCache() {
|
||||
mcAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstanceHandle(MCAccess.class);
|
||||
lastMCAccess = mcAccess == null ? null : mcAccess.getHandle();
|
||||
blockCache = mcAccess == null ? null : lastMCAccess.getBlockCache();
|
||||
}
|
||||
|
||||
private BlockCache getInstance() {
|
||||
if (lastMCAccess == mcAccess.getHandle()) {
|
||||
return blockCache;
|
||||
}
|
||||
else {
|
||||
lastMCAccess = mcAccess.getHandle();
|
||||
// TODO: This would make an initialized block cache uninitialized.
|
||||
blockCache = lastMCAccess.getBlockCache();
|
||||
return blockCache;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getHandle() {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup() {
|
||||
if (blockCache != null) {
|
||||
blockCache.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -29,7 +29,6 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -93,7 +92,6 @@ import fr.neatmonster.nocheatplus.components.registry.feature.INotifyReload;
|
|||
import fr.neatmonster.nocheatplus.components.registry.feature.IPostRegisterRunnable;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.IRegisterAsGenericInstance;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.JoinLeaveListener;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.MCAccessHolder;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.NCPListener;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.NameSetPermState;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.PermStateReceiver;
|
||||
|
@ -159,9 +157,6 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
|||
/** Lower case player name to milliseconds point of time of release */
|
||||
private final Map<String, Long> denyLoginNames = Collections.synchronizedMap(new HashMap<String, Long>());
|
||||
|
||||
/** MCAccess instance. */
|
||||
protected MCAccess mcAccess = null;
|
||||
|
||||
/** Configuration problems (likely put to ConfigManager later). */
|
||||
protected String configProblems = null;
|
||||
|
||||
|
@ -233,6 +228,8 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
|||
|
||||
private final DefaultGenericInstanceRegistry genericInstanceRegistry = new DefaultGenericInstanceRegistry();
|
||||
|
||||
/** Self-updating MCAccess reference. */
|
||||
protected final IGenericInstanceHandle<MCAccess> mcAccess = genericInstanceRegistry.getGenericInstanceHandle(MCAccess.class);
|
||||
|
||||
/** Tick listener that is only needed sometimes (component registration). */
|
||||
protected final OnDemandTickListener onDemandTickListener = new OnDemandTickListener() {
|
||||
|
@ -508,11 +505,6 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
|||
permStateReceivers.add((PermStateReceiver) obj);
|
||||
added = true;
|
||||
}
|
||||
if (obj instanceof MCAccessHolder) {
|
||||
// These will get notified in initMcAccess (iterates over allComponents).
|
||||
((MCAccessHolder) obj).setMCAccess(getMCAccess());
|
||||
added = true;
|
||||
}
|
||||
if (obj instanceof ConsistencyChecker) {
|
||||
consistencyCheckers.add((ConsistencyChecker) obj);
|
||||
added = true;
|
||||
|
@ -1204,86 +1196,40 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
|||
return logManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCAccess getMCAccess() {
|
||||
if (mcAccess == null) {
|
||||
initMCAccess();
|
||||
}
|
||||
return mcAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fall-back method to initialize from factory, only if not yet set. Uses the BukkitScheduler to ensure this works if called from async checks.
|
||||
*/
|
||||
private void initMCAccess() {
|
||||
// TODO: Remove or log.
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
initMCAccess(ConfigManager.getConfigFile());
|
||||
}
|
||||
else {
|
||||
getServer().getScheduler().callSyncMethod(this, new Callable<MCAccess>() {
|
||||
@Override
|
||||
public MCAccess call() throws Exception {
|
||||
if (mcAccess != null) {
|
||||
return mcAccess;
|
||||
}
|
||||
else {
|
||||
return initMCAccess(ConfigManager.getConfigFile());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-setup MCAccess from internal factory and pass it to MCAccessHolder components, only call from the main thread.
|
||||
* (Re-) Setup MCAccess and other access providers from the internal
|
||||
* factories. Only call from the primary thread.
|
||||
*
|
||||
* @param config
|
||||
*/
|
||||
public MCAccess initMCAccess(final ConfigFile config) {
|
||||
private MCAccess initMCAccess(final ConfigFile config) {
|
||||
// TODO: Auto registry with unregister on reload hooks (more clean reload).
|
||||
// Reset MCAccess.
|
||||
// TODO: Might fire a NCPSetMCAccessFromFactoryEvent (include getting and setting)!
|
||||
final MCAccessConfig mcaC = new MCAccessConfig(config);
|
||||
final MCAccess mcAccess = new MCAccessFactory().getMCAccess(mcaC);
|
||||
// TODO: Consider registry events for generic instances too.
|
||||
new AttributeAccessFactory().setupAttributeAccess(mcAccess, mcaC);
|
||||
new EntityAccessFactory().setupEntityAccess(mcAccess, mcaC);
|
||||
|
||||
setMCAccess(mcAccess);
|
||||
// Set in registry.
|
||||
// TODO: Perhaps make MCAccess an aggregate thing for the more fine grained parts.
|
||||
genericInstanceRegistry.registerGenericInstance(MCAccess.class, mcAccess);
|
||||
|
||||
// TODO: Summary event or listener call-back (possibly in another place.).
|
||||
|
||||
// Log.
|
||||
logManager.info(Streams.INIT, "McAccess set to: " + mcAccess.getMCVersion() + " / " + mcAccess.getServerVersionTag());
|
||||
|
||||
return mcAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set and propagate to registered MCAccessHolder instances.
|
||||
*/
|
||||
@Override
|
||||
public void setMCAccess(final MCAccess mcAccess) {
|
||||
// Just sets it and propagates it.
|
||||
// TODO: Might fire a NCPSetMCAccessEvent (include getting and setting)!
|
||||
// TODO: Store a list of MCAccessHolder.
|
||||
this.mcAccess = mcAccess;
|
||||
// TODO: Deprecate MCAccessHolder
|
||||
for (final Object obj : this.allComponents) {
|
||||
if (obj instanceof MCAccessHolder) {
|
||||
try{
|
||||
((MCAccessHolder) obj).setMCAccess(mcAccess);
|
||||
} catch(Throwable t) {
|
||||
logManager.severe(Streams.INIT, "MCAccessHolder(" + obj.getClass().getName() + ") failed to set MCAccess: " + t.getClass().getSimpleName());
|
||||
logManager.severe(Streams.INIT, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Set in registry.
|
||||
genericInstanceRegistry.registerGenericInstance(MCAccess.class, mcAccess);
|
||||
// Log.
|
||||
logManager.info(Streams.INIT, "McAccess set to: " + mcAccess.getMCVersion() + " / " + mcAccess.getServerVersionTag());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize BlockProperties, including config.
|
||||
* Initialize BlockProperties, including config. Needs initMCAccess to be
|
||||
* called before.
|
||||
*/
|
||||
protected void initBlockProperties(ConfigFile config) {
|
||||
// Set up BlockProperties.
|
||||
BlockProperties.init(getMCAccess(), ConfigManager.getWorldConfigProvider());
|
||||
BlockProperties.init(mcAccess, ConfigManager.getWorldConfigProvider());
|
||||
BlockProperties.applyConfig(config, ConfPaths.COMPATIBILITY_BLOCKS);
|
||||
// Schedule dumping the blocks properties (to let other plugins override).
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||
|
|
|
@ -19,10 +19,8 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
||||
import fr.neatmonster.nocheatplus.compat.IBridgeCrossPlugin;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.compat.cbreflect.reflect.ReflectBase;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.IPostRegisterRunnable;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.MCAccessHolder;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
/**
|
||||
|
@ -32,12 +30,10 @@ import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
|||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public class BridgeCrossPlugin implements IBridgeCrossPlugin, IPostRegisterRunnable, MCAccessHolder {
|
||||
public class BridgeCrossPlugin implements IBridgeCrossPlugin, IPostRegisterRunnable {
|
||||
|
||||
// TODO: More sophisticated checking ?
|
||||
|
||||
private MCAccess mcAccess;
|
||||
|
||||
private final Class<?> playerClass;
|
||||
private final Class<?> entityClass;
|
||||
|
||||
|
@ -70,17 +66,6 @@ public class BridgeCrossPlugin implements IBridgeCrossPlugin, IPostRegisterRunna
|
|||
NCPAPIProvider.getNoCheatPlusAPI().registerGenericInstance(IBridgeCrossPlugin.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMCAccess(MCAccess mcAccess) {
|
||||
// TODO: Should adapt to mcAccess?
|
||||
this.mcAccess = mcAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCAccess getMCAccess() {
|
||||
return mcAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNativePlayer(final Player player) {
|
||||
return playerClass != null && playerClass.isAssignableFrom(player.getClass());
|
||||
|
|
|
@ -23,6 +23,7 @@ import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker;
|
|||
import fr.neatmonster.nocheatplus.compat.bukkit.MCAccessBukkit;
|
||||
import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI;
|
||||
import fr.neatmonster.nocheatplus.components.registry.ComponentRegistry;
|
||||
import fr.neatmonster.nocheatplus.components.registry.DefaultGenericInstanceRegistry;
|
||||
import fr.neatmonster.nocheatplus.components.registry.event.IGenericInstanceHandle;
|
||||
import fr.neatmonster.nocheatplus.logging.LogManager;
|
||||
import fr.neatmonster.nocheatplus.logging.StaticLog;
|
||||
|
@ -36,16 +37,10 @@ public class PluginTests {
|
|||
*/
|
||||
public static class DummyNoCheatPlusAPI implements NoCheatPlusAPI {
|
||||
|
||||
private MCAccess mcAccess = new MCAccessBukkit();
|
||||
private final DefaultGenericInstanceRegistry genericInstanceRegistry = new DefaultGenericInstanceRegistry();
|
||||
|
||||
@Override
|
||||
public void setMCAccess(MCAccess mcAccess) {
|
||||
this.mcAccess = mcAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCAccess getMCAccess() {
|
||||
return mcAccess;
|
||||
public DummyNoCheatPlusAPI() {
|
||||
genericInstanceRegistry.registerGenericInstance(MCAccess.class, new MCAccessBukkit());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,22 +65,22 @@ public class PluginTests {
|
|||
|
||||
@Override
|
||||
public <T, TI extends T> T registerGenericInstance(Class<T> registerFor, TI instance) {
|
||||
throw new UnsupportedOperationException();
|
||||
return genericInstanceRegistry.registerGenericInstance(registerFor, instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getGenericInstance(Class<T> registeredFor) {
|
||||
throw new UnsupportedOperationException();
|
||||
return genericInstanceRegistry.getGenericInstance(registeredFor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T unregisterGenericInstance(Class<T> registeredFor) {
|
||||
throw new UnsupportedOperationException();
|
||||
return genericInstanceRegistry.unregisterGenericInstance(registeredFor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> IGenericInstanceHandle<T> getGenericInstanceHandle(Class<T> registeredFor) {
|
||||
throw new UnsupportedOperationException();
|
||||
return genericInstanceRegistry.getGenericInstanceHandle(registeredFor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
|
||||
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
||||
import fr.neatmonster.nocheatplus.PluginTests;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
||||
import fr.neatmonster.nocheatplus.config.DefaultConfig;
|
||||
import fr.neatmonster.nocheatplus.config.RawConfigFile;
|
||||
|
@ -71,7 +72,7 @@ public class BlockTests {
|
|||
*/
|
||||
public static void initBlockProperties() {
|
||||
PluginTests.setDummNoCheatPlusAPI(false);
|
||||
BlockProperties.init(NCPAPIProvider.getNoCheatPlusAPI().getMCAccess(), new DefaultConfigWorldConfigProvider());
|
||||
BlockProperties.init(NCPAPIProvider.getNoCheatPlusAPI().getGenericInstanceHandle(MCAccess.class), new DefaultConfigWorldConfigProvider());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user