mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-15 07:05:52 +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 abstract @NotNull Supplier<@NotNull ItemMetaBuilder> getSupplier();
|
||||||
|
|
||||||
protected void mutateNbt(Consumer<NBTCompound> consumer) {
|
protected synchronized void mutateNbt(Consumer<NBTCompound> consumer) {
|
||||||
if (built) {
|
if (built) {
|
||||||
built = false;
|
built = false;
|
||||||
final var currentNbt = nbt;
|
final var currentNbt = nbt;
|
||||||
NBT_UPDATER.compareAndSet(this, currentNbt, currentNbt.deepClone());
|
NBT_UPDATER.compareAndSet(this, currentNbt, currentNbt.deepClone());
|
||||||
}
|
}
|
||||||
synchronized (this) {
|
|
||||||
consumer.accept(nbt);
|
consumer.accept(nbt);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected synchronized NBTCompound nbt() {
|
protected synchronized NBTCompound nbt() {
|
||||||
return nbt;
|
return nbt;
|
||||||
|
Loading…
Reference in New Issue
Block a user