This commit is contained in:
Glitchfinder
2013-01-10 09:27:05 -08:00
118 changed files with 2050 additions and 1996 deletions

View File

@ -6,10 +6,10 @@ public class ChunkletManagerFactory {
public static ChunkletManager getChunkletManager() {
HiddenConfig hConfig = HiddenConfig.getInstance();
if(hConfig.getChunkletsEnabled()) {
if (hConfig.getChunkletsEnabled()) {
return new HashChunkletManager();
} else {
return new NullChunkletManager();
}
return new NullChunkletManager();
}
}

View File

@ -25,14 +25,14 @@ public class HashChunkletManager implements ChunkletManager {
public void loadChunklet(int cx, int cy, int cz, World world) {
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
File cxDir = new File(dataDir, "" + cx);
if(!cxDir.exists()) return;
if (!cxDir.exists()) return;
File czDir = new File(cxDir, "" + cz);
if(!czDir.exists()) return;
if (!czDir.exists()) return;
File yFile = new File(czDir, "" + cy);
if(!yFile.exists()) return;
if (!yFile.exists()) return;
ChunkletStore in = deserializeChunkletStore(yFile);
if(in != null) {
if (in != null) {
store.put(world.getName() + "," + cx + "," + cz + "," + cy, in);
}
}
@ -40,11 +40,11 @@ public class HashChunkletManager implements ChunkletManager {
@Override
public void unloadChunklet(int cx, int cy, int cz, World world) {
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
if(store.containsKey(world.getName() + "," + cx + "," + cz + "," + cy)) {
if (store.containsKey(world.getName() + "," + cx + "," + cz + "," + cy)) {
File cxDir = new File(dataDir, "" + cx);
if(!cxDir.exists()) cxDir.mkdir();
if (!cxDir.exists()) cxDir.mkdir();
File czDir = new File(cxDir, "" + cz);
if(!czDir.exists()) czDir.mkdir();
if (!czDir.exists()) czDir.mkdir();
File yFile = new File(czDir, "" + cy);
ChunkletStore out = store.get(world.getName() + "," + cx + "," + cz + "," + cy);
@ -57,19 +57,19 @@ public class HashChunkletManager implements ChunkletManager {
public void loadChunk(int cx, int cz, World world) {
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
File cxDir = new File(dataDir, "" + cx);
if(!cxDir.exists()) return;
if (!cxDir.exists()) return;
File czDir = new File(cxDir, "" + cz);
if(!czDir.exists()) return;
if (!czDir.exists()) return;
for(int y = 0; y < 4; y++) {
for (int y = 0; y < 4; y++) {
File yFile = new File(czDir, "" + y);
if(!yFile.exists()) {
if (!yFile.exists()) {
continue;
} else {
ChunkletStore in = deserializeChunkletStore(yFile);
if(in != null) {
store.put(world.getName() + "," + cx + "," + cz + "," + y, in);
}
}
ChunkletStore in = deserializeChunkletStore(yFile);
if (in != null) {
store.put(world.getName() + "," + cx + "," + cz + "," + y, in);
}
}
}
@ -78,12 +78,12 @@ public class HashChunkletManager implements ChunkletManager {
public void unloadChunk(int cx, int cz, World world) {
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
for(int y = 0; y < 4; y++) {
if(store.containsKey(world.getName() + "," + cx + "," + cz + "," + y)) {
for (int y = 0; y < 4; y++) {
if (store.containsKey(world.getName() + "," + cx + "," + cz + "," + y)) {
File cxDir = new File(dataDir, "" + cx);
if(!cxDir.exists()) cxDir.mkdir();
if (!cxDir.exists()) cxDir.mkdir();
File czDir = new File(cxDir, "" + cz);
if(!czDir.exists()) czDir.mkdir();
if (!czDir.exists()) czDir.mkdir();
File yFile = new File(czDir, "" + y);
ChunkletStore out = store.get(world.getName() + "," + cx + "," + cz + "," + y);
@ -107,16 +107,16 @@ public class HashChunkletManager implements ChunkletManager {
public void saveWorld(World world) {
String worldName = world.getName();
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
if(!dataDir.exists())
if (!dataDir.exists())
dataDir.mkdirs();
for(String key : store.keySet()) {
for (String key : store.keySet()) {
String[] info = key.split(",");
if(worldName.equals(info[0])) {
if (worldName.equals(info[0])) {
File cxDir = new File(dataDir, "" + info[1]);
if(!cxDir.exists()) cxDir.mkdir();
if (!cxDir.exists()) cxDir.mkdir();
File czDir = new File(cxDir, "" + info[2]);
if(!czDir.exists()) czDir.mkdir();
if (!czDir.exists()) czDir.mkdir();
File yFile = new File(czDir, "" + info[3]);
serializeChunkletStore(store.get(key), yFile);
@ -130,9 +130,9 @@ public class HashChunkletManager implements ChunkletManager {
String worldName = world.getName();
for(String key : store.keySet()) {
for (String key : store.keySet()) {
String tempWorldName = key.split(",")[0];
if(tempWorldName.equals(worldName)) {
if (tempWorldName.equals(worldName)) {
store.remove(key);
return;
}
@ -141,14 +141,14 @@ public class HashChunkletManager implements ChunkletManager {
@Override
public void loadWorld(World world) {
//for(Chunk chunk : world.getLoadedChunks()) {
//for (Chunk chunk : world.getLoadedChunks()) {
// this.chunkLoaded(chunk.getX(), chunk.getZ(), world);
//}
}
@Override
public void saveAll() {
for(World world : Bukkit.getWorlds()) {
for (World world : Bukkit.getWorlds()) {
saveWorld(world);
}
}
@ -156,7 +156,7 @@ public class HashChunkletManager implements ChunkletManager {
@Override
public void unloadAll() {
saveAll();
for(World world : Bukkit.getWorlds()) {
for (World world : Bukkit.getWorlds()) {
unloadWorld(world);
}
}
@ -253,22 +253,22 @@ public class HashChunkletManager implements ChunkletManager {
@Override
public void cleanUp() {
for(String key : store.keySet()) {
if(store.get(key).isEmpty()) {
for (String key : store.keySet()) {
if (store.get(key).isEmpty()) {
String[] info = key.split(",");
File dataDir = new File(Bukkit.getWorld(info[0]).getWorldFolder(), "mcmmo_data");
File cxDir = new File(dataDir, "" + info[1]);
if(!cxDir.exists()) continue;
if (!cxDir.exists()) continue;
File czDir = new File(cxDir, "" + info[2]);
if(!czDir.exists()) continue;
if (!czDir.exists()) continue;
File yFile = new File(czDir, "" + info[3]);
yFile.delete();
//Delete empty directories
if(czDir.list().length == 0) czDir.delete();
if(cxDir.list().length == 0) cxDir.delete();
if (czDir.list().length == 0) czDir.delete();
if (cxDir.list().length == 0) cxDir.delete();
}
}
}
@ -282,7 +282,7 @@ public class HashChunkletManager implements ChunkletManager {
ObjectOutputStream objOut = null;
try {
if(!location.exists())
if (!location.exists())
location.createNewFile();
fileOut = new FileOutputStream(location);
objOut = new ObjectOutputStream(fileOut);
@ -374,9 +374,9 @@ public class HashChunkletManager implements ChunkletManager {
// IMPORTANT! If ChunkletStoreFactory is going to be returning something other than PrimitiveEx we need to remove this, as it will be breaking time for old maps
/*
if(!(storeIn instanceof PrimitiveExChunkletStore)) {
if (!(storeIn instanceof PrimitiveExChunkletStore)) {
ChunkletStore tempStore = ChunkletStoreFactory.getChunkletStore();
if(storeIn != null) {
if (storeIn != null) {
tempStore.copyFrom(storeIn);
}
storeIn = tempStore;

View File

@ -23,10 +23,10 @@ public class PrimitiveChunkletStore implements ChunkletStore {
@Override
public boolean isEmpty() {
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
for(int y = 0; y < 64; y++) {
if(store[x][z][y]) return false;
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < 64; y++) {
if (store[x][z][y]) return false;
}
}
}
@ -35,9 +35,9 @@ public class PrimitiveChunkletStore implements ChunkletStore {
@Override
public void copyFrom(ChunkletStore otherStore) {
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
for(int y = 0; y < 64; y++) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < 64; y++) {
store[x][z][y] = otherStore.isTrue(x, y, z);
}
}

View File

@ -28,10 +28,10 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
@Override
public boolean isEmpty() {
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
for(int y = 0; y < 64; y++) {
if(store[x][z][y]) return false;
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < 64; y++) {
if (store[x][z][y]) return false;
}
}
}
@ -40,9 +40,9 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
@Override
public void copyFrom(ChunkletStore otherStore) {
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
for(int y = 0; y < 64; y++) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < 64; y++) {
store[x][z][y] = otherStore.isTrue(x, y, z);
}
}
@ -54,13 +54,13 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
byte[] buffer = new byte[2304]; // 2304 is 16*16*9
int bufferIndex = 0;
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
for(int y = 0; y < 64; y++) {
if(store[x][z][y]) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < 64; y++) {
if (store[x][z][y]) {
byte[] temp = constructColumn(x, z);
for(int i = 0; i < 9; i++) {
for (int i = 0; i < 9; i++) {
buffer[bufferIndex] = temp[i];
bufferIndex++;
}
@ -81,13 +81,13 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
byte[] temp = new byte[9];
// Could probably reorganize this loop to print nasty things if it does not equal 9 or -1
while(in.read(temp, 0, 9) == 9) {
while (in.read(temp, 0, 9) == 9) {
int x = addressByteX(temp[0]);
int z = addressByteZ(temp[0]);
boolean[] yColumn = new boolean[64];
for(int i = 0; i < 8; i++) {
for(int j = 0; j < 8; j++) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
yColumn[j + (i * 8)] = (temp[i + 1] & (1 << j)) != 0;
}
}
@ -127,13 +127,13 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
column[0] = makeAddressByte(x, z);
for (int i = 0; i < 8; i++){
for (int i = 0; i < 8; i++) {
byte yCompressed = 0x0;
int subColumnIndex = 8 * i;
int subColumnEnd = subColumnIndex + 8;
for(int y = subColumnIndex; y < subColumnEnd; y++) {
if(store[x][z][y]) {
for (int y = subColumnIndex; y < subColumnEnd; y++) {
if (store[x][z][y]) {
yCompressed |= 1 << (y % 8);
}
}

View File

@ -6,10 +6,10 @@ public class ChunkManagerFactory {
public static ChunkManager getChunkManager() {
HiddenConfig hConfig = HiddenConfig.getInstance();
if(hConfig.getChunkletsEnabled()) {
if (hConfig.getChunkletsEnabled()) {
return new HashChunkManager();
} else {
return new NullChunkManager();
}
return new NullChunkManager();
}
}

View File

@ -38,12 +38,11 @@ public class HashChunkManager implements ChunkManager {
public synchronized void closeAll() {
for (UUID uid : regionFiles.keySet()) {
HashMap<Long, mcMMOSimpleRegionFile> worldRegions = regionFiles.get(uid);
Iterator<mcMMOSimpleRegionFile> itr = worldRegions.values().iterator();
while (itr.hasNext()) {
mcMMOSimpleRegionFile rf = itr.next();
for (Iterator<mcMMOSimpleRegionFile> worldRegionIterator = worldRegions.values().iterator(); worldRegionIterator.hasNext();) {
mcMMOSimpleRegionFile rf = worldRegionIterator.next();
if (rf != null) {
rf.close();
itr.remove();
worldRegionIterator.remove();
}
}
}
@ -62,9 +61,9 @@ public class HashChunkManager implements ChunkManager {
Object o = objectStream.readObject();
if (o instanceof ChunkStore) {
return (ChunkStore) o;
} else {
throw new RuntimeException("Wrong class type read for chunk meta data for " + x + ", " + z);
}
throw new RuntimeException("Wrong class type read for chunk meta data for " + x + ", " + z);
} catch (IOException e) {
// Assume the format changed
return null;
@ -144,19 +143,19 @@ public class HashChunkManager implements ChunkManager {
@Override
public synchronized void loadChunk(int cx, int cz, World world) {
if(world == null)
if (world == null)
return;
if(store.containsKey(world.getName() + "," + cx + "," + cz))
if (store.containsKey(world.getName() + "," + cx + "," + cz))
return;
ChunkStore in = null;
UUID key = world.getUID();
if(!this.oldData.containsKey(key))
if (!this.oldData.containsKey(key))
this.oldData.put(key, (new File(world.getWorldFolder(), "mcmmo_data")).exists());
if(this.oldData.containsKey(key) && oldData.get(key))
if (this.oldData.containsKey(key) && oldData.get(key))
convertChunk(new File(world.getWorldFolder(), "mcmmo_data"), cx, cz, world, true);
try {
@ -164,20 +163,20 @@ public class HashChunkManager implements ChunkManager {
}
catch(Exception e) {}
if(in != null) {
if (in != null) {
store.put(world.getName() + "," + cx + "," + cz, in);
List<UUID> mobs = in.getSpawnedMobs();
List<UUID> pets = in.getSpawnedPets();
if(mobs.isEmpty() && pets.isEmpty())
if (mobs.isEmpty() && pets.isEmpty())
return;
for(LivingEntity entity : world.getLivingEntities()) {
if(mobs.contains(entity.getUniqueId()))
for (LivingEntity entity : world.getLivingEntities()) {
if (mobs.contains(entity.getUniqueId()))
addSpawnedMob(entity);
if(pets.contains(entity.getUniqueId()))
if (pets.contains(entity.getUniqueId()))
addSpawnedPet(entity);
}
@ -190,24 +189,24 @@ public class HashChunkManager implements ChunkManager {
public synchronized void unloadChunk(int cx, int cz, World world) {
saveChunk(cx, cz, world);
if(store.containsKey(world.getName() + "," + cx + "," + cz)) {
if (store.containsKey(world.getName() + "," + cx + "," + cz)) {
store.remove(world.getName() + "," + cx + "," + cz);
for(Entity entity : spawnedMobs) {
if(!isEntityInChunk(entity, cx, cz, world))
for (Entity entity : spawnedMobs) {
if (!isEntityInChunk(entity, cx, cz, world))
continue;
mobsToRemove.add(entity);
}
for(Entity entity : spawnedPets) {
if(!isEntityInChunk(entity, cx, cz, world))
for (Entity entity : spawnedPets) {
if (!isEntityInChunk(entity, cx, cz, world))
continue;
mobsToRemove.add(entity);
}
if(safeToRemoveMobs) {
if (safeToRemoveMobs) {
spawnedMobs.remove(mobsToRemove);
spawnedPets.remove(mobsToRemove);
mobsToRemove.clear();
@ -217,14 +216,14 @@ public class HashChunkManager implements ChunkManager {
@Override
public synchronized void saveChunk(int cx, int cz, World world) {
if(world == null)
if (world == null)
return;
boolean unloaded = false;
if(!store.containsKey(world.getName() + "," + cx + "," + cz)) {
if (!store.containsKey(world.getName() + "," + cx + "," + cz)) {
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
for(Entity entity : tempSpawnedMobs) {
if(!isEntityInChunk(entity, cx, cz, world))
for (Entity entity : tempSpawnedMobs) {
if (!isEntityInChunk(entity, cx, cz, world))
continue;
loadChunk(cx, cz, world);
@ -232,10 +231,10 @@ public class HashChunkManager implements ChunkManager {
break;
}
if(!unloaded) {
if (!unloaded) {
List<Entity> tempSpawnedPets = new ArrayList<Entity>(spawnedPets);
for(Entity entity : tempSpawnedPets) {
if(!isEntityInChunk(entity, cx, cz, world))
for (Entity entity : tempSpawnedPets) {
if (!isEntityInChunk(entity, cx, cz, world))
continue;
loadChunk(cx, cz, world);
@ -245,31 +244,31 @@ public class HashChunkManager implements ChunkManager {
}
}
if(!store.containsKey(world.getName() + "," + cx + "," + cz) && unloaded) {
if (!store.containsKey(world.getName() + "," + cx + "," + cz) && unloaded) {
ChunkStore cStore = ChunkStoreFactory.getChunkStore(world, cx, cz);
store.put(world.getName() + "," + cx + "," + cz, cStore);
}
if(store.containsKey(world.getName() + "," + cx + "," + cz)) {
if (store.containsKey(world.getName() + "," + cx + "," + cz)) {
ChunkStore out = store.get(world.getName() + "," + cx + "," + cz);
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
for(Entity entity : tempSpawnedMobs) {
if(!isEntityInChunk(entity, cx, cz, world))
for (Entity entity : tempSpawnedMobs) {
if (!isEntityInChunk(entity, cx, cz, world))
continue;
out.addSpawnedMob(entity.getUniqueId());
}
List<Entity> tempSpawnedPets = new ArrayList<Entity>(spawnedPets);
for(Entity entity : tempSpawnedPets) {
if(!isEntityInChunk(entity, cx, cz, world))
for (Entity entity : tempSpawnedPets) {
if (!isEntityInChunk(entity, cx, cz, world))
continue;
out.addSpawnedPet(entity.getUniqueId());
}
if(!out.isDirty())
if (!out.isDirty())
return;
writeChunkStore(world, cx, cz, out);
@ -277,16 +276,16 @@ public class HashChunkManager implements ChunkManager {
}
private boolean isEntityInChunk(Entity entity, int cx, int cz, World world) {
if(entity == null || world == null)
if (entity == null || world == null)
return false;
if(entity.getLocation().getChunk().getX() != cx)
if (entity.getLocation().getChunk().getX() != cx)
return false;
if(entity.getLocation().getChunk().getZ() != cz)
if (entity.getLocation().getChunk().getZ() != cz)
return false;
if(entity.getWorld() != world)
if (entity.getWorld() != world)
return false;
return true;
@ -294,7 +293,7 @@ public class HashChunkManager implements ChunkManager {
@Override
public synchronized boolean isChunkLoaded(int cx, int cz, World world) {
if(world == null)
if (world == null)
return false;
return store.containsKey(world.getName() + "," + cx + "," + cz);
@ -305,7 +304,7 @@ public class HashChunkManager implements ChunkManager {
@Override
public synchronized void chunkUnloaded(int cx, int cz, World world) {
if(world == null)
if (world == null)
return;
ChunkletUnloader.addToList(cx, cz, world);
@ -313,16 +312,16 @@ public class HashChunkManager implements ChunkManager {
@Override
public synchronized void saveWorld(World world) {
if(world == null)
if (world == null)
return;
closeAll();
String worldName = world.getName();
List<String> keys = new ArrayList<String>(store.keySet());
for(String key : keys) {
for (String key : keys) {
String[] info = key.split(",");
if(worldName.equals(info[0])) {
if (worldName.equals(info[0])) {
int cx = 0;
int cz = 0;
@ -338,10 +337,10 @@ public class HashChunkManager implements ChunkManager {
}
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
for(Entity entity : tempSpawnedMobs) {
for (Entity entity : tempSpawnedMobs) {
World entityWorld = entity.getWorld();
if(world != entityWorld)
if (world != entityWorld)
continue;
int cx = entity.getLocation().getChunk().getX();
@ -351,10 +350,10 @@ public class HashChunkManager implements ChunkManager {
}
List<Entity> tempSpawnedPets = new ArrayList<Entity>(spawnedPets);
for(Entity entity : tempSpawnedPets) {
for (Entity entity : tempSpawnedPets) {
World entityWorld = entity.getWorld();
if(world != entityWorld)
if (world != entityWorld)
continue;
int cx = entity.getLocation().getChunk().getX();
@ -366,16 +365,16 @@ public class HashChunkManager implements ChunkManager {
@Override
public synchronized void unloadWorld(World world) {
if(world == null)
if (world == null)
return;
closeAll();
String worldName = world.getName();
List<String> keys = new ArrayList<String>(store.keySet());
for(String key : keys) {
for (String key : keys) {
String[] info = key.split(",");
if(worldName.equals(info[0])) {
if (worldName.equals(info[0])) {
int cx = 0;
int cz = 0;
@ -393,10 +392,10 @@ public class HashChunkManager implements ChunkManager {
safeToRemoveMobs = false;
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
for(Entity entity : tempSpawnedMobs) {
for (Entity entity : tempSpawnedMobs) {
World entityWorld = entity.getWorld();
if(world != entityWorld)
if (world != entityWorld)
continue;
int cx = entity.getLocation().getChunk().getX();
@ -406,10 +405,10 @@ public class HashChunkManager implements ChunkManager {
}
List<Entity> tempSpawnedPets = new ArrayList<Entity>(spawnedPets);
for(Entity entity : tempSpawnedPets) {
for (Entity entity : tempSpawnedPets) {
World entityWorld = entity.getWorld();
if(world != entityWorld)
if (world != entityWorld)
continue;
int cx = entity.getLocation().getChunk().getX();
@ -432,7 +431,7 @@ public class HashChunkManager implements ChunkManager {
public synchronized void saveAll() {
closeAll();
for(World world : Bukkit.getWorlds()) {
for (World world : Bukkit.getWorlds()) {
saveWorld(world);
}
}
@ -441,14 +440,14 @@ public class HashChunkManager implements ChunkManager {
public synchronized void unloadAll() {
closeAll();
for(World world : Bukkit.getWorlds()) {
for (World world : Bukkit.getWorlds()) {
unloadWorld(world);
}
}
@Override
public synchronized boolean isTrue(int x, int y, int z, World world) {
if(world == null)
if (world == null)
return false;
int cx = x / 16;
@ -472,7 +471,7 @@ public class HashChunkManager implements ChunkManager {
@Override
public synchronized boolean isTrue(Block block) {
if(block == null)
if (block == null)
return false;
return isTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
@ -480,7 +479,7 @@ public class HashChunkManager implements ChunkManager {
@Override
public synchronized void setTrue(int x, int y, int z, World world) {
if(world == null)
if (world == null)
return;
int cx = x / 16;
@ -507,7 +506,7 @@ public class HashChunkManager implements ChunkManager {
@Override
public synchronized void setTrue(Block block) {
if(block == null)
if (block == null)
return;
setTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
@ -515,7 +514,7 @@ public class HashChunkManager implements ChunkManager {
@Override
public synchronized void setFalse(int x, int y, int z, World world) {
if(world == null)
if (world == null)
return;
int cx = x / 16;
@ -541,7 +540,7 @@ public class HashChunkManager implements ChunkManager {
@Override
public synchronized void setFalse(Block block) {
if(block == null)
if (block == null)
return;
setFalse(block.getX(), block.getY(), block.getZ(), block.getWorld());
@ -555,21 +554,21 @@ public class HashChunkManager implements ChunkManager {
}
public synchronized void convertChunk(File dataDir, int cx, int cz, World world, boolean actually) {
if(!actually)
if (!actually)
return;
if(!dataDir.exists()) return;
if (!dataDir.exists()) return;
File cxDir = new File(dataDir, "" + cx);
if(!cxDir.exists()) return;
if (!cxDir.exists()) return;
File czDir = new File(cxDir, "" + cz);
if(!czDir.exists()) return;
if (!czDir.exists()) return;
boolean conversionSet = false;
for(BlockStoreConversionZDirectory converter : this.converters) {
if(converter == null)
for (BlockStoreConversionZDirectory converter : this.converters) {
if (converter == null)
continue;
if(converter.taskID >= 0)
if (converter.taskID >= 0)
continue;
converter.start(world, cxDir, czDir);
@ -577,7 +576,7 @@ public class HashChunkManager implements ChunkManager {
break;
}
if(!conversionSet) {
if (!conversionSet) {
BlockStoreConversionZDirectory converter = new BlockStoreConversionZDirectory();
converter.start(world, cxDir, czDir);
converters.add(converter);
@ -593,22 +592,22 @@ public class HashChunkManager implements ChunkManager {
}
public void addSpawnedMob(Entity entity) {
if(!isSpawnedMob(entity))
if (!isSpawnedMob(entity))
spawnedMobs.add(entity);
}
public void addSpawnedPet(Entity entity) {
if(!isSpawnedPet(entity))
if (!isSpawnedPet(entity))
spawnedPets.add(entity);
}
public void removeSpawnedMob(Entity entity) {
if(isSpawnedMob(entity))
if (isSpawnedMob(entity))
spawnedMobs.remove(entity);
}
public void removeSpawnedPet(Entity entity) {
if(isSpawnedPet(entity))
if (isSpawnedPet(entity))
spawnedPets.remove(entity);
}
}

View File

@ -82,10 +82,10 @@ public class PrimitiveChunkStore implements ChunkStore {
@Override
public boolean isEmpty() {
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
for(int y = 0; y < this.worldHeight; y++) {
if(store[x][z][y]) return false;
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < this.worldHeight; y++) {
if (store[x][z][y]) return false;
}
}
}
@ -94,9 +94,9 @@ public class PrimitiveChunkStore implements ChunkStore {
@Override
public void copyFrom(ChunkletStore otherStore) {
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
for(int y = 0; y < this.worldHeight; y++) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < this.worldHeight; y++) {
store[x][z][y] = otherStore.isTrue(x, y, z);
}
}
@ -113,42 +113,42 @@ public class PrimitiveChunkStore implements ChunkStore {
}
public void addSpawnedMob(UUID id) {
if(!isSpawnedMob(id)) {
if (!isSpawnedMob(id)) {
spawnedMobs.add(id);
dirty = true;
}
}
public void addSpawnedPet(UUID id) {
if(!isSpawnedPet(id)) {
if (!isSpawnedPet(id)) {
spawnedPets.add(id);
dirty = true;
}
}
public void removeSpawnedMob(UUID id) {
if(isSpawnedMob(id)) {
if (isSpawnedMob(id)) {
spawnedMobs.remove(id);
dirty = true;
}
}
public void removeSpawnedPet(UUID id) {
if(isSpawnedPet(id)) {
if (isSpawnedPet(id)) {
spawnedPets.remove(id);
dirty = true;
}
}
public void clearSpawnedMobs() {
if(!spawnedMobs.isEmpty()) {
if (!spawnedMobs.isEmpty()) {
spawnedMobs.clear();
dirty = true;
}
}
public void clearSpawnedPets() {
if(!spawnedPets.isEmpty()) {
if (!spawnedPets.isEmpty()) {
spawnedPets.clear();
dirty = true;
}
@ -204,16 +204,16 @@ public class PrimitiveChunkStore implements ChunkStore {
store = (boolean[][][]) in.readObject();
if (fileVersionNumber < CURRENT_VERSION) {
if(fileVersionNumber < 5)
if (fileVersionNumber < 5)
fixArray();
if(fileVersionNumber < 6) {
if (fileVersionNumber < 6) {
spawnedMobs = new ArrayList<UUID>();
spawnedPets = new ArrayList<UUID>();
}
dirty = true;
}
if(fileVersionNumber >= 6) {
if (fileVersionNumber >= 6) {
//What do we want to do about this? These casts are unchecked.
spawnedMobs = (ArrayList<UUID>) in.readObject();
spawnedPets = (ArrayList<UUID>) in.readObject();
@ -223,9 +223,9 @@ public class PrimitiveChunkStore implements ChunkStore {
private void fixArray() {
boolean[][][] temp = this.store;
this.store = new boolean[16][16][this.worldHeight];
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
for(int y = 0; y < this.worldHeight; y++) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < this.worldHeight; y++) {
try {
store[x][z][y] = temp[x][y][z];
}