From 111bafc862130b16e7809a31e643d914d3c607fa Mon Sep 17 00:00:00 2001 From: Slikey Date: Thu, 15 Oct 2015 00:26:40 +0200 Subject: [PATCH] Fix Bug where Map was queried for the wrong data type. Also improved the performance by reducing the amount of calls on the Map. --- src/main/java/com/evilco/mc/nbt/tag/TagCompound.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/evilco/mc/nbt/tag/TagCompound.java b/src/main/java/com/evilco/mc/nbt/tag/TagCompound.java index f8facf4..587f153 100644 --- a/src/main/java/com/evilco/mc/nbt/tag/TagCompound.java +++ b/src/main/java/com/evilco/mc/nbt/tag/TagCompound.java @@ -313,11 +313,10 @@ public void setTag (@Nonnull ITag tag) { // check arguments Preconditions.checkNotNull (tag, "tag"); - // delete previous - if (this.tags.containsKey (tag)) this.tags.get (tag.getName ()).setParent (null); - // store tag - this.tags.put (tag.getName (), tag); + ITag previous = this.tags.put (tag.getName (), tag); + // delete previous + previous.setParent(null); // update parent tag.setParent (this); @@ -350,4 +349,4 @@ public void write (NbtOutputStream outputStream, boolean anonymous) throws IOExc // write end tag outputStream.writeByte (TagType.END.typeID); } -} \ No newline at end of file +}