mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-14 22:56:31 +01:00
Simplify synchronization
This commit is contained in:
parent
018a9263ee
commit
790e99bce3
@ -204,16 +204,14 @@ public abstract class ItemMetaBuilder implements TagWritable {
|
||||
|
||||
protected abstract @NotNull Supplier<@NotNull ItemMetaBuilder> getSupplier();
|
||||
|
||||
protected void mutateNbt(Consumer<NBTCompound> consumer) {
|
||||
protected synchronized void mutateNbt(Consumer<NBTCompound> consumer) {
|
||||
if (built) {
|
||||
built = false;
|
||||
final var currentNbt = nbt;
|
||||
NBT_UPDATER.compareAndSet(this, currentNbt, currentNbt.deepClone());
|
||||
}
|
||||
synchronized (this) {
|
||||
consumer.accept(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
protected synchronized NBTCompound nbt() {
|
||||
return nbt;
|
||||
|
Loading…
Reference in New Issue
Block a user