Fix for UTFDataFormatException

This commit is contained in:
GJ 2012-06-26 14:58:51 -04:00
parent 1610e932c6
commit 24d2c1bc7a
2 changed files with 17 additions and 6 deletions

View File

@ -13,6 +13,7 @@ Version 1.3.10-dev
+ Added Ability API functions + Added Ability API functions
= Fixed players never being removed from memory (memory leak) = Fixed players never being removed from memory (memory leak)
= Fixed admin chat being seen by everyone = Fixed admin chat being seen by everyone
= Fixed issue with UTFDataFormatException occurring on occasion when trying to load Chunklets
Version 1.3.09 Version 1.3.09
+ Added compatibility with AntiCheat (Which I highly recommend to prevent cheating) + Added compatibility with AntiCheat (Which I highly recommend to prevent cheating)

View File

@ -8,6 +8,7 @@ import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.StreamCorruptedException; import java.io.StreamCorruptedException;
import java.io.UTFDataFormatException;
import java.util.HashMap; import java.util.HashMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -235,18 +236,27 @@ public class HashChunkletManager implements ChunkletManager {
storeIn = (ChunkletStore) objIn.readObject(); storeIn = (ChunkletStore) objIn.readObject();
objIn.close(); objIn.close();
fileIn.close(); fileIn.close();
} catch (IOException ex) { }
catch (IOException ex) {
if (ex instanceof EOFException) { if (ex instanceof EOFException) {
// EOF should only happen on Chunklets that somehow have been corrupted. // 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 area will be lost."); mcMMO.p.getLogger().severe("Chunklet data at " + location.toString() + " could not be read due to an EOFException, data in this area will be lost.");
return ChunkletStoreFactory.getChunkletStore(); return ChunkletStoreFactory.getChunkletStore();
} else if (ex instanceof StreamCorruptedException) { }
// StreamCorrupted happens when the chunklet is no good. else if (ex instanceof StreamCorruptedException) {
// StreamCorrupted happens when the Chunklet is no good.
mcMMO.p.getLogger().severe("Chunklet data at " + location.toString() + " is corrupted, data in this area will be lost."); mcMMO.p.getLogger().severe("Chunklet data at " + location.toString() + " is corrupted, data in this area will be lost.");
return ChunkletStoreFactory.getChunkletStore(); return ChunkletStoreFactory.getChunkletStore();
} }
else if (ex instanceof UTFDataFormatException) {
// UTF happens when the Chunklet cannot be read or is corrupted
mcMMO.p.getLogger().severe("Chunklet data at " + location.toString() + " could not be read due to an UTFDataFormatException, data in this area will be lost.");
return ChunkletStoreFactory.getChunkletStore();
}
ex.printStackTrace(); ex.printStackTrace();
} catch (ClassNotFoundException ex) { }
catch (ClassNotFoundException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }