Handle EOFException in Chunklets by returning a new empty ChunkletStore and printing an error.

This commit is contained in:
NuclearW 2012-05-29 21:02:36 -04:00
parent 12a7d794b4
commit 39c2c5f25f

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.util.blockmeta;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -12,6 +13,8 @@ import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Block;
import com.gmail.nossr50.mcMMO;
public class HashChunkletManager implements ChunkletManager {
private HashMap<String, ChunkletStore> store = new HashMap<String, ChunkletStore>();
@ -211,6 +214,11 @@ public class HashChunkletManager implements ChunkletManager {
objIn.close();
fileIn.close();
} catch (IOException ex) {
if (ex instanceof EOFException) {
// EOF should only happen on Chunklets that somehow have been corrupted.
mcMMO.p.getLogger().severe("Chunklet data at " + location.toString() + " could not be read, data in this are will be lost.");
return ChunkletStoreFactory.getChunkletStore();
}
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();