From 24d2c1bc7a4d1c1f0181deddf1cc67f44f7136de Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Jun 2012 14:58:51 -0400 Subject: [PATCH] Fix for UTFDataFormatException --- Changelog.txt | 3 ++- .../util/blockmeta/HashChunkletManager.java | 20 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 0093277ef..4fe360019 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -12,7 +12,8 @@ Version 1.3.10-dev + Added ability for custom blocks to drop a range of items. + Added Ability API functions = 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 + Added compatibility with AntiCheat (Which I highly recommend to prevent cheating) diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java index b100545b7..c878fcb0c 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.StreamCorruptedException; +import java.io.UTFDataFormatException; import java.util.HashMap; import org.bukkit.Bukkit; @@ -235,18 +236,27 @@ public class HashChunkletManager implements ChunkletManager { storeIn = (ChunkletStore) objIn.readObject(); objIn.close(); fileIn.close(); - } catch (IOException ex) { + } + 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 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(); - } 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."); 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(); - } catch (ClassNotFoundException ex) { + } + catch (ClassNotFoundException ex) { ex.printStackTrace(); }