Ejemplo n.º 1
0
 @Override
 public synchronized void closeChunkStore(World world, int x, int z) {
   mcMMOSimpleRegionFile rf = getSimpleRegionFile(world, x, z);
   if (rf != null) {
     rf.close();
   }
 }
Ejemplo n.º 2
0
 @Override
 public synchronized ChunkStore readChunkStore(World world, int x, int z) throws IOException {
   mcMMOSimpleRegionFile rf = getSimpleRegionFile(world, x, z);
   InputStream in = rf.getInputStream(x, z);
   if (in == null) {
     return null;
   }
   ObjectInputStream objectStream = new ObjectInputStream(in);
   try {
     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);
     }
   } catch (IOException e) {
     // Assume the format changed
     return null;
     // throw new RuntimeException("Unable to process chunk meta data for " + x + ", " + z, e);
   } catch (ClassNotFoundException e) {
     // Assume the format changed
     // System.out.println("[SpoutPlugin] is Unable to find serialized class for " + x + ", " + z +
     // ", " + e.getMessage());
     return null;
     // throw new RuntimeException("Unable to find serialized class for " + x + ", " + z, e);
   }
 }
Ejemplo n.º 3
0
 @Override
 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();
       if (rf != null) {
         rf.close();
         itr.remove();
       }
     }
   }
   regionFiles.clear();
 }
Ejemplo n.º 4
0
 @Override
 public synchronized void writeChunkStore(World world, int x, int z, ChunkStore data) {
   if (!data.isDirty()) {
     return;
   }
   try {
     mcMMOSimpleRegionFile rf = getSimpleRegionFile(world, x, z);
     ObjectOutputStream objectStream = new ObjectOutputStream(rf.getOutputStream(x, z));
     objectStream.writeObject(data);
     objectStream.flush();
     objectStream.close();
     data.setDirty(false);
   } catch (IOException e) {
     throw new RuntimeException("Unable to write chunk meta data for " + x + ", " + z, e);
   }
 }