mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-27 19:47:44 +01:00
No need to expose tag default value
This commit is contained in:
parent
429a14e220
commit
9255adb7ec
@ -21,8 +21,7 @@ public final class Tag<T> {
|
||||
private final String key;
|
||||
private final Function<NBTCompound, T> readFunction;
|
||||
private final BiConsumer<NBTCompound, T> writeConsumer;
|
||||
|
||||
protected volatile Supplier<T> defaultValue;
|
||||
private volatile Supplier<T> defaultValue;
|
||||
|
||||
private Tag(@NotNull String key,
|
||||
@NotNull Function<NBTCompound, T> readFunction,
|
||||
@ -46,15 +45,12 @@ public final class Tag<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public @Nullable Supplier<@Nullable T> getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public @Nullable T read(@NotNull NBTCompound nbtCompound) {
|
||||
if (nbtCompound.containsKey(key)) {
|
||||
return readFunction.apply(nbtCompound);
|
||||
} else {
|
||||
return defaultValue != null ? defaultValue.get() : null;
|
||||
final var supplier = defaultValue;
|
||||
return supplier != null ? supplier.get() : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user