Rename TagReadable & TagWritable

This commit is contained in:
TheMode 2021-05-17 18:26:38 +02:00
parent 418fc8b4be
commit 7e5940d1a5
7 changed files with 19 additions and 19 deletions

View File

@ -5,7 +5,7 @@ import net.kyori.adventure.text.Component;
import net.minestom.server.instance.block.Block; import net.minestom.server.instance.block.Block;
import net.minestom.server.item.attribute.ItemAttribute; import net.minestom.server.item.attribute.ItemAttribute;
import net.minestom.server.tag.Tag; import net.minestom.server.tag.Tag;
import net.minestom.server.tag.TagReader; import net.minestom.server.tag.TagReadable;
import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.binary.BinaryWriter;
import net.minestom.server.utils.binary.Writeable; import net.minestom.server.utils.binary.Writeable;
import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Contract;
@ -17,7 +17,7 @@ import java.util.*;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
public class ItemMeta implements TagReader, Writeable { public class ItemMeta implements TagReadable, Writeable {
private final int damage; private final int damage;
private final boolean unbreakable; private final boolean unbreakable;

View File

@ -6,7 +6,7 @@ import net.minestom.server.adventure.AdventureSerializer;
import net.minestom.server.instance.block.Block; import net.minestom.server.instance.block.Block;
import net.minestom.server.item.attribute.ItemAttribute; import net.minestom.server.item.attribute.ItemAttribute;
import net.minestom.server.tag.Tag; import net.minestom.server.tag.Tag;
import net.minestom.server.tag.TagWriter; import net.minestom.server.tag.TagWritable;
import net.minestom.server.utils.NBTUtils; import net.minestom.server.utils.NBTUtils;
import net.minestom.server.utils.Utils; import net.minestom.server.utils.Utils;
import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Contract;
@ -18,7 +18,7 @@ import java.util.*;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
public abstract class ItemMetaBuilder implements TagWriter { public abstract class ItemMetaBuilder implements TagWritable {
protected NBTCompound nbt = new NBTCompound(); protected NBTCompound nbt = new NBTCompound();

View File

@ -141,7 +141,7 @@ public class Tag<T> {
public static <T> @NotNull Tag<T> Custom(@NotNull String key, @NotNull TagSerializer<T> serializer) { public static <T> @NotNull Tag<T> Custom(@NotNull String key, @NotNull TagSerializer<T> serializer) {
return new Tag<>(key, return new Tag<>(key,
nbtCompound -> serializer.read(TagReader.fromCompound(nbtCompound)), nbtCompound -> serializer.read(TagReadable.fromCompound(nbtCompound)),
(nbtCompound, value) -> serializer.write(TagWriter.fromCompound(nbtCompound), value)); (nbtCompound, value) -> serializer.write(TagWritable.fromCompound(nbtCompound), value));
} }
} }

View File

@ -3,5 +3,5 @@ package net.minestom.server.tag;
/** /**
* Represents an element which can read and write {@link Tag tags}. * Represents an element which can read and write {@link Tag tags}.
*/ */
public interface TagHandler extends TagReader, TagWriter { public interface TagHandler extends TagReadable, TagWritable {
} }

View File

@ -7,7 +7,7 @@ import org.jglrxavpok.hephaistos.nbt.NBTCompound;
/** /**
* Represents an element which can read {@link Tag tags}. * Represents an element which can read {@link Tag tags}.
*/ */
public interface TagReader { public interface TagReadable {
/** /**
* Reads the specified tag. * Reads the specified tag.
@ -30,10 +30,10 @@ public interface TagReader {
* Converts an nbt compound to a tag reader. * Converts an nbt compound to a tag reader.
* *
* @param compound the compound to convert * @param compound the compound to convert
* @return a {@link TagReader} capable of reading {@code compound} * @return a {@link TagReadable} capable of reading {@code compound}
*/ */
static @NotNull TagReader fromCompound(@NotNull NBTCompound compound) { static @NotNull TagReadable fromCompound(@NotNull NBTCompound compound) {
return new TagReader() { return new TagReadable() {
@Override @Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) { public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
return tag.read(compound); return tag.read(compound);

View File

@ -11,18 +11,18 @@ import org.jetbrains.annotations.Nullable;
public interface TagSerializer<T> { public interface TagSerializer<T> {
/** /**
* Reads the custom tag from a {@link TagReader}. * Reads the custom tag from a {@link TagReadable}.
* *
* @param reader the reader * @param reader the reader
* @return the deserialized value * @return the deserialized value
*/ */
@Nullable T read(@NotNull TagReader reader); @Nullable T read(@NotNull TagReadable reader);
/** /**
* Writes the custom tag to a {@link TagWriter}. * Writes the custom tag to a {@link TagWritable}.
* *
* @param writer the writer * @param writer the writer
* @param value the value to serialize * @param value the value to serialize
*/ */
void write(@NotNull TagWriter writer, @NotNull T value); void write(@NotNull TagWritable writer, @NotNull T value);
} }

View File

@ -7,7 +7,7 @@ import org.jglrxavpok.hephaistos.nbt.NBTCompound;
/** /**
* Represents an element which can write {@link Tag tags}. * Represents an element which can write {@link Tag tags}.
*/ */
public interface TagWriter { public interface TagWritable {
/** /**
* Writes the specified type. * Writes the specified type.
@ -22,10 +22,10 @@ public interface TagWriter {
* Converts an nbt compound to a tag writer. * Converts an nbt compound to a tag writer.
* *
* @param compound the compound to convert * @param compound the compound to convert
* @return a {@link TagWriter} capable of writing {@code compound} * @return a {@link TagWritable} capable of writing {@code compound}
*/ */
static @NotNull TagWriter fromCompound(@NotNull NBTCompound compound) { static @NotNull TagWritable fromCompound(@NotNull NBTCompound compound) {
return new TagWriter() { return new TagWritable() {
@Override @Override
public <T> void setTag(@NotNull Tag<T> tag, @Nullable T value) { public <T> void setTag(@NotNull Tag<T> tag, @Nullable T value) {
tag.write(compound, value); tag.write(compound, value);