From 8d711ea0156983fdab49abcb7cf0ac074974f7b0 Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Thu, 11 May 2023 21:40:03 +0200 Subject: [PATCH 1/8] chore: rename static in HoverEvent.ShowItem --- .../adventure/text/event/HoverEvent.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/api/src/main/java/net/kyori/adventure/text/event/HoverEvent.java b/api/src/main/java/net/kyori/adventure/text/event/HoverEvent.java index ae893ebca..1aa368dde 100644 --- a/api/src/main/java/net/kyori/adventure/text/event/HoverEvent.java +++ b/api/src/main/java/net/kyori/adventure/text/event/HoverEvent.java @@ -39,6 +39,7 @@ import net.kyori.adventure.util.Index; import net.kyori.examination.Examinable; import net.kyori.examination.ExaminableProperty; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Range; @@ -331,6 +332,18 @@ public static final class ShowItem implements Examinable { private final int count; private final @Nullable BinaryTagHolder nbt; + /** + * Creates. + * + * @param item the item + * @param count the count + * @return a {@code ShowItem} + * @since 4.14.0 + */ + public static @NotNull ShowItem showItem(final @NotNull Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { + return showItem(item, count, null); + } + /** * Creates. * @@ -338,11 +351,26 @@ public static final class ShowItem implements Examinable { * @param count the count * @return a {@code ShowItem} * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #showItem(Key, int)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") public static @NotNull ShowItem of(final @NotNull Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { return of(item, count, null); } + /** + * Creates. + * + * @param item the item + * @param count the count + * @return a {@code ShowItem} + * @since 4.14.0 + */ + public static @NotNull ShowItem showItem(final @NotNull Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { + return showItem(item, count, null); + } + /** * Creates. * @@ -350,11 +378,27 @@ public static final class ShowItem implements Examinable { * @param count the count * @return a {@code ShowItem} * @since 4.6.0 + * @deprecated for removal since 4.14.0, use {@link #showItem(Keyed, int)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") public static @NotNull ShowItem of(final @NotNull Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { return of(item, count, null); } + /** + * Creates. + * + * @param item the item + * @param count the count + * @param nbt the nbt + * @return a {@code ShowItem} + * @since 4.14.0 + */ + public static @NotNull ShowItem showItem(final @NotNull Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { + return new ShowItem(requireNonNull(item, "item"), count, nbt); + } + /** * Creates. * @@ -363,11 +407,27 @@ public static final class ShowItem implements Examinable { * @param nbt the nbt * @return a {@code ShowItem} * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #showItem(Key, int, BinaryTagHolder)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") public static @NotNull ShowItem of(final @NotNull Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { return new ShowItem(requireNonNull(item, "item"), count, nbt); } + /** + * Creates. + * + * @param item the item + * @param count the count + * @param nbt the nbt + * @return a {@code ShowItem} + * @since 4.14.0 + */ + public static @NotNull ShowItem showItem(final @NotNull Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { + return new ShowItem(requireNonNull(item, "item").key(), count, nbt); + } + /** * Creates. * @@ -376,7 +436,10 @@ public static final class ShowItem implements Examinable { * @param nbt the nbt * @return a {@code ShowItem} * @since 4.6.0 + * @deprecated for removal since 4.14.0, use {@link #showItem(Keyed, int, BinaryTagHolder)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") public static @NotNull ShowItem of(final @NotNull Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { return new ShowItem(requireNonNull(item, "item").key(), count, nbt); } From 3370b395300a8d29e465455092a5d62dcce99220 Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Thu, 11 May 2023 21:45:23 +0200 Subject: [PATCH 2/8] chore: rename static in HoverEvent.ShowEntity --- .../adventure/text/event/HoverEvent.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/api/src/main/java/net/kyori/adventure/text/event/HoverEvent.java b/api/src/main/java/net/kyori/adventure/text/event/HoverEvent.java index 1aa368dde..e279fb06e 100644 --- a/api/src/main/java/net/kyori/adventure/text/event/HoverEvent.java +++ b/api/src/main/java/net/kyori/adventure/text/event/HoverEvent.java @@ -557,6 +557,18 @@ public static final class ShowEntity implements Examinable { private final UUID id; private final Component name; + /** + * Creates. + * + * @param type the type + * @param id the id + * @return a {@code ShowEntity} + * @since 4.14.0 + */ + public static @NotNull ShowEntity showEntity(final @NotNull Key type, final @NotNull UUID id) { + return showEntity(type, id, null); + } + /** * Creates. * @@ -564,11 +576,26 @@ public static final class ShowEntity implements Examinable { * @param id the id * @return a {@code ShowEntity} * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #showEntity(Key, UUID)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") public static @NotNull ShowEntity of(final @NotNull Key type, final @NotNull UUID id) { return of(type, id, null); } + /** + * Creates. + * + * @param type the type + * @param id the id + * @return a {@code ShowEntity} + * @since 4.14.0 + */ + public static @NotNull ShowEntity showEntity(final @NotNull Keyed type, final @NotNull UUID id) { + return showEntity(type, id, null); + } + /** * Creates. * @@ -576,11 +603,27 @@ public static final class ShowEntity implements Examinable { * @param id the id * @return a {@code ShowEntity} * @since 4.6.0 + * @deprecated for removal since 4.14.0, use {@link #showEntity(Keyed, UUID)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") public static @NotNull ShowEntity of(final @NotNull Keyed type, final @NotNull UUID id) { return of(type, id, null); } + /** + * Creates. + * + * @param type the type + * @param id the id + * @param name the name + * @return a {@code ShowEntity} + * @since 4.14.0 + */ + public static @NotNull ShowEntity showEntity(final @NotNull Key type, final @NotNull UUID id, final @Nullable Component name) { + return new ShowEntity(requireNonNull(type, "type"), requireNonNull(id, "id"), name); + } + /** * Creates. * @@ -589,11 +632,27 @@ public static final class ShowEntity implements Examinable { * @param name the name * @return a {@code ShowEntity} * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #showEntity(Key, UUID, Component)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") public static @NotNull ShowEntity of(final @NotNull Key type, final @NotNull UUID id, final @Nullable Component name) { return new ShowEntity(requireNonNull(type, "type"), requireNonNull(id, "id"), name); } + /** + * Creates. + * + * @param type the type + * @param id the id + * @param name the name + * @return a {@code ShowEntity} + * @since 4.14.0 + */ + public static @NotNull ShowEntity showEntity(final @NotNull Keyed type, final @NotNull UUID id, final @Nullable Component name) { + return new ShowEntity(requireNonNull(type, "type").key(), requireNonNull(id, "id"), name); + } + /** * Creates. * @@ -602,7 +661,10 @@ public static final class ShowEntity implements Examinable { * @param name the name * @return a {@code ShowEntity} * @since 4.6.0 + * @deprecated for removal since 4.14.0, use {@link #showEntity(Keyed, UUID, Component)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") public static @NotNull ShowEntity of(final @NotNull Keyed type, final @NotNull UUID id, final @Nullable Component name) { return new ShowEntity(requireNonNull(type, "type").key(), requireNonNull(id, "id"), name); } From e69d0ba557e6c6dbae59ae249d2cce3fe04ad445 Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Thu, 11 May 2023 21:57:50 +0200 Subject: [PATCH 3/8] chore: rename static in adventure-nbt --- .../kyori/adventure/nbt/BinaryTagType.java | 10 +++++++- .../adventure/nbt/ByteArrayBinaryTag.java | 15 ++++++++++++ .../kyori/adventure/nbt/ByteBinaryTag.java | 19 +++++++++++++-- .../kyori/adventure/nbt/DoubleBinaryTag.java | 17 +++++++++++++ .../kyori/adventure/nbt/FloatBinaryTag.java | 15 ++++++++++++ .../adventure/nbt/IntArrayBinaryTag.java | 16 +++++++++++++ .../net/kyori/adventure/nbt/IntBinaryTag.java | 15 ++++++++++++ .../kyori/adventure/nbt/ListBinaryTag.java | 24 +++++++++++++++++-- .../adventure/nbt/LongArrayBinaryTag.java | 17 +++++++++++++ .../kyori/adventure/nbt/LongBinaryTag.java | 17 +++++++++++++ .../kyori/adventure/nbt/ShortBinaryTag.java | 15 ++++++++++++ .../kyori/adventure/nbt/StringBinaryTag.java | 15 ++++++++++++ 12 files changed, 190 insertions(+), 5 deletions(-) diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagType.java b/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagType.java index f0ce61b04..971f1d0aa 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagType.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagType.java @@ -29,6 +29,8 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; + +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -76,7 +78,7 @@ static void writeUntyped(final BinaryTagType) type).write(tag, output); } - static @NotNull BinaryTagType of(final byte id) { + static @NotNull BinaryTagType binaryTagType(final byte id) { for (int i = 0; i < TYPES.size(); i++) { final BinaryTagType type = TYPES.get(i); if (type.id() == id) { @@ -86,6 +88,12 @@ static void writeUntyped(final BinaryTagType of(final byte id) { + return binaryTagType(id); + } + static @NotNull BinaryTagType register(final Class type, final byte id, final Reader reader, final @Nullable Writer writer) { return register(new Impl<>(type, id, reader, writer)); } diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/ByteArrayBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/ByteArrayBinaryTag.java index 06897be6a..2fc456c2c 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/ByteArrayBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/ByteArrayBinaryTag.java @@ -23,6 +23,7 @@ */ package net.kyori.adventure.nbt; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -31,13 +32,27 @@ * @since 4.0.0 */ public interface ByteArrayBinaryTag extends ArrayBinaryTag, Iterable { + /** + * Creates a binary tag holding a {@code byte}-array value. + * + * @param value the value + * @return a binary tag + * @since 4.14.0 + */ + static @NotNull ByteArrayBinaryTag byteArrayBinaryTag(final byte@NotNull... value) { + return new ByteArrayBinaryTagImpl(value); + } + /** * Creates a binary tag holding a {@code byte}-array value. * * @param value the value * @return a binary tag * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #byteArrayBinaryTag(byte...) instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") static @NotNull ByteArrayBinaryTag of(final byte@NotNull... value) { return new ByteArrayBinaryTagImpl(value); } diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/ByteBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/ByteBinaryTag.java index 80f2b56cc..51bed228c 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/ByteBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/ByteBinaryTag.java @@ -23,6 +23,7 @@ */ package net.kyori.adventure.nbt; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -50,9 +51,9 @@ public interface ByteBinaryTag extends NumberBinaryTag { * * @param value the value * @return a binary tag - * @since 4.0.0 + * @since 4.14.0 */ - static @NotNull ByteBinaryTag of(final byte value) { + static @NotNull ByteBinaryTag byteBinaryTag(final byte value) { if (value == 0) { return ZERO; } else if (value == 1) { @@ -62,6 +63,20 @@ public interface ByteBinaryTag extends NumberBinaryTag { } } + /** + * Creates a binary tag holding a {@code byte} value. + * + * @param value the value + * @return a binary tag + * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #byteBinaryTag(byte)} instead. + */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") + static @NotNull ByteBinaryTag of(final byte value) { + return byteBinaryTag(value); + } + @Override default @NotNull BinaryTagType type() { return BinaryTagTypes.BYTE; diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/DoubleBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/DoubleBinaryTag.java index 9f0177cdb..bd73e354d 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/DoubleBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/DoubleBinaryTag.java @@ -23,21 +23,38 @@ */ package net.kyori.adventure.nbt; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import java.util.UUID; + /** * A binary tag holding a {@code double} value. * * @since 4.0.0 */ public interface DoubleBinaryTag extends NumberBinaryTag { + /** + * Creates a binary tag holding a {@code double} value. + * + * @param value the value + * @return a binary tag + * @since 4.14.0 + */ + static @NotNull DoubleBinaryTag doubleBinaryTag(final double value) { + return new DoubleBinaryTagImpl(value); + } + /** * Creates a binary tag holding a {@code double} value. * * @param value the value * @return a binary tag * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #doubleBinaryTag(double)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") static @NotNull DoubleBinaryTag of(final double value) { return new DoubleBinaryTagImpl(value); } diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/FloatBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/FloatBinaryTag.java index 42ac9b16c..e834233f4 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/FloatBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/FloatBinaryTag.java @@ -23,6 +23,7 @@ */ package net.kyori.adventure.nbt; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -31,13 +32,27 @@ * @since 4.0.0 */ public interface FloatBinaryTag extends NumberBinaryTag { + /** + * Creates a binary tag holding a {@code float} value. + * + * @param value the value + * @return a binary tag + * @since 4.14.0 + */ + static @NotNull FloatBinaryTag floatBinaryTag(final float value) { + return new FloatBinaryTagImpl(value); + } + /** * Creates a binary tag holding a {@code float} value. * * @param value the value * @return a binary tag * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #floatBinaryTag(float)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") static @NotNull FloatBinaryTag of(final float value) { return new FloatBinaryTagImpl(value); } diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java index 1ca09c189..0522c3ba4 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java @@ -27,6 +27,8 @@ import java.util.Spliterator; import java.util.function.IntConsumer; import java.util.stream.IntStream; + +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -36,13 +38,27 @@ * @sinceMinecraft 1.2.1 */ public interface IntArrayBinaryTag extends ArrayBinaryTag, Iterable { + /** + * Creates a binary tag holding an {@code int}-array value. + * + * @param value the value + * @return a binary tag + * @since 4.14.0 + */ + static @NotNull IntArrayBinaryTag intArrayBinaryTag(final int@NotNull... value) { + return new IntArrayBinaryTagImpl(value); + } + /** * Creates a binary tag holding an {@code int}-array value. * * @param value the value * @return a binary tag * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #intArrayBinaryTag(int...)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") static @NotNull IntArrayBinaryTag of(final int@NotNull... value) { return new IntArrayBinaryTagImpl(value); } diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java index b97e0ad0b..6efa87f8d 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java @@ -23,6 +23,7 @@ */ package net.kyori.adventure.nbt; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -31,13 +32,27 @@ * @since 4.0.0 */ public interface IntBinaryTag extends NumberBinaryTag { + /** + * Creates a binary tag holding an {@code int} value. + * + * @param value the value + * @return a binary tag + * @since 4.14.0 + */ + static @NotNull IntBinaryTag intBinaryTag(final int value) { + return new IntBinaryTagImpl(value); + } + /** * Creates a binary tag holding an {@code int} value. * * @param value the value * @return a binary tag * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #intBinaryTag(int)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") static @NotNull IntBinaryTag of(final int value) { return new IntBinaryTagImpl(value); } diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java index 9f96b0c4a..84a468c94 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java @@ -26,6 +26,8 @@ import java.util.List; import java.util.function.Consumer; import java.util.stream.Stream; + +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Range; @@ -93,14 +95,32 @@ public interface ListBinaryTag extends ListTagSetter, * @param tags the elements * @return a tag * @throws IllegalArgumentException if {@code type} is {@link BinaryTagTypes#END} - * @since 4.0.0 + * @since 4.14.0 */ - static @NotNull ListBinaryTag of(final @NotNull BinaryTagType type, final @NotNull List tags) { + static @NotNull ListBinaryTag listBinaryTag(final @NotNull BinaryTagType type, final @NotNull List tags) { if (tags.isEmpty()) return empty(); if (type == BinaryTagTypes.END) throw new IllegalArgumentException("Cannot create a list of " + BinaryTagTypes.END); return new ListBinaryTagImpl(type, tags); } + /** + * Creates a tag. + * + *

If {@code tags} is empty, {@link #empty()} will be returned.

+ * + * @param type the element type + * @param tags the elements + * @return a tag + * @throws IllegalArgumentException if {@code type} is {@link BinaryTagTypes#END} + * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #listBinaryTag(BinaryTagType, List)} instead. + */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") + static @NotNull ListBinaryTag of(final @NotNull BinaryTagType type, final @NotNull List tags) { + return listBinaryTag(type, tags); + } + @Override default @NotNull BinaryTagType type() { return BinaryTagTypes.LIST; diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/LongArrayBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/LongArrayBinaryTag.java index 1ca8f2142..320a79610 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/LongArrayBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/LongArrayBinaryTag.java @@ -23,10 +23,13 @@ */ package net.kyori.adventure.nbt; +import java.util.List; import java.util.PrimitiveIterator; import java.util.Spliterator; import java.util.function.LongConsumer; import java.util.stream.LongStream; + +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -36,13 +39,27 @@ * @sinceMinecraft 1.12 */ public interface LongArrayBinaryTag extends ArrayBinaryTag, Iterable { + /** + * Creates a binary tag holding a {@code long}-array value. + * + * @param value the value + * @return a binary tag + * @since 4.14.0 + */ + static @NotNull LongArrayBinaryTag longArrayBinaryTag(final long@NotNull... value) { + return new LongArrayBinaryTagImpl(value); + } + /** * Creates a binary tag holding a {@code long}-array value. * * @param value the value * @return a binary tag * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #longArrayBinaryTag(long...)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") static @NotNull LongArrayBinaryTag of(final long@NotNull... value) { return new LongArrayBinaryTagImpl(value); } diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/LongBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/LongBinaryTag.java index cb8aa476f..5d923cc0d 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/LongBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/LongBinaryTag.java @@ -23,21 +23,38 @@ */ package net.kyori.adventure.nbt; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import java.util.List; + /** * A binary tag holding a {@code long} value. * * @since 4.0.0 */ public interface LongBinaryTag extends NumberBinaryTag { + /** + * Creates a binary tag holding a {@code long} value. + * + * @param value the value + * @return a binary tag + * @since 4.14.0 + */ + static @NotNull LongBinaryTag longBinaryTag(final long value) { + return new LongBinaryTagImpl(value); + } + /** * Creates a binary tag holding a {@code long} value. * * @param value the value * @return a binary tag * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #longBinaryTag(long)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") static @NotNull LongBinaryTag of(final long value) { return new LongBinaryTagImpl(value); } diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/ShortBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/ShortBinaryTag.java index 011a3385e..0f14ef9ee 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/ShortBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/ShortBinaryTag.java @@ -23,6 +23,7 @@ */ package net.kyori.adventure.nbt; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -31,13 +32,27 @@ * @since 4.0.0 */ public interface ShortBinaryTag extends NumberBinaryTag { + /** + * Creates a binary tag holding a {@code short} value. + * + * @param value the value + * @return a binary tag + * @since 4.14.0 + */ + static @NotNull ShortBinaryTag shortBinaryTag(final short value) { + return new ShortBinaryTagImpl(value); + } + /** * Creates a binary tag holding a {@code short} value. * * @param value the value * @return a binary tag * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #shortBinaryTag(short)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") static @NotNull ShortBinaryTag of(final short value) { return new ShortBinaryTagImpl(value); } diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/StringBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/StringBinaryTag.java index b8644fe2d..eb67294c2 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/StringBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/StringBinaryTag.java @@ -23,6 +23,7 @@ */ package net.kyori.adventure.nbt; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -31,13 +32,27 @@ * @since 4.0.0 */ public interface StringBinaryTag extends BinaryTag { + /** + * Creates a binary tag holding a {@link String} value. + * + * @param value the value + * @return a binary tag + * @since 4.14.0 + */ + static @NotNull StringBinaryTag stringBinaryTag(final @NotNull String value) { + return new StringBinaryTagImpl(value); + } + /** * Creates a binary tag holding a {@link String} value. * * @param value the value * @return a binary tag * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #stringBinaryTag(String)} instead. */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") static @NotNull StringBinaryTag of(final @NotNull String value) { return new StringBinaryTagImpl(value); } From 86f8aa7bb95a3a5f3ca34d9f5ad3d2ebef164a82 Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Thu, 11 May 2023 21:59:51 +0200 Subject: [PATCH 4/8] space --- .../main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java | 2 +- nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java | 2 +- nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java index 0522c3ba4..77e9bd43d 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java @@ -55,7 +55,7 @@ public interface IntArrayBinaryTag extends ArrayBinaryTag, Iterable { * @param value the value * @return a binary tag * @since 4.0.0 - * @deprecated for removal since 4.14.0, use {@link #intArrayBinaryTag(int...)} instead. + * @deprecated for removal since 4.14.0, use {@link #intArrayBinaryTag(int...)} instead. */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java index 6efa87f8d..9ed534831 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java @@ -49,7 +49,7 @@ public interface IntBinaryTag extends NumberBinaryTag { * @param value the value * @return a binary tag * @since 4.0.0 - * @deprecated for removal since 4.14.0, use {@link #intBinaryTag(int)} instead. + * @deprecated for removal since 4.14.0, use {@link #intBinaryTag(int)} instead. */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java index 84a468c94..04e17b80c 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java @@ -113,7 +113,7 @@ public interface ListBinaryTag extends ListTagSetter, * @return a tag * @throws IllegalArgumentException if {@code type} is {@link BinaryTagTypes#END} * @since 4.0.0 - * @deprecated for removal since 4.14.0, use {@link #listBinaryTag(BinaryTagType, List)} instead. + * @deprecated for removal since 4.14.0, use {@link #listBinaryTag(BinaryTagType, List)} instead. */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") From b51118ffd0a5005d861c29f413d262bead7f6324 Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Thu, 11 May 2023 22:06:22 +0200 Subject: [PATCH 5/8] chore: replace deprecated usage --- .../adventure/nbt/BinaryTagReaderImpl.java | 4 +-- .../kyori/adventure/nbt/BinaryTagTypes.java | 26 +++++++++---------- .../adventure/nbt/CompoundTagSetter.java | 20 +++++++------- .../kyori/adventure/nbt/TagStringReader.java | 26 +++++++++---------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagReaderImpl.java b/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagReaderImpl.java index d2b2080dd..3e93441dd 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagReaderImpl.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagReaderImpl.java @@ -66,7 +66,7 @@ final class BinaryTagReaderImpl implements BinaryTagIO.Reader { input = new TrackingDataInput(input, this.maxBytes); } - final BinaryTagType type = BinaryTagType.of(input.readByte()); + final BinaryTagType type = BinaryTagType.binaryTagType(input.readByte()); requireCompound(type); input.skipBytes(input.readUnsignedShort()); // read empty name return BinaryTagTypes.COMPOUND.read(input); @@ -88,7 +88,7 @@ final class BinaryTagReaderImpl implements BinaryTagIO.Reader { @Override public Map.@NotNull Entry readNamed(final @NotNull DataInput input) throws IOException { - final BinaryTagType type = BinaryTagType.of(input.readByte()); + final BinaryTagType type = BinaryTagType.binaryTagType(input.readByte()); requireCompound(type); final String name = input.readUTF(); return new AbstractMap.SimpleImmutableEntry<>(name, BinaryTagTypes.COMPOUND.read(input)); diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagTypes.java b/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagTypes.java index 364cfe7e4..012c28736 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagTypes.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagTypes.java @@ -45,37 +45,37 @@ public final class BinaryTagTypes { * * @since 4.0.0 */ - public static final BinaryTagType BYTE = BinaryTagType.registerNumeric(ByteBinaryTag.class, (byte) 1, input -> ByteBinaryTag.of(input.readByte()), (tag, output) -> output.writeByte(tag.value())); + public static final BinaryTagType BYTE = BinaryTagType.registerNumeric(ByteBinaryTag.class, (byte) 1, input -> ByteBinaryTag.byteBinaryTag(input.readByte()), (tag, output) -> output.writeByte(tag.value())); /** * {@link ShortBinaryTag}. * * @since 4.0.0 */ - public static final BinaryTagType SHORT = BinaryTagType.registerNumeric(ShortBinaryTag.class, (byte) 2, input -> ShortBinaryTag.of(input.readShort()), (tag, output) -> output.writeShort(tag.value())); + public static final BinaryTagType SHORT = BinaryTagType.registerNumeric(ShortBinaryTag.class, (byte) 2, input -> ShortBinaryTag.shortBinaryTag(input.readShort()), (tag, output) -> output.writeShort(tag.value())); /** * {@link IntBinaryTag}. * * @since 4.0.0 */ - public static final BinaryTagType INT = BinaryTagType.registerNumeric(IntBinaryTag.class, (byte) 3, input -> IntBinaryTag.of(input.readInt()), (tag, output) -> output.writeInt(tag.value())); + public static final BinaryTagType INT = BinaryTagType.registerNumeric(IntBinaryTag.class, (byte) 3, input -> IntBinaryTag.intBinaryTag(input.readInt()), (tag, output) -> output.writeInt(tag.value())); /** * {@link LongBinaryTag}. * * @since 4.0.0 */ - public static final BinaryTagType LONG = BinaryTagType.registerNumeric(LongBinaryTag.class, (byte) 4, input -> LongBinaryTag.of(input.readLong()), (tag, output) -> output.writeLong(tag.value())); + public static final BinaryTagType LONG = BinaryTagType.registerNumeric(LongBinaryTag.class, (byte) 4, input -> LongBinaryTag.longBinaryTag(input.readLong()), (tag, output) -> output.writeLong(tag.value())); /** * {@link FloatBinaryTag}. * * @since 4.0.0 */ - public static final BinaryTagType FLOAT = BinaryTagType.registerNumeric(FloatBinaryTag.class, (byte) 5, input -> FloatBinaryTag.of(input.readFloat()), (tag, output) -> output.writeFloat(tag.value())); + public static final BinaryTagType FLOAT = BinaryTagType.registerNumeric(FloatBinaryTag.class, (byte) 5, input -> FloatBinaryTag.floatBinaryTag(input.readFloat()), (tag, output) -> output.writeFloat(tag.value())); /** * {@link DoubleBinaryTag}. * * @since 4.0.0 */ - public static final BinaryTagType DOUBLE = BinaryTagType.registerNumeric(DoubleBinaryTag.class, (byte) 6, input -> DoubleBinaryTag.of(input.readDouble()), (tag, output) -> output.writeDouble(tag.value())); + public static final BinaryTagType DOUBLE = BinaryTagType.registerNumeric(DoubleBinaryTag.class, (byte) 6, input -> DoubleBinaryTag.doubleBinaryTag(input.readDouble()), (tag, output) -> output.writeDouble(tag.value())); /** * {@link ByteArrayBinaryTag}. * @@ -87,7 +87,7 @@ public final class BinaryTagTypes { try (final BinaryTagScope ignored = TrackingDataInput.enter(input, length)) { final byte[] value = new byte[length]; input.readFully(value); - return ByteArrayBinaryTag.of(value); + return ByteArrayBinaryTag.byteArrayBinaryTag(value); } }, (tag, output) -> { final byte[] value = ByteArrayBinaryTagImpl.value(tag); @@ -99,7 +99,7 @@ public final class BinaryTagTypes { * * @since 4.0.0 */ - public static final BinaryTagType STRING = BinaryTagType.register(StringBinaryTag.class, (byte) 8, input -> StringBinaryTag.of(input.readUTF()), (tag, output) -> output.writeUTF(tag.value())); + public static final BinaryTagType STRING = BinaryTagType.register(StringBinaryTag.class, (byte) 8, input -> StringBinaryTag.stringBinaryTag(input.readUTF()), (tag, output) -> output.writeUTF(tag.value())); /** * {@link ListBinaryTag}. * @@ -107,14 +107,14 @@ public final class BinaryTagTypes { */ @SuppressWarnings("try") public static final BinaryTagType LIST = BinaryTagType.register(ListBinaryTag.class, (byte) 9, input -> { - final BinaryTagType type = BinaryTagType.of(input.readByte()); + final BinaryTagType type = BinaryTagType.binaryTagType(input.readByte()); final int length = input.readInt(); try (final BinaryTagScope ignored = TrackingDataInput.enter(input, length * 8L)) { final List tags = new ArrayList<>(length); for (int i = 0; i < length; i++) { tags.add(type.read(input)); } - return ListBinaryTag.of(type, tags); + return ListBinaryTag.listBinaryTag(type, tags); } }, (tag, output) -> { output.writeByte(tag.elementType().id()); @@ -134,7 +134,7 @@ public final class BinaryTagTypes { try (final BinaryTagScope ignored = TrackingDataInput.enter(input)) { final Map tags = new HashMap<>(); BinaryTagType type; - while ((type = BinaryTagType.of(input.readByte())) != BinaryTagTypes.END) { + while ((type = BinaryTagType.binaryTagType(input.readByte())) != BinaryTagTypes.END) { final String key = input.readUTF(); final BinaryTag tag = type.read(input); tags.put(key, tag); @@ -169,7 +169,7 @@ public final class BinaryTagTypes { for (int i = 0; i < length; i++) { value[i] = input.readInt(); } - return IntArrayBinaryTag.of(value); + return IntArrayBinaryTag.intArrayBinaryTag(value); } }, (tag, output) -> { final int[] value = IntArrayBinaryTagImpl.value(tag); @@ -193,7 +193,7 @@ public final class BinaryTagTypes { for (int i = 0; i < length; i++) { value[i] = input.readLong(); } - return LongArrayBinaryTag.of(value); + return LongArrayBinaryTag.longArrayBinaryTag(value); } }, (tag, output) -> { final long[] value = LongArrayBinaryTagImpl.value(tag); diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/CompoundTagSetter.java b/nbt/src/main/java/net/kyori/adventure/nbt/CompoundTagSetter.java index f8577638c..74a3bf972 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/CompoundTagSetter.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/CompoundTagSetter.java @@ -107,7 +107,7 @@ public interface CompoundTagSetter { * @since 4.0.0 */ default @NotNull R putByte(final @NotNull String key, final byte value) { - return this.put(key, ByteBinaryTag.of(value)); + return this.put(key, ByteBinaryTag.byteBinaryTag(value)); } /** @@ -119,7 +119,7 @@ public interface CompoundTagSetter { * @since 4.0.0 */ default @NotNull R putShort(final @NotNull String key, final short value) { - return this.put(key, ShortBinaryTag.of(value)); + return this.put(key, ShortBinaryTag.shortBinaryTag(value)); } /** @@ -131,7 +131,7 @@ public interface CompoundTagSetter { * @since 4.0.0 */ default @NotNull R putInt(final @NotNull String key, final int value) { - return this.put(key, IntBinaryTag.of(value)); + return this.put(key, IntBinaryTag.intBinaryTag(value)); } /** @@ -143,7 +143,7 @@ public interface CompoundTagSetter { * @since 4.0.0 */ default @NotNull R putLong(final @NotNull String key, final long value) { - return this.put(key, LongBinaryTag.of(value)); + return this.put(key, LongBinaryTag.longBinaryTag(value)); } /** @@ -155,7 +155,7 @@ public interface CompoundTagSetter { * @since 4.0.0 */ default @NotNull R putFloat(final @NotNull String key, final float value) { - return this.put(key, FloatBinaryTag.of(value)); + return this.put(key, FloatBinaryTag.floatBinaryTag(value)); } /** @@ -167,7 +167,7 @@ public interface CompoundTagSetter { * @since 4.0.0 */ default @NotNull R putDouble(final @NotNull String key, final double value) { - return this.put(key, DoubleBinaryTag.of(value)); + return this.put(key, DoubleBinaryTag.doubleBinaryTag(value)); } /** @@ -179,7 +179,7 @@ public interface CompoundTagSetter { * @since 4.0.0 */ default @NotNull R putByteArray(final @NotNull String key, final byte@NotNull[] value) { - return this.put(key, ByteArrayBinaryTag.of(value)); + return this.put(key, ByteArrayBinaryTag.byteArrayBinaryTag(value)); } /** @@ -191,7 +191,7 @@ public interface CompoundTagSetter { * @since 4.0.0 */ default @NotNull R putString(final @NotNull String key, final @NotNull String value) { - return this.put(key, StringBinaryTag.of(value)); + return this.put(key, StringBinaryTag.stringBinaryTag(value)); } /** @@ -203,7 +203,7 @@ public interface CompoundTagSetter { * @since 4.0.0 */ default @NotNull R putIntArray(final @NotNull String key, final int@NotNull[] value) { - return this.put(key, IntArrayBinaryTag.of(value)); + return this.put(key, IntArrayBinaryTag.intArrayBinaryTag(value)); } /** @@ -215,6 +215,6 @@ public interface CompoundTagSetter { * @since 4.0.0 */ default @NotNull R putLongArray(final @NotNull String key, final long@NotNull[] value) { - return this.put(key, LongArrayBinaryTag.of(value)); + return this.put(key, LongArrayBinaryTag.longArrayBinaryTag(value)); } } diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/TagStringReader.java b/nbt/src/main/java/net/kyori/adventure/nbt/TagStringReader.java index 67bad86c3..68a4e9227 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/TagStringReader.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/TagStringReader.java @@ -94,11 +94,11 @@ public BinaryTag array(char elementType) throws StringTagParseException { elementType = Character.toLowerCase(elementType); if (elementType == Tokens.TYPE_BYTE) { - return ByteArrayBinaryTag.of(this.byteArray()); + return ByteArrayBinaryTag.byteArrayBinaryTag(this.byteArray()); } else if (elementType == Tokens.TYPE_INT) { - return IntArrayBinaryTag.of(this.intArray()); + return IntArrayBinaryTag.intArrayBinaryTag(this.intArray()); } else if (elementType == Tokens.TYPE_LONG) { - return LongArrayBinaryTag.of(this.longArray()); + return LongArrayBinaryTag.longArrayBinaryTag(this.longArray()); } else { throw this.buffer.makeError("Type " + elementType + " is not a valid element type in an array!"); } @@ -222,7 +222,7 @@ public BinaryTag tag() throws StringTagParseException { case Tokens.DOUBLE_QUOTE: // definitely a string tag this.buffer.advance(); - return StringBinaryTag.of(unescape(this.buffer.takeUntil(startToken).toString())); + return StringBinaryTag.stringBinaryTag(unescape(this.buffer.takeUntil(startToken).toString())); default: // scalar return this.scalar(); } @@ -264,23 +264,23 @@ private BinaryTag scalar() { try { switch (Character.toLowerCase(last)) { // try to read and return as a number case Tokens.TYPE_BYTE: - return ByteBinaryTag.of(Byte.parseByte(built.substring(0, length - 1))); + return ByteBinaryTag.byteBinaryTag(Byte.parseByte(built.substring(0, length - 1))); case Tokens.TYPE_SHORT: - return ShortBinaryTag.of(Short.parseShort(built.substring(0, length - 1))); + return ShortBinaryTag.shortBinaryTag(Short.parseShort(built.substring(0, length - 1))); case Tokens.TYPE_INT: - return IntBinaryTag.of(Integer.parseInt(built.substring(0, length - 1))); + return IntBinaryTag.intBinaryTag(Integer.parseInt(built.substring(0, length - 1))); case Tokens.TYPE_LONG: - return LongBinaryTag.of(Long.parseLong(built.substring(0, length - 1))); + return LongBinaryTag.longBinaryTag(Long.parseLong(built.substring(0, length - 1))); case Tokens.TYPE_FLOAT: final float floatValue = Float.parseFloat(built.substring(0, length - 1)); if (Float.isFinite(floatValue)) { // don't accept NaN and Infinity - return FloatBinaryTag.of(floatValue); + return FloatBinaryTag.floatBinaryTag(floatValue); } break; case Tokens.TYPE_DOUBLE: final double doubleValue = Double.parseDouble(built.substring(0, length - 1)); if (Double.isFinite(doubleValue)) { // don't accept NaN and Infinity - return DoubleBinaryTag.of(doubleValue); + return DoubleBinaryTag.doubleBinaryTag(doubleValue); } break; } @@ -289,11 +289,11 @@ private BinaryTag scalar() { } } else if (noLongerNumericAt == -1) { // if we run out of content without an explicit value separator, then we're either an integer or string tag -- all others have a character at the end try { - return IntBinaryTag.of(Integer.parseInt(built)); + return IntBinaryTag.intBinaryTag(Integer.parseInt(built)); } catch (final NumberFormatException ex) { if (built.indexOf('.') != -1) { // see if we have an unsuffixed double; always needs a dot try { - return DoubleBinaryTag.of(Double.parseDouble(built)); + return DoubleBinaryTag.doubleBinaryTag(Double.parseDouble(built)); } catch (final NumberFormatException ex2) { // ignore } @@ -306,7 +306,7 @@ private BinaryTag scalar() { } else if (built.equalsIgnoreCase(Tokens.LITERAL_FALSE)) { return ByteBinaryTag.ZERO; } - return StringBinaryTag.of(built); + return StringBinaryTag.stringBinaryTag(built); } From 927c84b0a65f32fc144e19c953e87bde91b45b33 Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Thu, 11 May 2023 22:37:09 +0200 Subject: [PATCH 6/8] fix checkstyle and replace deprecated usage in tests --- .../adventure/text/event/HoverEventTest.java | 26 +++++++++---------- .../kyori/adventure/nbt/BinaryTagType.java | 1 - .../kyori/adventure/nbt/BinaryTagTypes.java | 2 +- .../adventure/nbt/ByteArrayBinaryTag.java | 2 +- .../kyori/adventure/nbt/DoubleBinaryTag.java | 2 -- .../net/kyori/adventure/nbt/EndBinaryTag.java | 14 ++++++++++ .../adventure/nbt/IntArrayBinaryTag.java | 1 - .../net/kyori/adventure/nbt/IntBinaryTag.java | 2 +- .../kyori/adventure/nbt/ListBinaryTag.java | 1 - .../adventure/nbt/LongArrayBinaryTag.java | 2 -- .../kyori/adventure/nbt/LongBinaryTag.java | 2 -- .../java/net/kyori/adventure/nbt/BigTest.java | 10 +++---- .../adventure/nbt/ListBinaryTagTest.java | 24 ++++++++--------- .../kyori/adventure/nbt/ReadWriteTest.java | 26 +++++++++---------- .../HoverEventShowEntitySerializer.java | 2 +- .../HoverEventShowItemSerializer.java | 2 +- .../HoverEventSerializersTest.java | 8 +++--- .../HoverEventShowEntitySerializer.java | 2 +- .../HoverEventShowItemSerializer.java | 2 +- .../HoverEventSerializersTest.java | 8 +++--- .../minimessage/tag/standard/HoverTag.java | 8 +++--- .../NBTLegacyHoverEventSerializerImpl.java | 4 +-- 22 files changed, 78 insertions(+), 73 deletions(-) diff --git a/api/src/test/java/net/kyori/adventure/text/event/HoverEventTest.java b/api/src/test/java/net/kyori/adventure/text/event/HoverEventTest.java index 132b3b2d0..a36564f60 100644 --- a/api/src/test/java/net/kyori/adventure/text/event/HoverEventTest.java +++ b/api/src/test/java/net/kyori/adventure/text/event/HoverEventTest.java @@ -46,7 +46,7 @@ void testAsHoverEvent() { @Test void testShowItemItem() { - final HoverEvent.ShowItem si0 = HoverEvent.ShowItem.of(Key.key("stone"), 1); + final HoverEvent.ShowItem si0 = HoverEvent.ShowItem.showItem(Key.key("stone"), 1); assertEquals(Key.key("stone"), si0.item()); final HoverEvent.ShowItem si1 = si0.item(Key.key("dirt")); assertEquals(Key.key("stone"), si0.item()); // original should be unmodified @@ -55,7 +55,7 @@ void testShowItemItem() { @Test void testShowItemCount() { - final HoverEvent.ShowItem si0 = HoverEvent.ShowItem.of(Key.key("stone"), 1); + final HoverEvent.ShowItem si0 = HoverEvent.ShowItem.showItem(Key.key("stone"), 1); assertEquals(1, si0.count()); assertSame(si0, si0.count(1)); // unmodified final HoverEvent.ShowItem si1 = si0.count(2); @@ -65,7 +65,7 @@ void testShowItemCount() { @Test void testShowEntityType() { - final HoverEvent.ShowEntity se0 = HoverEvent.ShowEntity.of(Key.key("cow"), UUID.randomUUID()); + final HoverEvent.ShowEntity se0 = HoverEvent.ShowEntity.showEntity(Key.key("cow"), UUID.randomUUID()); assertEquals(Key.key("cow"), se0.type()); final HoverEvent.ShowEntity se1 = se0.type(Key.key("chicken")); assertEquals(Key.key("cow"), se0.type()); // original should be unmodified @@ -75,7 +75,7 @@ void testShowEntityType() { @Test void testShowEntityId() { final UUID id0 = UUID.randomUUID(); - final HoverEvent.ShowEntity se0 = HoverEvent.ShowEntity.of(Key.key("cow"), id0); + final HoverEvent.ShowEntity se0 = HoverEvent.ShowEntity.showEntity(Key.key("cow"), id0); assertEquals(id0, se0.id()); final UUID id1 = UUID.randomUUID(); final HoverEvent.ShowEntity se1 = se0.id(id1); @@ -86,7 +86,7 @@ void testShowEntityId() { @Test void testShowEntityName() { final Component n0 = Component.text("Cow"); - final HoverEvent.ShowEntity se0 = HoverEvent.ShowEntity.of(Key.key("cow"), UUID.randomUUID(), n0); + final HoverEvent.ShowEntity se0 = HoverEvent.ShowEntity.showEntity(Key.key("cow"), UUID.randomUUID(), n0); assertEquals(n0, se0.name()); final Component n1 = Component.text("Chicken"); final HoverEvent.ShowEntity se1 = se0.name(n1); @@ -104,19 +104,19 @@ void testEquality() { HoverEvent.hoverEvent(HoverEvent.Action.SHOW_TEXT, Component.empty()) ) .addEqualityGroup( - HoverEvent.showItem(HoverEvent.ShowItem.of(Key.key("air"), 1, null)), - HoverEvent.hoverEvent(HoverEvent.Action.SHOW_ITEM, HoverEvent.ShowItem.of(Key.key("air"), 1, null)) + HoverEvent.showItem(HoverEvent.ShowItem.showItem(Key.key("air"), 1, null)), + HoverEvent.hoverEvent(HoverEvent.Action.SHOW_ITEM, HoverEvent.ShowItem.showItem(Key.key("air"), 1, null)) ) .addEqualityGroup( - HoverEvent.showEntity(HoverEvent.ShowEntity.of(Key.key("cat"), entity)), - HoverEvent.showEntity(HoverEvent.ShowEntity.of(Key.key("cat"), entity, null)), - HoverEvent.hoverEvent(HoverEvent.Action.SHOW_ENTITY, HoverEvent.ShowEntity.of(Key.key("cat"), entity)), - HoverEvent.hoverEvent(HoverEvent.Action.SHOW_ENTITY, HoverEvent.ShowEntity.of(Key.key("cat"), entity, null)), + HoverEvent.showEntity(HoverEvent.ShowEntity.showEntity(Key.key("cat"), entity)), + HoverEvent.showEntity(HoverEvent.ShowEntity.showEntity(Key.key("cat"), entity, null)), + HoverEvent.hoverEvent(HoverEvent.Action.SHOW_ENTITY, HoverEvent.ShowEntity.showEntity(Key.key("cat"), entity)), + HoverEvent.hoverEvent(HoverEvent.Action.SHOW_ENTITY, HoverEvent.ShowEntity.showEntity(Key.key("cat"), entity, null)), HoverEvent.showEntity(Key.key("cat"), entity, null) ) .addEqualityGroup( - HoverEvent.showEntity(HoverEvent.ShowEntity.of(Key.key("cat"), entity, Component.empty())), - HoverEvent.hoverEvent(HoverEvent.Action.SHOW_ENTITY, HoverEvent.ShowEntity.of(Key.key("cat"), entity, Component.empty())), + HoverEvent.showEntity(HoverEvent.ShowEntity.showEntity(Key.key("cat"), entity, Component.empty())), + HoverEvent.hoverEvent(HoverEvent.Action.SHOW_ENTITY, HoverEvent.ShowEntity.showEntity(Key.key("cat"), entity, Component.empty())), HoverEvent.showEntity(Key.key("cat"), entity, Component.empty()) ) .testEquals(); diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagType.java b/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagType.java index 971f1d0aa..f33c33a28 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagType.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagType.java @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; - import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagTypes.java b/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagTypes.java index 012c28736..4f2ee6be6 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagTypes.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/BinaryTagTypes.java @@ -39,7 +39,7 @@ public final class BinaryTagTypes { * * @since 4.0.0 */ - public static final BinaryTagType END = BinaryTagType.register(EndBinaryTag.class, (byte) 0, input -> EndBinaryTag.get(), null); // nothing to write + public static final BinaryTagType END = BinaryTagType.register(EndBinaryTag.class, (byte) 0, input -> EndBinaryTag.endBinaryTag(), null); // nothing to write /** * {@link ByteBinaryTag}. * diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/ByteArrayBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/ByteArrayBinaryTag.java index 2fc456c2c..54423ba94 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/ByteArrayBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/ByteArrayBinaryTag.java @@ -49,7 +49,7 @@ public interface ByteArrayBinaryTag extends ArrayBinaryTag, Iterable { * @param value the value * @return a binary tag * @since 4.0.0 - * @deprecated for removal since 4.14.0, use {@link #byteArrayBinaryTag(byte...) instead. + * @deprecated for removal since 4.14.0, use {@link #byteArrayBinaryTag(byte...)} instead. */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/DoubleBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/DoubleBinaryTag.java index bd73e354d..b0724e38f 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/DoubleBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/DoubleBinaryTag.java @@ -26,8 +26,6 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import java.util.UUID; - /** * A binary tag holding a {@code double} value. * diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/EndBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/EndBinaryTag.java index 87551c778..765511915 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/EndBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/EndBinaryTag.java @@ -23,6 +23,7 @@ */ package net.kyori.adventure.nbt; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -31,12 +32,25 @@ * @since 4.0.0 */ public interface EndBinaryTag extends BinaryTag { + /** + * Gets the end tag. + * + * @return the end tag + * @since 4.14.0 + */ + static @NotNull EndBinaryTag endBinaryTag() { + return EndBinaryTagImpl.INSTANCE; + } + /** * Gets the end tag. * * @return the end tag * @since 4.0.0 + * @deprecated for removal since 4.14.0, use {@link #endBinaryTag()} instead */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") static @NotNull EndBinaryTag get() { return EndBinaryTagImpl.INSTANCE; } diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java index 77e9bd43d..89b34ba36 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTag.java @@ -27,7 +27,6 @@ import java.util.Spliterator; import java.util.function.IntConsumer; import java.util.stream.IntStream; - import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java index 9ed534831..51eb0ad3c 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java @@ -42,7 +42,7 @@ public interface IntBinaryTag extends NumberBinaryTag { static @NotNull IntBinaryTag intBinaryTag(final int value) { return new IntBinaryTagImpl(value); } - + /** * Creates a binary tag holding an {@code int} value. * diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java index 04e17b80c..fa8095aa9 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.function.Consumer; import java.util.stream.Stream; - import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/LongArrayBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/LongArrayBinaryTag.java index 320a79610..48851846d 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/LongArrayBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/LongArrayBinaryTag.java @@ -23,12 +23,10 @@ */ package net.kyori.adventure.nbt; -import java.util.List; import java.util.PrimitiveIterator; import java.util.Spliterator; import java.util.function.LongConsumer; import java.util.stream.LongStream; - import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/LongBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/LongBinaryTag.java index 5d923cc0d..364b62561 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/LongBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/LongBinaryTag.java @@ -26,8 +26,6 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import java.util.List; - /** * A binary tag holding a {@code long} value. * diff --git a/nbt/src/test/java/net/kyori/adventure/nbt/BigTest.java b/nbt/src/test/java/net/kyori/adventure/nbt/BigTest.java index 0a65fe4e5..0df4fe1be 100644 --- a/nbt/src/test/java/net/kyori/adventure/nbt/BigTest.java +++ b/nbt/src/test/java/net/kyori/adventure/nbt/BigTest.java @@ -40,11 +40,11 @@ class BigTest { private static final double DOUBLE_DELTA = 1e-15; private static final byte[] BYTE_ARRAY_TEST = new byte[1000]; private static final ListBinaryTag LONG_LIST = ListBinaryTag.builder(BinaryTagTypes.LONG) - .add(LongBinaryTag.of(11)) - .add(LongBinaryTag.of(12)) - .add(LongBinaryTag.of(13)) - .add(LongBinaryTag.of(14)) - .add(LongBinaryTag.of(15)) + .add(LongBinaryTag.longBinaryTag(11)) + .add(LongBinaryTag.longBinaryTag(12)) + .add(LongBinaryTag.longBinaryTag(13)) + .add(LongBinaryTag.longBinaryTag(14)) + .add(LongBinaryTag.longBinaryTag(15)) .build(); private static final ListBinaryTag COMPOUND_LIST = ListBinaryTag.builder(BinaryTagTypes.COMPOUND) .add( diff --git a/nbt/src/test/java/net/kyori/adventure/nbt/ListBinaryTagTest.java b/nbt/src/test/java/net/kyori/adventure/nbt/ListBinaryTagTest.java index 834d6516a..9f2f26858 100644 --- a/nbt/src/test/java/net/kyori/adventure/nbt/ListBinaryTagTest.java +++ b/nbt/src/test/java/net/kyori/adventure/nbt/ListBinaryTagTest.java @@ -38,28 +38,28 @@ void testCreateEndBuilder() { @Test void testAddEnd() { final ListBinaryTag l0 = ListBinaryTag.empty(); - assertThrows(IllegalArgumentException.class, () -> l0.add(EndBinaryTag.get())); + assertThrows(IllegalArgumentException.class, () -> l0.add(EndBinaryTag.endBinaryTag())); } @Test void testAddOtherToEndChangesType() { final ListBinaryTag l0 = ListBinaryTag.empty(); - final ListBinaryTag l1 = l0.add(IntBinaryTag.of(13)); + final ListBinaryTag l1 = l0.add(IntBinaryTag.intBinaryTag(13)); assertEquals(BinaryTagTypes.INT, l1.elementType()); } @Test void testMismatchedAdd() { - final ListBinaryTag l0 = ListBinaryTag.of(BinaryTagTypes.BYTE, ImmutableList.of(ByteBinaryTag.of((byte) 0))); - assertThrows(IllegalArgumentException.class, () -> l0.add(IntBinaryTag.of(1))); + final ListBinaryTag l0 = ListBinaryTag.listBinaryTag(BinaryTagTypes.BYTE, ImmutableList.of(ByteBinaryTag.byteBinaryTag((byte) 0))); + assertThrows(IllegalArgumentException.class, () -> l0.add(IntBinaryTag.intBinaryTag(1))); } @Test void testSet() { - final IntBinaryTag i0 = IntBinaryTag.of(0); - final IntBinaryTag i1 = IntBinaryTag.of(1); - final IntBinaryTag i2 = IntBinaryTag.of(2); - final ListBinaryTag l3 = ListBinaryTag.of(BinaryTagTypes.INT, ImmutableList.of(i0, i1, i2)); + final IntBinaryTag i0 = IntBinaryTag.intBinaryTag(0); + final IntBinaryTag i1 = IntBinaryTag.intBinaryTag(1); + final IntBinaryTag i2 = IntBinaryTag.intBinaryTag(2); + final ListBinaryTag l3 = ListBinaryTag.listBinaryTag(BinaryTagTypes.INT, ImmutableList.of(i0, i1, i2)); final ListBinaryTag l2 = l3.set(1, i0, removed -> assertEquals(i1, removed)); assertEquals(i0, l2.get(0)); assertEquals(i0, l2.get(1)); @@ -77,10 +77,10 @@ void testSet() { @Test void testRemove() { - final IntBinaryTag i0 = IntBinaryTag.of(0); - final IntBinaryTag i1 = IntBinaryTag.of(1); - final IntBinaryTag i2 = IntBinaryTag.of(2); - final ListBinaryTag l3 = ListBinaryTag.of(BinaryTagTypes.INT, ImmutableList.of(i0, i1, i2)); + final IntBinaryTag i0 = IntBinaryTag.intBinaryTag(0); + final IntBinaryTag i1 = IntBinaryTag.intBinaryTag(1); + final IntBinaryTag i2 = IntBinaryTag.intBinaryTag(2); + final ListBinaryTag l3 = ListBinaryTag.listBinaryTag(BinaryTagTypes.INT, ImmutableList.of(i0, i1, i2)); final ListBinaryTag l2 = l3.remove(1, removed -> assertEquals(i1, removed)); assertEquals(2, l2.size()); assertEquals(i0, l2.get(0)); diff --git a/nbt/src/test/java/net/kyori/adventure/nbt/ReadWriteTest.java b/nbt/src/test/java/net/kyori/adventure/nbt/ReadWriteTest.java index 7c79b39f0..54016da5d 100644 --- a/nbt/src/test/java/net/kyori/adventure/nbt/ReadWriteTest.java +++ b/nbt/src/test/java/net/kyori/adventure/nbt/ReadWriteTest.java @@ -34,12 +34,12 @@ class ReadWriteTest { @Test void testByteArray() throws IOException { - this.testWriteRead(ByteArrayBinaryTag.of(Byte.MIN_VALUE, (byte) -100, (byte) 0, (byte) 100, Byte.MAX_VALUE), BinaryTagTypes.BYTE_ARRAY); + this.testWriteRead(ByteArrayBinaryTag.byteArrayBinaryTag(Byte.MIN_VALUE, (byte) -100, (byte) 0, (byte) 100, Byte.MAX_VALUE), BinaryTagTypes.BYTE_ARRAY); } @Test void testByte() throws IOException { - this.testWriteRead(ByteBinaryTag.of((byte) 2), BinaryTagTypes.BYTE); + this.testWriteRead(ByteBinaryTag.byteBinaryTag((byte) 2), BinaryTagTypes.BYTE); } @Test @@ -54,34 +54,34 @@ void testCompound() throws IOException { @Test void testDouble() throws IOException { - this.testWriteRead(DoubleBinaryTag.of(4d), BinaryTagTypes.DOUBLE); + this.testWriteRead(DoubleBinaryTag.doubleBinaryTag(4d), BinaryTagTypes.DOUBLE); } @Test void testEnd() throws IOException { - this.testWriteRead(EndBinaryTag.get(), BinaryTagTypes.END); + this.testWriteRead(EndBinaryTag.endBinaryTag(), BinaryTagTypes.END); } @Test void testFloat() throws IOException { - this.testWriteRead(FloatBinaryTag.of(6f), BinaryTagTypes.FLOAT); + this.testWriteRead(FloatBinaryTag.floatBinaryTag(6f), BinaryTagTypes.FLOAT); } @Test void testIntArray() throws IOException { - this.testWriteRead(IntArrayBinaryTag.of(Integer.MIN_VALUE, -100, 0, 100, Integer.MAX_VALUE), BinaryTagTypes.INT_ARRAY); + this.testWriteRead(IntArrayBinaryTag.intArrayBinaryTag(Integer.MIN_VALUE, -100, 0, 100, Integer.MAX_VALUE), BinaryTagTypes.INT_ARRAY); } @Test void testInt() throws IOException { - this.testWriteRead(IntBinaryTag.of(8), BinaryTagTypes.INT); + this.testWriteRead(IntBinaryTag.intBinaryTag(8), BinaryTagTypes.INT); } @Test void testList() throws IOException { final ListBinaryTag a = ListBinaryTag.builder() - .add(DoubleBinaryTag.of(32d)) - .add(DoubleBinaryTag.of(64d)) + .add(DoubleBinaryTag.doubleBinaryTag(32d)) + .add(DoubleBinaryTag.doubleBinaryTag(64d)) .build(); final ListBinaryTag b = this.testWriteRead(a, BinaryTagTypes.LIST); assertEquals(a.elementType(), b.elementType()); @@ -89,22 +89,22 @@ void testList() throws IOException { @Test void testLongArray() throws IOException { - this.testWriteRead(LongArrayBinaryTag.of(Long.MIN_VALUE, -100, 0, 100, Long.MAX_VALUE), BinaryTagTypes.LONG_ARRAY); + this.testWriteRead(LongArrayBinaryTag.longArrayBinaryTag(Long.MIN_VALUE, -100, 0, 100, Long.MAX_VALUE), BinaryTagTypes.LONG_ARRAY); } @Test void testLong() throws IOException { - this.testWriteRead(LongBinaryTag.of(10), BinaryTagTypes.LONG); + this.testWriteRead(LongBinaryTag.longBinaryTag(10), BinaryTagTypes.LONG); } @Test void testShort() throws IOException { - this.testWriteRead(ShortBinaryTag.of((short) 12), BinaryTagTypes.SHORT); + this.testWriteRead(ShortBinaryTag.shortBinaryTag((short) 12), BinaryTagTypes.SHORT); } @Test void testString() throws IOException { - this.testWriteRead(StringBinaryTag.of("Hello, world!"), BinaryTagTypes.STRING); + this.testWriteRead(StringBinaryTag.stringBinaryTag("Hello, world!"), BinaryTagTypes.STRING); } private T testWriteRead(final T a, final BinaryTagType type) throws IOException { diff --git a/serializer-configurate3/src/main/java/net/kyori/adventure/serializer/configurate3/HoverEventShowEntitySerializer.java b/serializer-configurate3/src/main/java/net/kyori/adventure/serializer/configurate3/HoverEventShowEntitySerializer.java index 6782b7670..d31ae0a66 100644 --- a/serializer-configurate3/src/main/java/net/kyori/adventure/serializer/configurate3/HoverEventShowEntitySerializer.java +++ b/serializer-configurate3/src/main/java/net/kyori/adventure/serializer/configurate3/HoverEventShowEntitySerializer.java @@ -56,7 +56,7 @@ public HoverEvent.ShowEntity deserialize(final @NotNull TypeToken type, final } final @Nullable Component name = value.getNode(NAME).getValue(ComponentTypeSerializer.TYPE); - return HoverEvent.ShowEntity.of(typeId, id, name); + return HoverEvent.ShowEntity.showEntity(typeId, id, name); } @Override diff --git a/serializer-configurate3/src/main/java/net/kyori/adventure/serializer/configurate3/HoverEventShowItemSerializer.java b/serializer-configurate3/src/main/java/net/kyori/adventure/serializer/configurate3/HoverEventShowItemSerializer.java index 263448833..03741bba2 100644 --- a/serializer-configurate3/src/main/java/net/kyori/adventure/serializer/configurate3/HoverEventShowItemSerializer.java +++ b/serializer-configurate3/src/main/java/net/kyori/adventure/serializer/configurate3/HoverEventShowItemSerializer.java @@ -54,7 +54,7 @@ public HoverEvent.ShowItem deserialize(final @NotNull TypeToken type, final @ final int count = value.getNode(COUNT).getInt(1); final String tag = value.getNode(TAG).getString(); - return HoverEvent.ShowItem.of(id, count, tag == null ? null : BinaryTagHolder.binaryTagHolder(tag)); + return HoverEvent.ShowItem.showItem(id, count, tag == null ? null : BinaryTagHolder.binaryTagHolder(tag)); } @Override diff --git a/serializer-configurate3/src/test/java/net/kyori/adventure/serializer/configurate3/HoverEventSerializersTest.java b/serializer-configurate3/src/test/java/net/kyori/adventure/serializer/configurate3/HoverEventSerializersTest.java index 822a75e98..0687538ac 100644 --- a/serializer-configurate3/src/test/java/net/kyori/adventure/serializer/configurate3/HoverEventSerializersTest.java +++ b/serializer-configurate3/src/test/java/net/kyori/adventure/serializer/configurate3/HoverEventSerializersTest.java @@ -47,7 +47,7 @@ void testShowEntity() { }); }); final Component component = Component.text().content("kashike") - .hoverEvent(HoverEvent.showEntity(HoverEvent.ShowEntity.of(Key.key("minecraft:cat"), UUID.fromString("eb121687-8b1a-4944-bd4d-e0a818d9dfe2")))) + .hoverEvent(HoverEvent.showEntity(HoverEvent.ShowEntity.showEntity(Key.key("minecraft:cat"), UUID.fromString("eb121687-8b1a-4944-bd4d-e0a818d9dfe2")))) .build(); this.assertRoundtrippable(component, node); @@ -67,7 +67,7 @@ void testShowEntityCustomName() { }); }); final Component component = Component.text().content("kashike") - .hoverEvent(HoverEvent.showEntity(HoverEvent.ShowEntity.of(Key.key("minecraft:cat"), UUID.fromString("eb121687-8b1a-4944-bd4d-e0a818d9dfe2"), Component.text("meow")))) + .hoverEvent(HoverEvent.showEntity(HoverEvent.ShowEntity.showEntity(Key.key("minecraft:cat"), UUID.fromString("eb121687-8b1a-4944-bd4d-e0a818d9dfe2"), Component.text("meow")))) .build(); this.assertRoundtrippable(component, node); @@ -95,7 +95,7 @@ void testShowItem() { .color(NamedTextColor.AQUA) .append(Component.translatable("item.minecraft.purple_wool")) .append(Component.text("]")) - .hoverEvent(HoverEvent.showItem(HoverEvent.ShowItem.of(Key.key("minecraft:purple_wool"), 2, BinaryTagHolder.binaryTagHolder("{Damage: 5b}")))) + .hoverEvent(HoverEvent.showItem(HoverEvent.ShowItem.showItem(Key.key("minecraft:purple_wool"), 2, BinaryTagHolder.binaryTagHolder("{Damage: 5b}")))) .build(); this.assertRoundtrippable(component, node); @@ -122,7 +122,7 @@ void testShowItemNoTag() { .color(NamedTextColor.AQUA) .append(Component.translatable("item.minecraft.purple_wool")) .append(Component.text("]")) - .hoverEvent(HoverEvent.showItem(HoverEvent.ShowItem.of(Key.key("minecraft:purple_wool"), 1))) + .hoverEvent(HoverEvent.showItem(HoverEvent.ShowItem.showItem(Key.key("minecraft:purple_wool"), 1))) .build(); this.assertRoundtrippable(component, node); diff --git a/serializer-configurate4/src/main/java/net/kyori/adventure/serializer/configurate4/HoverEventShowEntitySerializer.java b/serializer-configurate4/src/main/java/net/kyori/adventure/serializer/configurate4/HoverEventShowEntitySerializer.java index 1e8fb53ed..814086050 100644 --- a/serializer-configurate4/src/main/java/net/kyori/adventure/serializer/configurate4/HoverEventShowEntitySerializer.java +++ b/serializer-configurate4/src/main/java/net/kyori/adventure/serializer/configurate4/HoverEventShowEntitySerializer.java @@ -53,7 +53,7 @@ public HoverEvent.ShowEntity deserialize(final @NotNull Type type, final @NotNul } final @Nullable Component name = value.node(NAME).get(Component.class); - return HoverEvent.ShowEntity.of(typeId, id, name); + return HoverEvent.ShowEntity.showEntity(typeId, id, name); } @Override diff --git a/serializer-configurate4/src/main/java/net/kyori/adventure/serializer/configurate4/HoverEventShowItemSerializer.java b/serializer-configurate4/src/main/java/net/kyori/adventure/serializer/configurate4/HoverEventShowItemSerializer.java index cbc0daabb..c9721752b 100644 --- a/serializer-configurate4/src/main/java/net/kyori/adventure/serializer/configurate4/HoverEventShowItemSerializer.java +++ b/serializer-configurate4/src/main/java/net/kyori/adventure/serializer/configurate4/HoverEventShowItemSerializer.java @@ -52,7 +52,7 @@ public HoverEvent.ShowItem deserialize(final @NotNull Type type, final @NotNull final int count = value.node(COUNT).getInt(1); final String tag = value.node(TAG).getString(); - return HoverEvent.ShowItem.of(id, count, tag == null ? null : BinaryTagHolder.binaryTagHolder(tag)); + return HoverEvent.ShowItem.showItem(id, count, tag == null ? null : BinaryTagHolder.binaryTagHolder(tag)); } @Override diff --git a/serializer-configurate4/src/test/java/net/kyori/adventure/serializer/configurate4/HoverEventSerializersTest.java b/serializer-configurate4/src/test/java/net/kyori/adventure/serializer/configurate4/HoverEventSerializersTest.java index 524f37914..9bff93ca7 100644 --- a/serializer-configurate4/src/test/java/net/kyori/adventure/serializer/configurate4/HoverEventSerializersTest.java +++ b/serializer-configurate4/src/test/java/net/kyori/adventure/serializer/configurate4/HoverEventSerializersTest.java @@ -47,7 +47,7 @@ void testShowEntity() { }); }); final Component component = Component.text().content("kashike") - .hoverEvent(HoverEvent.showEntity(HoverEvent.ShowEntity.of(Key.key("minecraft:cat"), UUID.fromString("eb121687-8b1a-4944-bd4d-e0a818d9dfe2")))) + .hoverEvent(HoverEvent.showEntity(HoverEvent.ShowEntity.showEntity(Key.key("minecraft:cat"), UUID.fromString("eb121687-8b1a-4944-bd4d-e0a818d9dfe2")))) .build(); this.assertRoundtrippable(component, node); @@ -67,7 +67,7 @@ void testShowEntityCustomName() { }); }); final Component component = Component.text().content("kashike") - .hoverEvent(HoverEvent.showEntity(HoverEvent.ShowEntity.of(Key.key("minecraft:cat"), UUID.fromString("eb121687-8b1a-4944-bd4d-e0a818d9dfe2"), Component.text("meow")))) + .hoverEvent(HoverEvent.showEntity(HoverEvent.ShowEntity.showEntity(Key.key("minecraft:cat"), UUID.fromString("eb121687-8b1a-4944-bd4d-e0a818d9dfe2"), Component.text("meow")))) .build(); this.assertRoundtrippable(component, node); @@ -95,7 +95,7 @@ void testShowItem() { .color(NamedTextColor.AQUA) .append(Component.translatable("item.minecraft.purple_wool")) .append(Component.text("]")) - .hoverEvent(HoverEvent.showItem(HoverEvent.ShowItem.of(Key.key("minecraft:purple_wool"), 2, BinaryTagHolder.binaryTagHolder("{Damage: 5b}")))) + .hoverEvent(HoverEvent.showItem(HoverEvent.ShowItem.showItem(Key.key("minecraft:purple_wool"), 2, BinaryTagHolder.binaryTagHolder("{Damage: 5b}")))) .build(); this.assertRoundtrippable(component, node); @@ -122,7 +122,7 @@ void testShowItemNoTag() { .color(NamedTextColor.AQUA) .append(Component.translatable("item.minecraft.purple_wool")) .append(Component.text("]")) - .hoverEvent(HoverEvent.showItem(HoverEvent.ShowItem.of(Key.key("minecraft:purple_wool"), 1))) + .hoverEvent(HoverEvent.showItem(HoverEvent.ShowItem.showItem(Key.key("minecraft:purple_wool"), 1))) .build(); this.assertRoundtrippable(component, node); diff --git a/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/tag/standard/HoverTag.java b/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/tag/standard/HoverTag.java index 39e97f513..37b778b22 100644 --- a/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/tag/standard/HoverTag.java +++ b/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/tag/standard/HoverTag.java @@ -126,9 +126,9 @@ private ShowItem() { final Key key = Key.key(args.popOr("Show item hover needs at least an item ID").value()); final int count = args.hasNext() ? args.pop().asInt().orElseThrow(() -> ctx.newException("The count argument was not a valid integer")) : 1; if (args.hasNext()) { - return HoverEvent.ShowItem.of(key, count, BinaryTagHolder.binaryTagHolder(args.pop().value())); + return HoverEvent.ShowItem.showItem(key, count, BinaryTagHolder.binaryTagHolder(args.pop().value())); } else { - return HoverEvent.ShowItem.of(key, count); + return HoverEvent.ShowItem.showItem(key, count); } } catch (final InvalidKeyException | NumberFormatException ex) { throw ctx.newException("Exception parsing show_item hover", ex, args); @@ -162,9 +162,9 @@ private ShowEntity() { final UUID id = UUID.fromString(args.popOr("Show entity needs an entity UUID").value()); if (args.hasNext()) { final Component name = ctx.deserialize(args.pop().value()); - return HoverEvent.ShowEntity.of(key, id, name); + return HoverEvent.ShowEntity.showEntity(key, id, name); } - return HoverEvent.ShowEntity.of(key, id); + return HoverEvent.ShowEntity.showEntity(key, id); } catch (final IllegalArgumentException | InvalidKeyException ex) { throw ctx.newException("Exception parsing show_entity hover", ex, args); } diff --git a/text-serializer-gson-legacy-impl/src/main/java/net/kyori/adventure/text/serializer/gson/legacyimpl/NBTLegacyHoverEventSerializerImpl.java b/text-serializer-gson-legacy-impl/src/main/java/net/kyori/adventure/text/serializer/gson/legacyimpl/NBTLegacyHoverEventSerializerImpl.java index 4d3dbf607..4603d0ee0 100644 --- a/text-serializer-gson-legacy-impl/src/main/java/net/kyori/adventure/text/serializer/gson/legacyimpl/NBTLegacyHoverEventSerializerImpl.java +++ b/text-serializer-gson-legacy-impl/src/main/java/net/kyori/adventure/text/serializer/gson/legacyimpl/NBTLegacyHoverEventSerializerImpl.java @@ -58,7 +58,7 @@ private NBTLegacyHoverEventSerializerImpl() { assertTextComponent(input); final CompoundBinaryTag contents = SNBT_CODEC.decode(((TextComponent) input).content()); final CompoundBinaryTag tag = contents.getCompound(ITEM_TAG); - return HoverEvent.ShowItem.of( + return HoverEvent.ShowItem.showItem( Key.key(contents.getString(ITEM_TYPE)), contents.getByte(ITEM_COUNT, (byte) 1), tag == CompoundBinaryTag.empty() ? null : BinaryTagHolder.encode(tag, SNBT_CODEC) @@ -69,7 +69,7 @@ private NBTLegacyHoverEventSerializerImpl() { public HoverEvent.@NotNull ShowEntity deserializeShowEntity(final @NotNull Component input, final Codec.Decoder componentCodec) throws IOException { assertTextComponent(input); final CompoundBinaryTag contents = SNBT_CODEC.decode(((TextComponent) input).content()); - return HoverEvent.ShowEntity.of( + return HoverEvent.ShowEntity.showEntity( Key.key(contents.getString(ENTITY_TYPE)), UUID.fromString(contents.getString(ENTITY_ID)), componentCodec.decode(contents.getString(ENTITY_NAME)) From 4fa2e0aa48f9251ba215162645d71955a9cdc992 Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Thu, 11 May 2023 22:58:19 +0200 Subject: [PATCH 7/8] replace more deprecated stuff --- .../net/kyori/adventure/nbt/StringIOTest.java | 140 +++++++++--------- .../serializer/gson/ShowEntitySerializer.java | 2 +- .../serializer/gson/ShowItemSerializer.java | 2 +- .../gson/ShowItemSerializerTest.java | 6 +- .../text/serializer/gson/StyleTest.java | 4 +- 5 files changed, 77 insertions(+), 77 deletions(-) diff --git a/nbt/src/test/java/net/kyori/adventure/nbt/StringIOTest.java b/nbt/src/test/java/net/kyori/adventure/nbt/StringIOTest.java index e097a7f8c..3f130ee7a 100644 --- a/nbt/src/test/java/net/kyori/adventure/nbt/StringIOTest.java +++ b/nbt/src/test/java/net/kyori/adventure/nbt/StringIOTest.java @@ -40,7 +40,7 @@ class StringIOTest { void testReadKeyValuePair() throws StringTagParseException { final TagStringReader keyRead = new TagStringReader(new CharBuffer("testKey: \"hello\"")); assertEquals("testKey", keyRead.key()); - assertEquals(StringBinaryTag.of("hello"), keyRead.tag()); + assertEquals(StringBinaryTag.stringBinaryTag("hello"), keyRead.tag()); } @Test @@ -51,9 +51,9 @@ void testComplexStringCompound() throws IOException { .putString("quoted", "quo\"ted") .putString("comp:lex \"key", "let's go") .put("listed", ListBinaryTag.builder(BinaryTagTypes.STRING) - .add(StringBinaryTag.of("one")) - .add(StringBinaryTag.of("two")) - .add(StringBinaryTag.of("three")) + .add(StringBinaryTag.stringBinaryTag("one")) + .add(StringBinaryTag.stringBinaryTag("two")) + .add(StringBinaryTag.stringBinaryTag("three")) .build()) .build(); @@ -102,124 +102,124 @@ void testBigTestPrettyPrinting() throws IOException { @Test void testStringTag() throws IOException { - final StringBinaryTag basic = StringBinaryTag.of("hello"); + final StringBinaryTag basic = StringBinaryTag.stringBinaryTag("hello"); final String basicStr = this.tagToString(basic); assertEquals("\"hello\"", basicStr); assertEquals(basic, this.stringToTag(basicStr)); - final StringBinaryTag withEscapes = StringBinaryTag.of("hello \\world"); + final StringBinaryTag withEscapes = StringBinaryTag.stringBinaryTag("hello \\world"); final String withEscapesStr = this.tagToString(withEscapes); assertEquals("\"hello \\\\world\"", withEscapesStr); assertEquals(withEscapes, this.stringToTag(withEscapesStr)); // single quotes - assertEquals(StringBinaryTag.of("something single-quoted"), this.stringToTag("'something single-quoted'")); + assertEquals(StringBinaryTag.stringBinaryTag("something single-quoted"), this.stringToTag("'something single-quoted'")); // unquoted - assertEquals(StringBinaryTag.of("whatever"), this.stringToTag("whatever")); + assertEquals(StringBinaryTag.stringBinaryTag("whatever"), this.stringToTag("whatever")); // something vaguely like a number - assertEquals(StringBinaryTag.of("1.33.28d"), this.stringToTag("1.33.28d")); - assertEquals(StringBinaryTag.of("2147483649"), this.stringToTag("2147483649")); // larger than an int + assertEquals(StringBinaryTag.stringBinaryTag("1.33.28d"), this.stringToTag("1.33.28d")); + assertEquals(StringBinaryTag.stringBinaryTag("2147483649"), this.stringToTag("2147483649")); // larger than an int } private static final String UNICODE_TEST = "test ä ö"; @Test void testUnicodeString() throws IOException { - assertEquals("\"" + UNICODE_TEST + "\"", this.tagToString(StringBinaryTag.of(UNICODE_TEST))); - assertEquals(StringBinaryTag.of(UNICODE_TEST), this.stringToTag("\"" + UNICODE_TEST + "\"")); + assertEquals("\"" + UNICODE_TEST + "\"", this.tagToString(StringBinaryTag.stringBinaryTag(UNICODE_TEST))); + assertEquals(StringBinaryTag.stringBinaryTag(UNICODE_TEST), this.stringToTag("\"" + UNICODE_TEST + "\"")); } @Test void testByteTag() throws IOException { - assertEquals("0b", this.tagToString(ByteBinaryTag.of((byte) 0))); - assertEquals("112b", this.tagToString(ByteBinaryTag.of((byte) 112))); + assertEquals("0b", this.tagToString(ByteBinaryTag.byteBinaryTag((byte) 0))); + assertEquals("112b", this.tagToString(ByteBinaryTag.byteBinaryTag((byte) 112))); - assertEquals(ByteBinaryTag.of((byte) 12), this.stringToTag("12b")); - assertEquals(ByteBinaryTag.of((byte) 13), this.stringToTag("13B")); + assertEquals(ByteBinaryTag.byteBinaryTag((byte) 12), this.stringToTag("12b")); + assertEquals(ByteBinaryTag.byteBinaryTag((byte) 13), this.stringToTag("13B")); } @Test void testShortTag() throws IOException { - assertEquals("14883s", this.tagToString(ShortBinaryTag.of((short) 14883))); + assertEquals("14883s", this.tagToString(ShortBinaryTag.shortBinaryTag((short) 14883))); - assertEquals(ShortBinaryTag.of((short) -28), this.stringToTag("-28S")); - assertEquals(ShortBinaryTag.of((short) 2229), this.stringToTag("+2229S")); - assertEquals(StringBinaryTag.of("12.88S"), this.stringToTag("12.88S")); + assertEquals(ShortBinaryTag.shortBinaryTag((short) -28), this.stringToTag("-28S")); + assertEquals(ShortBinaryTag.shortBinaryTag((short) 2229), this.stringToTag("+2229S")); + assertEquals(StringBinaryTag.stringBinaryTag("12.88S"), this.stringToTag("12.88S")); } @Test void testIntTag() throws IOException { - assertEquals("448228", this.tagToString(IntBinaryTag.of(448228))); + assertEquals("448228", this.tagToString(IntBinaryTag.intBinaryTag(448228))); - assertEquals(IntBinaryTag.of(4482828), this.stringToTag("4482828")); - assertEquals(IntBinaryTag.of(-24), this.stringToTag("-24")); + assertEquals(IntBinaryTag.intBinaryTag(4482828), this.stringToTag("4482828")); + assertEquals(IntBinaryTag.intBinaryTag(-24), this.stringToTag("-24")); } @Test void testReadLiteralBoolean() throws IOException { - assertEquals(ByteBinaryTag.of((byte) 1), this.stringToTag("true")); - assertEquals(ByteBinaryTag.of((byte) 0), this.stringToTag("false")); + assertEquals(ByteBinaryTag.byteBinaryTag((byte) 1), this.stringToTag("true")); + assertEquals(ByteBinaryTag.byteBinaryTag((byte) 0), this.stringToTag("false")); } @Test void testLongTag() throws IOException { - assertEquals("28292849L", this.tagToString(LongBinaryTag.of(28292849L))); - assertEquals("-28292849L", this.tagToString(LongBinaryTag.of(-28292849L))); + assertEquals("28292849L", this.tagToString(LongBinaryTag.longBinaryTag(28292849L))); + assertEquals("-28292849L", this.tagToString(LongBinaryTag.longBinaryTag(-28292849L))); - assertEquals(LongBinaryTag.of(42L), this.stringToTag("42l")); - assertEquals(LongBinaryTag.of(938L), this.stringToTag("+938L")); + assertEquals(LongBinaryTag.longBinaryTag(42L), this.stringToTag("42l")); + assertEquals(LongBinaryTag.longBinaryTag(938L), this.stringToTag("+938L")); } @Test void testFloatTag() throws IOException { - assertEquals("1.204f", this.tagToString(FloatBinaryTag.of(1.204f))); + assertEquals("1.204f", this.tagToString(FloatBinaryTag.floatBinaryTag(1.204f))); - assertEquals(FloatBinaryTag.of(1.2e4f), this.stringToTag("1.2e4f")); - assertEquals(FloatBinaryTag.of(4.3e-4f), this.stringToTag("4.3e-4f")); - assertEquals(FloatBinaryTag.of(-4.3e-4f), this.stringToTag("-4.3e-4F")); - assertEquals(FloatBinaryTag.of(4.3e-4f), this.stringToTag("+4.3e-4F")); - assertEquals(FloatBinaryTag.of(0.3f), this.stringToTag(".3F")); + assertEquals(FloatBinaryTag.floatBinaryTag(1.2e4f), this.stringToTag("1.2e4f")); + assertEquals(FloatBinaryTag.floatBinaryTag(4.3e-4f), this.stringToTag("4.3e-4f")); + assertEquals(FloatBinaryTag.floatBinaryTag(-4.3e-4f), this.stringToTag("-4.3e-4F")); + assertEquals(FloatBinaryTag.floatBinaryTag(4.3e-4f), this.stringToTag("+4.3e-4F")); + assertEquals(FloatBinaryTag.floatBinaryTag(0.3f), this.stringToTag(".3F")); } @Test void testDoubleTag() throws IOException { - assertEquals("1.204d", this.tagToString(DoubleBinaryTag.of(1.204d))); + assertEquals("1.204d", this.tagToString(DoubleBinaryTag.doubleBinaryTag(1.204d))); - assertEquals(DoubleBinaryTag.of(1.2e4d), this.stringToTag("1.2e4d")); - assertEquals(DoubleBinaryTag.of(4.3e-4d), this.stringToTag("4.3e-4d")); - assertEquals(DoubleBinaryTag.of(-4.3e-4d), this.stringToTag("-4.3e-4D")); - assertEquals(DoubleBinaryTag.of(4.3e-4d), this.stringToTag("+4.3e-4D")); + assertEquals(DoubleBinaryTag.doubleBinaryTag(1.2e4d), this.stringToTag("1.2e4d")); + assertEquals(DoubleBinaryTag.doubleBinaryTag(4.3e-4d), this.stringToTag("4.3e-4d")); + assertEquals(DoubleBinaryTag.doubleBinaryTag(-4.3e-4d), this.stringToTag("-4.3e-4D")); + assertEquals(DoubleBinaryTag.doubleBinaryTag(4.3e-4d), this.stringToTag("+4.3e-4D")); } @Test void testUnsuffixedDoubleTag() throws IOException { // we can read this, but will never write it - assertEquals(DoubleBinaryTag.of(2.55e5), this.stringToTag("2.55e5")); - assertEquals(DoubleBinaryTag.of(9.0), this.stringToTag("9.")); - assertEquals(DoubleBinaryTag.of(-9.5), this.stringToTag("-9.5")); - assertEquals(DoubleBinaryTag.of(0.5), this.stringToTag(".5")); + assertEquals(DoubleBinaryTag.doubleBinaryTag(2.55e5), this.stringToTag("2.55e5")); + assertEquals(DoubleBinaryTag.doubleBinaryTag(9.0), this.stringToTag("9.")); + assertEquals(DoubleBinaryTag.doubleBinaryTag(-9.5), this.stringToTag("-9.5")); + assertEquals(DoubleBinaryTag.doubleBinaryTag(0.5), this.stringToTag(".5")); } @Test void testSpecialFloatingPointNumbers() throws IOException { - assertEquals(StringBinaryTag.of("NaNd"), this.stringToTag("NaNd")); - assertEquals(StringBinaryTag.of("NaNf"), this.stringToTag("NaNf")); - assertEquals(StringBinaryTag.of("Infinityd"), this.stringToTag("Infinityd")); - assertEquals(StringBinaryTag.of("Infinityf"), this.stringToTag("Infinityf")); + assertEquals(StringBinaryTag.stringBinaryTag("NaNd"), this.stringToTag("NaNd")); + assertEquals(StringBinaryTag.stringBinaryTag("NaNf"), this.stringToTag("NaNf")); + assertEquals(StringBinaryTag.stringBinaryTag("Infinityd"), this.stringToTag("Infinityd")); + assertEquals(StringBinaryTag.stringBinaryTag("Infinityf"), this.stringToTag("Infinityf")); } @Test void testPrematureNumericParsing() throws IOException { - assertEquals(StringBinaryTag.of("0da"), this.stringToTag("0da")); - assertEquals(StringBinaryTag.of("00000faa"), this.stringToTag("00000faa")); - assertEquals(StringBinaryTag.of("1350diamonds_plz"), this.stringToTag("1350diamonds_plz")); + assertEquals(StringBinaryTag.stringBinaryTag("0da"), this.stringToTag("0da")); + assertEquals(StringBinaryTag.stringBinaryTag("00000faa"), this.stringToTag("00000faa")); + assertEquals(StringBinaryTag.stringBinaryTag("1350diamonds_plz"), this.stringToTag("1350diamonds_plz")); } @Test void testByteArrayTag() throws IOException { - assertEquals("[B;1B,2B,3B]", this.tagToString(ByteArrayBinaryTag.of((byte) 1, (byte) 2, (byte) 3))); - assertEquals(ByteArrayBinaryTag.of((byte) 1, (byte) 1, (byte) 2, (byte) 3, (byte) 5, (byte) 8), this.stringToTag("[B; 1b, 1b, 2b, 3b, 5b, 8b]")); + assertEquals("[B;1B,2B,3B]", this.tagToString(ByteArrayBinaryTag.byteArrayBinaryTag((byte) 1, (byte) 2, (byte) 3))); + assertEquals(ByteArrayBinaryTag.byteArrayBinaryTag((byte) 1, (byte) 1, (byte) 2, (byte) 3, (byte) 5, (byte) 8), this.stringToTag("[B; 1b, 1b, 2b, 3b, 5b, 8b]")); } @Test @@ -234,8 +234,8 @@ void testLegacyListTag() throws IOException { assertEquals(legacyInput, output.toString()); final ListTagBuilder builder = new ListTagBuilder<>(); - builder.add(StringBinaryTag.of("Tag #1")); - builder.add(StringBinaryTag.of("Tag #2")); + builder.add(StringBinaryTag.stringBinaryTag("Tag #1")); + builder.add(StringBinaryTag.stringBinaryTag("Tag #2")); assertEquals(builder.build(), tag); } @@ -249,14 +249,14 @@ void testReadsLegacyCompoundKey() throws IOException { @Test void testIntArrayTag() throws IOException { - assertEquals("[I;1,2,3]", this.tagToString(IntArrayBinaryTag.of(1, 2, 3))); - assertEquals(IntArrayBinaryTag.of(2, 4, 6, 8, 10, 12), this.stringToTag("[I; 2, 4, 6, 8, 10, 12]")); + assertEquals("[I;1,2,3]", this.tagToString(IntArrayBinaryTag.intArrayBinaryTag(1, 2, 3))); + assertEquals(IntArrayBinaryTag.intArrayBinaryTag(2, 4, 6, 8, 10, 12), this.stringToTag("[I; 2, 4, 6, 8, 10, 12]")); } @Test void testLongArrayTag() throws IOException { - assertEquals("[L;1l,2l,3l]", this.tagToString(LongArrayBinaryTag.of(1, 2, 3))); - assertEquals(LongArrayBinaryTag.of(2, 4, 6, -8, 10, 12), this.stringToTag("[L; 2l, 4l, 6l, -8l, 10l, 12l]")); + assertEquals("[L;1l,2l,3l]", this.tagToString(LongArrayBinaryTag.longArrayBinaryTag(1, 2, 3))); + assertEquals(LongArrayBinaryTag.longArrayBinaryTag(2, 4, 6, -8, 10, 12), this.stringToTag("[L; 2l, 4l, 6l, -8l, 10l, 12l]")); } @Test @@ -274,30 +274,30 @@ void testEmptyListTag() throws IOException { @Test void testEmptyByteArray() throws IOException { - assertEquals("[B;]", this.tagToString(ByteArrayBinaryTag.of())); - assertEquals(ByteArrayBinaryTag.of(), this.stringToTag("[B;]")); - assertEquals(ByteArrayBinaryTag.of(), this.stringToTag("[B; ]")); + assertEquals("[B;]", this.tagToString(ByteArrayBinaryTag.byteArrayBinaryTag())); + assertEquals(ByteArrayBinaryTag.byteArrayBinaryTag(), this.stringToTag("[B;]")); + assertEquals(ByteArrayBinaryTag.byteArrayBinaryTag(), this.stringToTag("[B; ]")); } @Test void testEmptyIntArray() throws IOException { - assertEquals("[I;]", this.tagToString(IntArrayBinaryTag.of())); - assertEquals(IntArrayBinaryTag.of(), this.stringToTag("[I;]")); - assertEquals(IntArrayBinaryTag.of(), this.stringToTag("[I; ]")); + assertEquals("[I;]", this.tagToString(IntArrayBinaryTag.intArrayBinaryTag())); + assertEquals(IntArrayBinaryTag.intArrayBinaryTag(), this.stringToTag("[I;]")); + assertEquals(IntArrayBinaryTag.intArrayBinaryTag(), this.stringToTag("[I; ]")); } @Test void testEmptyLongArray() throws IOException { - assertEquals("[L;]", this.tagToString(LongArrayBinaryTag.of())); - assertEquals(LongArrayBinaryTag.of(), this.stringToTag("[L;]")); - assertEquals(LongArrayBinaryTag.of(), this.stringToTag("[L; ]")); + assertEquals("[L;]", this.tagToString(LongArrayBinaryTag.longArrayBinaryTag())); + assertEquals(LongArrayBinaryTag.longArrayBinaryTag(), this.stringToTag("[L;]")); + assertEquals(LongArrayBinaryTag.longArrayBinaryTag(), this.stringToTag("[L; ]")); } @Test void testTrailingComma() throws IOException { assertEquals(CompoundBinaryTag.builder().putString("test", "hello").build(), this.stringToTag("{test: \"hello\",}")); - assertEquals(IntArrayBinaryTag.of(1), this.stringToTag("[I;1,]")); - assertEquals(ListBinaryTag.builder().add(StringBinaryTag.of("hello")).build(), this.stringToTag("[\"hello\",]")); + assertEquals(IntArrayBinaryTag.intArrayBinaryTag(1), this.stringToTag("[I;1,]")); + assertEquals(ListBinaryTag.builder().add(StringBinaryTag.stringBinaryTag("hello")).build(), this.stringToTag("[\"hello\",]")); } private String tagToString(final BinaryTag tag) throws IOException { diff --git a/text-serializer-gson/src/main/java/net/kyori/adventure/text/serializer/gson/ShowEntitySerializer.java b/text-serializer-gson/src/main/java/net/kyori/adventure/text/serializer/gson/ShowEntitySerializer.java index e71677507..b8947beaa 100644 --- a/text-serializer-gson/src/main/java/net/kyori/adventure/text/serializer/gson/ShowEntitySerializer.java +++ b/text-serializer-gson/src/main/java/net/kyori/adventure/text/serializer/gson/ShowEntitySerializer.java @@ -76,7 +76,7 @@ public HoverEvent.ShowEntity read(final JsonReader in) throws IOException { } in.endObject(); - return HoverEvent.ShowEntity.of(type, id, name); + return HoverEvent.ShowEntity.showEntity(type, id, name); } @Override diff --git a/text-serializer-gson/src/main/java/net/kyori/adventure/text/serializer/gson/ShowItemSerializer.java b/text-serializer-gson/src/main/java/net/kyori/adventure/text/serializer/gson/ShowItemSerializer.java index d5ba08b55..f243c063a 100644 --- a/text-serializer-gson/src/main/java/net/kyori/adventure/text/serializer/gson/ShowItemSerializer.java +++ b/text-serializer-gson/src/main/java/net/kyori/adventure/text/serializer/gson/ShowItemSerializer.java @@ -85,7 +85,7 @@ public HoverEvent.ShowItem read(final JsonReader in) throws IOException { } in.endObject(); - return HoverEvent.ShowItem.of(key, count, nbt); + return HoverEvent.ShowItem.showItem(key, count, nbt); } @Override diff --git a/text-serializer-gson/src/test/java/net/kyori/adventure/text/serializer/gson/ShowItemSerializerTest.java b/text-serializer-gson/src/test/java/net/kyori/adventure/text/serializer/gson/ShowItemSerializerTest.java index 0cfaed63c..9a67fefc5 100644 --- a/text-serializer-gson/src/test/java/net/kyori/adventure/text/serializer/gson/ShowItemSerializerTest.java +++ b/text-serializer-gson/src/test/java/net/kyori/adventure/text/serializer/gson/ShowItemSerializerTest.java @@ -39,10 +39,10 @@ class ShowItemSerializerTest { @Test void testDeserializeWithPopulatedTag() throws IOException { assertEquals( - HoverEvent.ShowItem.of(Key.key("minecraft", "diamond"), 1, BinaryTagHolder.binaryTagHolder(TagStringIO.get().asString( + HoverEvent.ShowItem.showItem(Key.key("minecraft", "diamond"), 1, BinaryTagHolder.binaryTagHolder(TagStringIO.get().asString( CompoundBinaryTag.builder() .put("display", CompoundBinaryTag.builder() - .put("Name", StringBinaryTag.of("A test!")) + .put("Name", StringBinaryTag.stringBinaryTag("A test!")) .build()) .build() ))), @@ -60,7 +60,7 @@ void testDeserializeWithPopulatedTag() throws IOException { @Test void testDeserializeWithNullTag() { assertEquals( - HoverEvent.ShowItem.of(Key.key("minecraft", "diamond"), 1, null), + HoverEvent.ShowItem.showItem(Key.key("minecraft", "diamond"), 1, null), GsonComponentSerializer.gson().serializer().fromJson( GsonTest.object(json -> { json.addProperty(ShowItemSerializer.ID, "minecraft:diamond"); diff --git a/text-serializer-gson/src/test/java/net/kyori/adventure/text/serializer/gson/StyleTest.java b/text-serializer-gson/src/test/java/net/kyori/adventure/text/serializer/gson/StyleTest.java index 62335dcd8..1cbb42374 100644 --- a/text-serializer-gson/src/test/java/net/kyori/adventure/text/serializer/gson/StyleTest.java +++ b/text-serializer-gson/src/test/java/net/kyori/adventure/text/serializer/gson/StyleTest.java @@ -145,7 +145,7 @@ void testShowEntityHoverEvent() { final UUID dolores = UUID.randomUUID(); this.test( Style.style() - .hoverEvent(HoverEvent.showEntity(HoverEvent.ShowEntity.of( + .hoverEvent(HoverEvent.showEntity(HoverEvent.ShowEntity.showEntity( Key.key(Key.MINECRAFT_NAMESPACE, "pig"), dolores, Component.text("Dolores", TextColor.color(0x0a1ab9)) @@ -175,7 +175,7 @@ void testShowItemHoverEvent() { private static Style showItemStyle(final int count) { return Style.style() - .hoverEvent(HoverEvent.showItem(HoverEvent.ShowItem.of( + .hoverEvent(HoverEvent.showItem(HoverEvent.ShowItem.showItem( Key.key(Key.MINECRAFT_NAMESPACE, "stone"), count, null // TODO: test for NBT? From ac6a367012fef46228e61128a2bd39241363d1cb Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Fri, 12 May 2023 13:06:24 +0200 Subject: [PATCH 8/8] fix last deprecated method --- .../text/serializer/gson/TranslatableComponentTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text-serializer-gson/src/test/java/net/kyori/adventure/text/serializer/gson/TranslatableComponentTest.java b/text-serializer-gson/src/test/java/net/kyori/adventure/text/serializer/gson/TranslatableComponentTest.java index 089087e6d..5f850bee4 100644 --- a/text-serializer-gson/src/test/java/net/kyori/adventure/text/serializer/gson/TranslatableComponentTest.java +++ b/text-serializer-gson/src/test/java/net/kyori/adventure/text/serializer/gson/TranslatableComponentTest.java @@ -66,7 +66,7 @@ void testSingleArgWithEvents() { KEY, Component.text().content(name) .clickEvent(ClickEvent.suggestCommand(command)) - .hoverEvent(HoverEvent.showEntity(HoverEvent.ShowEntity.of( + .hoverEvent(HoverEvent.showEntity(HoverEvent.ShowEntity.showEntity( Key.key("minecraft", "player"), id, Component.text(name)