mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Cleanup
This commit is contained in:
parent
5645bf7982
commit
db59f24873
@ -1,8 +1,8 @@
|
||||
package com.gmail.nossr50.util.blockmeta;
|
||||
|
||||
public class ChunkletManagerFactory {
|
||||
public static ChunkletManager getChunkletManager() {
|
||||
// TODO: Add in loading from config what type of manager we want.
|
||||
return new HashChunkletManager();
|
||||
}
|
||||
public static ChunkletManager getChunkletManager() {
|
||||
// TODO: Add in loading from config what type of manager we want.
|
||||
return new HashChunkletManager();
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import java.io.Serializable;
|
||||
|
||||
public interface ChunkletStore extends Serializable {
|
||||
/**
|
||||
* Checks the value at the given coordinates
|
||||
*
|
||||
* @param x x coordinate in current chunklet
|
||||
* @param y y coordinate in current chunklet
|
||||
* @param z z coordinate in current chunklet
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.gmail.nossr50.util.blockmeta;
|
||||
|
||||
public class ChunkletStoreFactory {
|
||||
protected static ChunkletStore getChunkletStore() {
|
||||
// TODO: Add in loading from config what type of store we want.
|
||||
return new PrimitiveChunkletStore();
|
||||
}
|
||||
protected static ChunkletStore getChunkletStore() {
|
||||
// TODO: Add in loading from config what type of store we want.
|
||||
return new PrimitiveChunkletStore();
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
} else {
|
||||
ChunkletStore in = deserializeChunkletStore(yFile);
|
||||
if(in != null) {
|
||||
store.put(world.getName() + "," + cx + "," + cz + "," + y, in);
|
||||
store.put(world.getName() + "," + cx + "," + cz + "," + y, in);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -78,29 +78,29 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
}
|
||||
|
||||
public void unloadWorld(World world) {
|
||||
saveWorld(world);
|
||||
saveWorld(world);
|
||||
|
||||
String worldName = world.getName();
|
||||
|
||||
for(String key : store.keySet()) {
|
||||
String tempWorldName = key.split(",")[0];
|
||||
if(tempWorldName.equals(worldName)) {
|
||||
store.remove(key);
|
||||
}
|
||||
String tempWorldName = key.split(",")[0];
|
||||
if(tempWorldName.equals(worldName)) {
|
||||
store.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void saveAll() {
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
saveWorld(world);
|
||||
}
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
saveWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
public void unloadAll() {
|
||||
saveAll();
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
unloadWorld(world);
|
||||
}
|
||||
saveAll();
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
unloadWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTrue(int x, int y, int z, World world) {
|
||||
@ -155,7 +155,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
|
||||
ChunkletStore cStore;
|
||||
if(!store.containsKey(world.getName() + "," + cx + "," + cz + "," + cy)) {
|
||||
return; // No need to make a store for something we will be setting to false
|
||||
return; // No need to make a store for something we will be setting to false
|
||||
}
|
||||
|
||||
cStore = store.get(world.getName() + "," + cx + "," + cz + "," + cy);
|
||||
@ -192,7 +192,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
* @param location Where on the disk to put it
|
||||
*/
|
||||
private void serializeChunkletStore(ChunkletStore cStore, File location) {
|
||||
try {
|
||||
try {
|
||||
FileOutputStream fileOut = new FileOutputStream(location);
|
||||
ObjectOutputStream objOut = new ObjectOutputStream(fileOut);
|
||||
objOut.writeObject(cStore);
|
||||
@ -219,8 +219,8 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return storeIn;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user