diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-10-24 22:53:23 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-10-27 22:19:03 -0400 |
commit | 60819c6693daf19dde68b04af38a4fee8c7da988 (patch) | |
tree | e7bd96a07f0e9d9f1f6b2721ddd1bb5dd71eaf48 /src/main/java/net/minecraft/server/NBTTagCompound.java | |
parent | b9a72531b6e2ccc84bd021bca421255a957d96f7 (diff) | |
download | craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.gz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.lz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.xz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.zip |
Update CraftBukkit to Minecraft 1.4(.2).
Diffstat (limited to 'src/main/java/net/minecraft/server/NBTTagCompound.java')
-rw-r--r-- | src/main/java/net/minecraft/server/NBTTagCompound.java | 88 |
1 files changed, 77 insertions, 11 deletions
diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java index cd264824..2bc1d6c7 100644 --- a/src/main/java/net/minecraft/server/NBTTagCompound.java +++ b/src/main/java/net/minecraft/server/NBTTagCompound.java @@ -6,6 +6,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.concurrent.Callable; public class NBTTagCompound extends NBTBase { @@ -116,57 +117,118 @@ public class NBTTagCompound extends NBTBase { } public byte getByte(String s) { - return !this.map.containsKey(s) ? 0 : ((NBTTagByte) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? 0 : ((NBTTagByte) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 1, classcastexception)); + } } public short getShort(String s) { - return !this.map.containsKey(s) ? 0 : ((NBTTagShort) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? 0 : ((NBTTagShort) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 2, classcastexception)); + } } public int getInt(String s) { - return !this.map.containsKey(s) ? 0 : ((NBTTagInt) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? 0 : ((NBTTagInt) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 3, classcastexception)); + } } public long getLong(String s) { - return !this.map.containsKey(s) ? 0L : ((NBTTagLong) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? 0L : ((NBTTagLong) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 4, classcastexception)); + } } public float getFloat(String s) { - return !this.map.containsKey(s) ? 0.0F : ((NBTTagFloat) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? 0.0F : ((NBTTagFloat) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 5, classcastexception)); + } } public double getDouble(String s) { - return !this.map.containsKey(s) ? 0.0D : ((NBTTagDouble) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? 0.0D : ((NBTTagDouble) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 6, classcastexception)); + } } public String getString(String s) { - return !this.map.containsKey(s) ? "" : ((NBTTagString) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? "" : ((NBTTagString) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 8, classcastexception)); + } } public byte[] getByteArray(String s) { - return !this.map.containsKey(s) ? new byte[0] : ((NBTTagByteArray) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? new byte[0] : ((NBTTagByteArray) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 7, classcastexception)); + } } public int[] getIntArray(String s) { - return !this.map.containsKey(s) ? new int[0] : ((NBTTagIntArray) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? new int[0] : ((NBTTagIntArray) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 11, classcastexception)); + } } public NBTTagCompound getCompound(String s) { - return !this.map.containsKey(s) ? new NBTTagCompound(s) : (NBTTagCompound) this.map.get(s); + try { + return !this.map.containsKey(s) ? new NBTTagCompound(s) : (NBTTagCompound) this.map.get(s); + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 10, classcastexception)); + } } public NBTTagList getList(String s) { - return !this.map.containsKey(s) ? new NBTTagList(s) : (NBTTagList) this.map.get(s); + try { + return !this.map.containsKey(s) ? new NBTTagList(s) : (NBTTagList) this.map.get(s); + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 9, classcastexception)); + } } public boolean getBoolean(String s) { return this.getByte(s) != 0; } + public void o(String s) { + this.map.remove(s); + } + public String toString() { return "" + this.map.size() + " entries"; } + public boolean d() { + return this.map.isEmpty(); + } + + private CrashReport a(String s, int i, ClassCastException classcastexception) { + CrashReport crashreport = new CrashReport("Reading NBT data", classcastexception); + + crashreport.a("Corrupt tag type found", (Callable) (new CrashReportCorruptNBTTag(this, s))); + crashreport.a("Corrupt tag type expected", (Callable) (new CrashReportCorruptNBTTag2(this, i))); + crashreport.a("Corrupt tag name", s); + return crashreport; + } + public NBTBase clone() { NBTTagCompound nbttagcompound = new NBTTagCompound(this.getName()); Iterator iterator = this.map.keySet().iterator(); @@ -193,4 +255,8 @@ public class NBTTagCompound extends NBTBase { public int hashCode() { return super.hashCode() ^ this.map.hashCode(); } + + static Map a(NBTTagCompound nbttagcompound) { + return nbttagcompound.map; + } } |