From 790e99bce3a94c1c4492eba3d949e305e63cf274 Mon Sep 17 00:00:00 2001 From: TheMode Date: Mon, 28 Jun 2021 23:27:12 +0200 Subject: [PATCH] Simplify synchronization --- src/main/java/net/minestom/server/item/ItemMetaBuilder.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/minestom/server/item/ItemMetaBuilder.java b/src/main/java/net/minestom/server/item/ItemMetaBuilder.java index 8f6eed47a..5c6a4c1cd 100644 --- a/src/main/java/net/minestom/server/item/ItemMetaBuilder.java +++ b/src/main/java/net/minestom/server/item/ItemMetaBuilder.java @@ -204,15 +204,13 @@ public abstract class ItemMetaBuilder implements TagWritable { protected abstract @NotNull Supplier<@NotNull ItemMetaBuilder> getSupplier(); - protected void mutateNbt(Consumer consumer) { + protected synchronized void mutateNbt(Consumer consumer) { if (built) { built = false; final var currentNbt = nbt; NBT_UPDATER.compareAndSet(this, currentNbt, currentNbt.deepClone()); } - synchronized (this) { - consumer.accept(nbt); - } + consumer.accept(nbt); } protected synchronized NBTCompound nbt() {