mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-02 13:57:49 +01:00
Rename TypeIdCache to BlockCache.
This commit is contained in:
parent
96f9232dae
commit
b55c43ea71
@ -36,7 +36,7 @@ import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
|||||||
import fr.neatmonster.nocheatplus.players.Permissions;
|
import fr.neatmonster.nocheatplus.players.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
||||||
import fr.neatmonster.nocheatplus.utilities.TypeIdCache;
|
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* M"""""`'"""`YM oo
|
* M"""""`'"""`YM oo
|
||||||
@ -66,13 +66,13 @@ public class MovingListener implements Listener {
|
|||||||
private static final class MoveInfo{
|
private static final class MoveInfo{
|
||||||
public final PlayerLocation from = new PlayerLocation();
|
public final PlayerLocation from = new PlayerLocation();
|
||||||
public final PlayerLocation to = new PlayerLocation();
|
public final PlayerLocation to = new PlayerLocation();
|
||||||
public final TypeIdCache cache = new TypeIdCache();
|
public final BlockCache cache = new BlockCache();
|
||||||
public final void set(final Player player, final Location from, final Location to, final double yOnGround){
|
public final void set(final Player player, final Location from, final Location to, final double yOnGround){
|
||||||
this.from.set(from, player, yOnGround);
|
this.from.set(from, player, yOnGround);
|
||||||
this.to.set(to, player, yOnGround);
|
this.to.set(to, player, yOnGround);
|
||||||
this.cache.setAccess(this.from.getWorldServer());
|
this.cache.setAccess(this.from.getWorldServer());
|
||||||
this.from.setIdCache(cache);
|
this.from.setBlockCache(cache);
|
||||||
this.to.setIdCache(cache);
|
this.to.setBlockCache(cache);
|
||||||
}
|
}
|
||||||
public final void cleanup(){
|
public final void cleanup(){
|
||||||
from.cleanup();
|
from.cleanup();
|
||||||
|
@ -11,11 +11,11 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to type-ids using caching techniques.
|
* Access to type-ids and data using caching techniques.
|
||||||
* @author mc_dev
|
* @author mc_dev
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TypeIdCache implements IBlockAccess{
|
public class BlockCache implements IBlockAccess{
|
||||||
/**
|
/**
|
||||||
* TODO: Make a map for faster queries (without object creation).
|
* TODO: Make a map for faster queries (without object creation).
|
||||||
* TODO: Not sure the prime numbers are too big for normal use.
|
* TODO: Not sure the prime numbers are too big for normal use.
|
||||||
@ -79,14 +79,14 @@ public class TypeIdCache implements IBlockAccess{
|
|||||||
// private int[] id = null;
|
// private int[] id = null;
|
||||||
// private int[] data = null;
|
// private int[] data = null;
|
||||||
|
|
||||||
public TypeIdCache(){
|
public BlockCache(){
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeIdCache(final World world){
|
public BlockCache(final World world){
|
||||||
setAccess(world);
|
setAccess(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeIdCache(final IBlockAccess access){
|
public BlockCache(final IBlockAccess access){
|
||||||
setAccess(access);
|
setAccess(access);
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +96,7 @@ public class PlayerLocation {
|
|||||||
/** The worldServer. */
|
/** The worldServer. */
|
||||||
private WorldServer worldServer;
|
private WorldServer worldServer;
|
||||||
|
|
||||||
private TypeIdCache idCache;
|
private BlockCache blockCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the location.
|
* Gets the location.
|
||||||
@ -337,7 +337,7 @@ public class PlayerLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the player location object. Does not set or reset idCache.
|
* Sets the player location object. Does not set or reset blockCache.
|
||||||
*
|
*
|
||||||
* @param location
|
* @param location
|
||||||
* the location
|
* the location
|
||||||
@ -363,7 +363,7 @@ public class PlayerLocation {
|
|||||||
typeId = typeIdBelow = data = null;
|
typeId = typeIdBelow = data = null;
|
||||||
aboveStairs = inLava = inWater = inWeb = onGround = onIce = onLadder = passable = null;
|
aboveStairs = inLava = inWater = inWeb = onGround = onIce = onLadder = passable = null;
|
||||||
|
|
||||||
// TODO: consider idCache.setAccess.
|
// TODO: consider blockCache.setAccess.
|
||||||
|
|
||||||
this.setyOnGround(yFreedom);
|
this.setyOnGround(yFreedom);
|
||||||
}
|
}
|
||||||
@ -376,7 +376,7 @@ public class PlayerLocation {
|
|||||||
world = null;
|
world = null;
|
||||||
worldServer = null;
|
worldServer = null;
|
||||||
boundingBox = null;
|
boundingBox = null;
|
||||||
idCache = null;
|
blockCache = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getyOnGround() {
|
public double getyOnGround() {
|
||||||
@ -462,7 +462,7 @@ public class PlayerLocation {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public final int getTypeId(final int x, final int y, final int z){
|
public final int getTypeId(final int x, final int y, final int z){
|
||||||
return idCache == null ? worldServer.getTypeId(x, y, z) : idCache.getTypeId(x, y, z);
|
return blockCache == null ? worldServer.getTypeId(x, y, z) : blockCache.getTypeId(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -473,7 +473,7 @@ public class PlayerLocation {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public final int getData(final int x, final int y, final int z){
|
public final int getData(final int x, final int y, final int z){
|
||||||
return idCache == null ? worldServer.getData(x, y, z) : idCache.getData(x, y, z);
|
return blockCache == null ? worldServer.getData(x, y, z) : blockCache.getData(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -481,15 +481,15 @@ public class PlayerLocation {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public final IBlockAccess getBlockAccess() {
|
public final IBlockAccess getBlockAccess() {
|
||||||
return idCache == null ? worldServer : idCache;
|
return blockCache == null ? worldServer : blockCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the id cache for faster id getting.
|
* Set the id cache for faster id getting.
|
||||||
* @param cache
|
* @param cache
|
||||||
*/
|
*/
|
||||||
public void setIdCache(final TypeIdCache cache) {
|
public void setBlockCache(final BlockCache cache) {
|
||||||
this.idCache = cache;
|
this.blockCache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user