mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-20 23:21:24 +01:00
Clone instead of caching
This commit is contained in:
parent
5e8e7cbaf4
commit
f5b8f267d6
@ -7,7 +7,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -29,8 +28,6 @@ public class ItemMeta {
|
||||
private final NBTCompound nbt;
|
||||
private final ItemMetaBuilder emptyBuilder;
|
||||
|
||||
private SoftReference<NBTCompound> nbtCache;
|
||||
|
||||
protected ItemMeta(@NotNull ItemMetaBuilder metaBuilder) {
|
||||
this.damage = metaBuilder.damage;
|
||||
this.unbreakable = metaBuilder.unbreakable;
|
||||
@ -106,12 +103,7 @@ public class ItemMeta {
|
||||
}
|
||||
|
||||
public @NotNull NBTCompound toNBT() {
|
||||
NBTCompound cache = nbtCache.get();
|
||||
if (cache == null) {
|
||||
cache = nbt.deepClone();
|
||||
nbtCache = new SoftReference<>(cache);
|
||||
}
|
||||
return cache;
|
||||
return nbt.deepClone();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user