mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-29 15:07:36 +02:00
Style
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
30aa3ac8f3
commit
b294cb3f1c
@ -185,11 +185,6 @@ public class Tag<T> {
|
||||
}
|
||||
}
|
||||
|
||||
T createDefault() {
|
||||
final var supplier = defaultValue;
|
||||
return supplier != null ? supplier.get() : null;
|
||||
}
|
||||
|
||||
public void write(@NotNull MutableNBTCompound nbtCompound, @Nullable T value) {
|
||||
final String key = this.key;
|
||||
if (value != null) {
|
||||
@ -207,6 +202,10 @@ public class Tag<T> {
|
||||
write(nbtCompound, (T) value);
|
||||
}
|
||||
|
||||
final boolean isView() {
|
||||
return key.isEmpty();
|
||||
}
|
||||
|
||||
final boolean shareValue(@NotNull Tag<?> other) {
|
||||
if (this == other) return true;
|
||||
// Tags are not strictly the same, compare readers
|
||||
@ -215,6 +214,11 @@ public class Tag<T> {
|
||||
return this.readComparator == other.readComparator;
|
||||
}
|
||||
|
||||
final T createDefault() {
|
||||
final var supplier = defaultValue;
|
||||
return supplier != null ? supplier.get() : null;
|
||||
}
|
||||
|
||||
public static @NotNull Tag<Byte> Byte(@NotNull String key) {
|
||||
return tag(key, Serializers.BYTE);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ final class TagHandlerImpl implements TagHandler {
|
||||
|
||||
@Override
|
||||
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
|
||||
if (tag.getKey().isEmpty()) return tag.read(asCompound());
|
||||
if (tag.isView()) return tag.read(asCompound());
|
||||
return read(entries, tag);
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ final class TagHandlerImpl implements TagHandler {
|
||||
if (copy != null) value = copy.apply(value);
|
||||
}
|
||||
// View tag access
|
||||
if (tag.getKey().isEmpty()) {
|
||||
if (tag.isView()) {
|
||||
MutableNBTCompound tmp = new MutableNBTCompound();
|
||||
tag.writeUnsafe(tmp, value);
|
||||
updateContent(tmp);
|
||||
@ -179,7 +179,7 @@ final class TagHandlerImpl implements TagHandler {
|
||||
|
||||
@Override
|
||||
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
|
||||
if (tag.getKey().isEmpty()) return tag.read(compound);
|
||||
if (tag.isView()) return tag.read(compound);
|
||||
return read(entries, tag);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user