From 4f55e4152dc7b261729c476a15b6469f7b82d561 Mon Sep 17 00:00:00 2001 From: mworzala Date: Thu, 25 Jul 2024 14:27:10 -0400 Subject: [PATCH] fix: immutable map ref --- .../dataconverter/types/nbt/NBTMapType.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/ca/spottedleaf/dataconverter/types/nbt/NBTMapType.java b/src/main/java/ca/spottedleaf/dataconverter/types/nbt/NBTMapType.java index 70e9708..ceb6b9b 100644 --- a/src/main/java/ca/spottedleaf/dataconverter/types/nbt/NBTMapType.java +++ b/src/main/java/ca/spottedleaf/dataconverter/types/nbt/NBTMapType.java @@ -419,8 +419,11 @@ public ListType getListUnchecked(final String key, final ListType dfl) { final Object tag = this.map.get(key); if (tag instanceof NBTListType l) return l; - if (tag instanceof ListBinaryTag) - return new NBTListType((ListBinaryTag) tag); + if (tag instanceof ListBinaryTag) { + var map = new NBTListType((ListBinaryTag) tag); + this.map.put(key, map); + return map; + } return dfl; } @@ -439,8 +442,11 @@ public MapType getMap(final String key, final MapType dfl) { final Object tag = this.map.get(key); if (tag instanceof NBTMapType m) return m; - if (tag instanceof CompoundBinaryTag) - return new NBTMapType((CompoundBinaryTag) tag); + if (tag instanceof CompoundBinaryTag) { + var map = new NBTMapType((CompoundBinaryTag) tag); + this.map.put(key, map); + return map; + } return dfl; }