From 0abd8d14880abde03f03aea4dcb67063414942af Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Sat, 29 Jan 2022 20:40:32 +0100 Subject: [PATCH 1/5] nadventure --- helper/pom.xml | 49 ++++++++ .../java/me/lucko/helper/adventure/Text.java | 105 ++++++++++++++++++ .../helper/bossbar/BukkitBossBarFactory.java | 2 +- .../helper/bossbar/ViaBossBarFactory.java | 2 +- .../command/CommandInterruptException.java | 2 +- .../me/lucko/helper/config/ConfigFactory.java | 7 +- .../AdventureTypeSerializer.java | 56 ++++++++++ .../ColoredStringTypeSerializer.java | 2 +- .../typeserializers/Text3TypeSerializer.java | 1 + .../me/lucko/helper/gson/GsonProvider.java | 21 ++-- .../hologram/BukkitHologramFactory.java | 2 +- .../PacketIndividualHologramFactory.java | 2 +- .../me/lucko/helper/internal/LoaderUtils.java | 10 ++ .../lucko/helper/item/ItemStackBuilder.java | 2 +- .../main/java/me/lucko/helper/menu/Gui.java | 2 +- .../redirect/AbstractRedirectSystem.java | 2 +- .../helper/scoreboard/PacketScoreboard.java | 33 +++--- .../scoreboard/PacketScoreboardObjective.java | 2 +- .../scoreboard/PacketScoreboardTeam.java | 2 +- .../main/java/me/lucko/helper/text3/Text.java | 3 + .../me/lucko/helper/text3/package-info.java | 2 + .../java/me/lucko/helper/utils/Players.java | 2 +- 22 files changed, 269 insertions(+), 42 deletions(-) create mode 100644 helper/src/main/java/me/lucko/helper/adventure/Text.java create mode 100644 helper/src/main/java/me/lucko/helper/config/typeserializers/AdventureTypeSerializer.java create mode 100644 helper/src/main/java/me/lucko/helper/text3/package-info.java diff --git a/helper/pom.xml b/helper/pom.xml index 8404913e..c12a8eba 100644 --- a/helper/pom.xml +++ b/helper/pom.xml @@ -89,6 +89,12 @@ net.kyori:text-serializer-legacy net.kyori:text-feature-pagination me.lucko:textlegacy + net.kyori:adventure-api + net.kyori:adventure-text-serializer-gson + net.kyori:adventure-text-serializer-legacy + net.kyori:adventure-platform-bukkit + net.kyori:examination + org.spongepowered:configurate-core org.spongepowered:configurate-core org.spongepowered:configurate-yaml org.spongepowered:configurate-gson @@ -110,6 +116,14 @@ net.kyori.text me.lucko.helper.text3 + net.kyori.event me.lucko.helper.eventbus @@ -291,6 +305,41 @@ compile true + + + net.kyori + adventure-api + 4.9.3 + compile + true + + + org.checkerframework + checker-qual + + + + + net.kyori + adventure-text-serializer-gson + 4.9.3 + compile + true + + + net.kyori + adventure-text-serializer-legacy + 4.9.3 + compile + true + + + net.kyori + adventure-platform-bukkit + 4.0.1 + compile + true + net.kyori diff --git a/helper/src/main/java/me/lucko/helper/adventure/Text.java b/helper/src/main/java/me/lucko/helper/adventure/Text.java new file mode 100644 index 00000000..0923e42b --- /dev/null +++ b/helper/src/main/java/me/lucko/helper/adventure/Text.java @@ -0,0 +1,105 @@ +/* + * This file is part of helper, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.helper.adventure; + +import java.util.Arrays; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.bukkit.command.CommandSender; + +import me.lucko.helper.internal.LoaderUtils; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; + +/** + * Utilities for working with {@link Component}s and formatted text strings. + * @since 5.7.0 + */ +public class Text { + public static final char SECTION_CHAR = '\u00A7'; // § + public static final char AMPERSAND_CHAR = '&'; + + + public static String joinNewline(String... strings) { + return joinNewline(Arrays.stream(strings)); + } + + public static String joinNewline(Stream strings) { + return strings.collect(Collectors.joining("\n")); + } + + public static Component fromLegacy(String input, char character) { + return LegacyComponentSerializer.legacy(character).deserialize(input); + } + + public static Component fromLegacy(String input) { + return LegacyComponentSerializer.legacy(SECTION_CHAR).deserialize(input); + } + + public static String toLegacy(Component component, char character) { + return LegacyComponentSerializer.legacy(character).serialize(component); + } + + public static String toLegacy(Component component) { + return LegacyComponentSerializer.legacy(SECTION_CHAR).serialize(component); + } + + public static void sendMessage(CommandSender sender, Component message) { + LoaderUtils.getAdventure().sender(sender).sendMessage(message); + } + + public static void sendMessage(Iterable senders, Component message) { + for (CommandSender sender : senders) { + sendMessage(sender, message); + } + } + + public static String colorize(String s) { + return s == null ? null : translateAlternateColorCodes(AMPERSAND_CHAR, SECTION_CHAR, s); + } + + public static String decolorize(String s) { + return s == null ? null : translateAlternateColorCodes(SECTION_CHAR, AMPERSAND_CHAR, s); + } + + public static String translateAlternateColorCodes(char from, char to, String textToTranslate) { + char[] b = textToTranslate.toCharArray(); + for (int i = 0; i < b.length - 1; i++) { + if (b[i] == from && "0123456789AaBbCcDdEeFfKkLlMmNnOoRrXx".indexOf(b[i+1]) > -1) { + b[i] = to; + b[i+1] = Character.toLowerCase(b[i+1]); + } + } + return new String(b); + } + + private Text() { + throw new UnsupportedOperationException("This class cannot be instantiated"); + } + +} \ No newline at end of file diff --git a/helper/src/main/java/me/lucko/helper/bossbar/BukkitBossBarFactory.java b/helper/src/main/java/me/lucko/helper/bossbar/BukkitBossBarFactory.java index d9767b67..e0769d7d 100644 --- a/helper/src/main/java/me/lucko/helper/bossbar/BukkitBossBarFactory.java +++ b/helper/src/main/java/me/lucko/helper/bossbar/BukkitBossBarFactory.java @@ -25,7 +25,7 @@ package me.lucko.helper.bossbar; -import me.lucko.helper.text.Text; +import me.lucko.helper.adventure.Text; import org.bukkit.Server; import org.bukkit.boss.BarColor; diff --git a/helper/src/main/java/me/lucko/helper/bossbar/ViaBossBarFactory.java b/helper/src/main/java/me/lucko/helper/bossbar/ViaBossBarFactory.java index af2f6cd3..a36a17f9 100644 --- a/helper/src/main/java/me/lucko/helper/bossbar/ViaBossBarFactory.java +++ b/helper/src/main/java/me/lucko/helper/bossbar/ViaBossBarFactory.java @@ -25,7 +25,7 @@ package me.lucko.helper.bossbar; -import me.lucko.helper.text.Text; +import me.lucko.helper.adventure.Text; import me.lucko.helper.utils.ImmutableCollectors; import me.lucko.helper.utils.Players; diff --git a/helper/src/main/java/me/lucko/helper/command/CommandInterruptException.java b/helper/src/main/java/me/lucko/helper/command/CommandInterruptException.java index 96430f8e..0bee3026 100644 --- a/helper/src/main/java/me/lucko/helper/command/CommandInterruptException.java +++ b/helper/src/main/java/me/lucko/helper/command/CommandInterruptException.java @@ -25,7 +25,7 @@ package me.lucko.helper.command; -import me.lucko.helper.text.Text; +import me.lucko.helper.adventure.Text; import org.bukkit.command.CommandSender; diff --git a/helper/src/main/java/me/lucko/helper/config/ConfigFactory.java b/helper/src/main/java/me/lucko/helper/config/ConfigFactory.java index 15ba9f4b..d8eb0cfb 100644 --- a/helper/src/main/java/me/lucko/helper/config/ConfigFactory.java +++ b/helper/src/main/java/me/lucko/helper/config/ConfigFactory.java @@ -35,10 +35,11 @@ import me.lucko.helper.config.typeserializers.JsonTreeTypeSerializer; import me.lucko.helper.config.typeserializers.Text3TypeSerializer; import me.lucko.helper.config.typeserializers.TextTypeSerializer; +import me.lucko.helper.config.typeserializers.AdventureTypeSerializer; import me.lucko.helper.datatree.DataTree; import me.lucko.helper.gson.GsonSerializable; -import net.kyori.text.Component; +import net.kyori.adventure.text.Component; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.yaml.snakeyaml.DumperOptions; @@ -118,8 +119,8 @@ public HoconConfigurationLoader loader(@Nonnull Path path) { helperSerializers.register(TypeToken.of(DataTree.class), JsonTreeTypeSerializer.INSTANCE); helperSerializers.register(TypeToken.of(String.class), ColoredStringTypeSerializer.INSTANCE); helperSerializers.register(TypeToken.of(me.lucko.helper.text.Component.class), TextTypeSerializer.INSTANCE); - helperSerializers.register(TypeToken.of(Component.class), Text3TypeSerializer.INSTANCE); - + helperSerializers.register(TypeToken.of(net.kyori.text.Component.class), Text3TypeSerializer.INSTANCE); + helperSerializers.register(TypeToken.of(Component.class), AdventureTypeSerializer.INSTANCE); TYPE_SERIALIZERS = helperSerializers.newChild(); } diff --git a/helper/src/main/java/me/lucko/helper/config/typeserializers/AdventureTypeSerializer.java b/helper/src/main/java/me/lucko/helper/config/typeserializers/AdventureTypeSerializer.java new file mode 100644 index 00000000..7998c730 --- /dev/null +++ b/helper/src/main/java/me/lucko/helper/config/typeserializers/AdventureTypeSerializer.java @@ -0,0 +1,56 @@ +/* + * This file is part of helper, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.helper.config.typeserializers; + +import com.google.common.reflect.TypeToken; +import com.google.gson.JsonElement; + +import me.lucko.helper.gson.GsonProvider; + +import net.kyori.adventure.text.Component; + +import ninja.leaping.configurate.ConfigurationNode; +import ninja.leaping.configurate.objectmapping.ObjectMappingException; +import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; + +public class AdventureTypeSerializer implements TypeSerializer { + public static final AdventureTypeSerializer INSTANCE = new AdventureTypeSerializer(); + + private AdventureTypeSerializer() { + } + + @Override + public Component deserialize(TypeToken typeToken, ConfigurationNode node) throws ObjectMappingException { + JsonElement json = node.getValue(TypeToken.of(JsonElement.class)); + return GsonProvider.standard().fromJson(json, typeToken.getType()); + } + + @Override + public void serialize(TypeToken typeToken, Component component, ConfigurationNode node) throws ObjectMappingException { + JsonElement element = GsonProvider.standard().toJsonTree(component, typeToken.getType()); + node.setValue(TypeToken.of(JsonElement.class), element); + } +} \ No newline at end of file diff --git a/helper/src/main/java/me/lucko/helper/config/typeserializers/ColoredStringTypeSerializer.java b/helper/src/main/java/me/lucko/helper/config/typeserializers/ColoredStringTypeSerializer.java index bf01976d..9af14428 100644 --- a/helper/src/main/java/me/lucko/helper/config/typeserializers/ColoredStringTypeSerializer.java +++ b/helper/src/main/java/me/lucko/helper/config/typeserializers/ColoredStringTypeSerializer.java @@ -27,7 +27,7 @@ import com.google.common.reflect.TypeToken; -import me.lucko.helper.text.Text; +import me.lucko.helper.adventure.Text; import ninja.leaping.configurate.ConfigurationNode; import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; diff --git a/helper/src/main/java/me/lucko/helper/config/typeserializers/Text3TypeSerializer.java b/helper/src/main/java/me/lucko/helper/config/typeserializers/Text3TypeSerializer.java index 77ee8094..07e80003 100644 --- a/helper/src/main/java/me/lucko/helper/config/typeserializers/Text3TypeSerializer.java +++ b/helper/src/main/java/me/lucko/helper/config/typeserializers/Text3TypeSerializer.java @@ -36,6 +36,7 @@ import ninja.leaping.configurate.objectmapping.ObjectMappingException; import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; +@Deprecated public class Text3TypeSerializer implements TypeSerializer { public static final Text3TypeSerializer INSTANCE = new Text3TypeSerializer(); diff --git a/helper/src/main/java/me/lucko/helper/gson/GsonProvider.java b/helper/src/main/java/me/lucko/helper/gson/GsonProvider.java index 33437ca1..bb2f0432 100644 --- a/helper/src/main/java/me/lucko/helper/gson/GsonProvider.java +++ b/helper/src/main/java/me/lucko/helper/gson/GsonProvider.java @@ -25,6 +25,11 @@ package me.lucko.helper.gson; +import java.io.Reader; +import java.util.Objects; + +import javax.annotation.Nonnull; + import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; @@ -35,20 +40,15 @@ import me.lucko.helper.gson.typeadapters.BukkitSerializableAdapterFactory; import me.lucko.helper.gson.typeadapters.GsonSerializableAdapterFactory; import me.lucko.helper.gson.typeadapters.JsonElementTreeSerializer; - -import net.kyori.text.serializer.gson.GsonComponentSerializer; - -import java.io.Reader; -import java.util.Objects; - -import javax.annotation.Nonnull; +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; /** * Provides static instances of Gson */ public final class GsonProvider { - private static final Gson STANDARD_GSON = GsonComponentSerializer.populate(new GsonBuilder()) + private static final Gson STANDARD_GSON = GsonComponentSerializer.gson().populator() + .apply(new GsonBuilder()) .registerTypeHierarchyAdapter(DataTree.class, JsonElementTreeSerializer.INSTANCE) .registerTypeAdapterFactory(GsonSerializableAdapterFactory.INSTANCE) .registerTypeAdapterFactory(BukkitSerializableAdapterFactory.INSTANCE) @@ -56,7 +56,8 @@ public final class GsonProvider { .disableHtmlEscaping() .create(); - private static final Gson PRETTY_PRINT_GSON = GsonComponentSerializer.populate(new GsonBuilder()) + private static final Gson PRETTY_PRINT_GSON = GsonComponentSerializer.gson().populator() + .apply(new GsonBuilder()) .registerTypeHierarchyAdapter(DataTree.class, JsonElementTreeSerializer.INSTANCE) .registerTypeAdapterFactory(GsonSerializableAdapterFactory.INSTANCE) .registerTypeAdapterFactory(BukkitSerializableAdapterFactory.INSTANCE) @@ -134,4 +135,4 @@ public static Gson getPrettyPrinting() { return prettyPrinting(); } -} +} \ No newline at end of file diff --git a/helper/src/main/java/me/lucko/helper/hologram/BukkitHologramFactory.java b/helper/src/main/java/me/lucko/helper/hologram/BukkitHologramFactory.java index 5a167097..e8819f82 100644 --- a/helper/src/main/java/me/lucko/helper/hologram/BukkitHologramFactory.java +++ b/helper/src/main/java/me/lucko/helper/hologram/BukkitHologramFactory.java @@ -36,7 +36,7 @@ import me.lucko.helper.serialize.Position; import me.lucko.helper.terminable.composite.CompositeTerminable; -import me.lucko.helper.text3.Text; +import me.lucko.helper.adventure.Text; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.entity.ArmorStand; diff --git a/helper/src/main/java/me/lucko/helper/hologram/individual/PacketIndividualHologramFactory.java b/helper/src/main/java/me/lucko/helper/hologram/individual/PacketIndividualHologramFactory.java index 3c439cda..90c8d035 100644 --- a/helper/src/main/java/me/lucko/helper/hologram/individual/PacketIndividualHologramFactory.java +++ b/helper/src/main/java/me/lucko/helper/hologram/individual/PacketIndividualHologramFactory.java @@ -40,7 +40,7 @@ import me.lucko.helper.reflect.ServerReflection; import me.lucko.helper.serialize.Position; import me.lucko.helper.terminable.composite.CompositeTerminable; -import me.lucko.helper.text3.Text; +import me.lucko.helper.adventure.Text; import me.lucko.helper.utils.entityspawner.EntitySpawner; import org.bukkit.Chunk; diff --git a/helper/src/main/java/me/lucko/helper/internal/LoaderUtils.java b/helper/src/main/java/me/lucko/helper/internal/LoaderUtils.java index e9fca615..84289636 100644 --- a/helper/src/main/java/me/lucko/helper/internal/LoaderUtils.java +++ b/helper/src/main/java/me/lucko/helper/internal/LoaderUtils.java @@ -27,6 +27,7 @@ import me.lucko.helper.Helper; import me.lucko.helper.plugin.HelperPlugin; +import net.kyori.adventure.platform.bukkit.BukkitAudiences; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; @@ -45,6 +46,7 @@ public final class LoaderUtils { private static HelperPlugin plugin = null; private static Thread mainThread = null; + private static BukkitAudiences adventure = null; @Nonnull public static synchronized HelperPlugin getPlugin() { @@ -100,6 +102,14 @@ public static synchronized Thread getMainThread() { return mainThread; } + public static synchronized BukkitAudiences getAdventure() { + if (adventure == null) { + adventure = BukkitAudiences.create(getPlugin()); + } + + return adventure; + } + // performs an intial setup for global handlers private static void setup() { diff --git a/helper/src/main/java/me/lucko/helper/item/ItemStackBuilder.java b/helper/src/main/java/me/lucko/helper/item/ItemStackBuilder.java index e96a67cd..c4112b94 100644 --- a/helper/src/main/java/me/lucko/helper/item/ItemStackBuilder.java +++ b/helper/src/main/java/me/lucko/helper/item/ItemStackBuilder.java @@ -26,7 +26,7 @@ package me.lucko.helper.item; import me.lucko.helper.menu.Item; -import me.lucko.helper.text.Text; +import me.lucko.helper.adventure.Text; import me.lucko.helper.utils.annotation.NonnullByDefault; import org.bukkit.ChatColor; diff --git a/helper/src/main/java/me/lucko/helper/menu/Gui.java b/helper/src/main/java/me/lucko/helper/menu/Gui.java index dfeab301..31392290 100644 --- a/helper/src/main/java/me/lucko/helper/menu/Gui.java +++ b/helper/src/main/java/me/lucko/helper/menu/Gui.java @@ -35,7 +35,7 @@ import me.lucko.helper.reflect.MinecraftVersions; import me.lucko.helper.terminable.TerminableConsumer; import me.lucko.helper.terminable.composite.CompositeTerminable; -import me.lucko.helper.text.Text; +import me.lucko.helper.adventure.Text; import me.lucko.helper.utils.annotation.NonnullByDefault; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/helper/src/main/java/me/lucko/helper/network/redirect/AbstractRedirectSystem.java b/helper/src/main/java/me/lucko/helper/network/redirect/AbstractRedirectSystem.java index 6013c2bc..75707022 100644 --- a/helper/src/main/java/me/lucko/helper/network/redirect/AbstractRedirectSystem.java +++ b/helper/src/main/java/me/lucko/helper/network/redirect/AbstractRedirectSystem.java @@ -38,7 +38,7 @@ import me.lucko.helper.messaging.conversation.ConversationReplyListener; import me.lucko.helper.profiles.Profile; import me.lucko.helper.promise.Promise; -import me.lucko.helper.text3.Text; +import me.lucko.helper.adventure.Text; import net.jodah.expiringmap.ExpirationPolicy; import net.jodah.expiringmap.ExpiringMap; diff --git a/helper/src/main/java/me/lucko/helper/scoreboard/PacketScoreboard.java b/helper/src/main/java/me/lucko/helper/scoreboard/PacketScoreboard.java index 5ec8c27c..86579af7 100644 --- a/helper/src/main/java/me/lucko/helper/scoreboard/PacketScoreboard.java +++ b/helper/src/main/java/me/lucko/helper/scoreboard/PacketScoreboard.java @@ -25,29 +25,28 @@ package me.lucko.helper.scoreboard; -import com.comphenix.protocol.wrappers.WrappedChatComponent; -import com.google.common.base.Preconditions; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; -import me.lucko.helper.Events; -import me.lucko.helper.plugin.HelperPlugin; -import me.lucko.helper.text3.Text; -import me.lucko.helper.utils.Players; -import me.lucko.helper.utils.annotation.NonnullByDefault; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -import net.kyori.text.serializer.gson.GsonComponentSerializer; +import com.comphenix.protocol.wrappers.WrappedChatComponent; +import com.google.common.base.Preconditions; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.scoreboard.DisplaySlot; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import me.lucko.helper.Events; +import me.lucko.helper.adventure.Text; +import me.lucko.helper.plugin.HelperPlugin; +import me.lucko.helper.utils.Players; +import me.lucko.helper.utils.annotation.NonnullByDefault; +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; /** * Implements {@link Scoreboard} using ProtocolLib. @@ -263,7 +262,7 @@ public boolean removePlayerObjective(Player player, String id) { } static WrappedChatComponent toComponent(String text) { - return WrappedChatComponent.fromJson(GsonComponentSerializer.INSTANCE.serialize(Text.fromLegacy(text))); + return WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(Text.fromLegacy(text))); } -} +} \ No newline at end of file diff --git a/helper/src/main/java/me/lucko/helper/scoreboard/PacketScoreboardObjective.java b/helper/src/main/java/me/lucko/helper/scoreboard/PacketScoreboardObjective.java index 9bb6b3a5..584690fd 100644 --- a/helper/src/main/java/me/lucko/helper/scoreboard/PacketScoreboardObjective.java +++ b/helper/src/main/java/me/lucko/helper/scoreboard/PacketScoreboardObjective.java @@ -34,7 +34,7 @@ import me.lucko.helper.protocol.Protocol; import me.lucko.helper.reflect.MinecraftVersion; import me.lucko.helper.reflect.MinecraftVersions; -import me.lucko.helper.text.Text; +import me.lucko.helper.adventure.Text; import me.lucko.helper.utils.annotation.NonnullByDefault; import org.bukkit.entity.Player; diff --git a/helper/src/main/java/me/lucko/helper/scoreboard/PacketScoreboardTeam.java b/helper/src/main/java/me/lucko/helper/scoreboard/PacketScoreboardTeam.java index 86902afd..0e975208 100644 --- a/helper/src/main/java/me/lucko/helper/scoreboard/PacketScoreboardTeam.java +++ b/helper/src/main/java/me/lucko/helper/scoreboard/PacketScoreboardTeam.java @@ -36,7 +36,7 @@ import me.lucko.helper.protocol.Protocol; import me.lucko.helper.reflect.MinecraftVersion; import me.lucko.helper.reflect.MinecraftVersions; -import me.lucko.helper.text.Text; +import me.lucko.helper.adventure.Text; import me.lucko.helper.utils.annotation.NonnullByDefault; import me.lucko.shadow.bukkit.PackageVersion; diff --git a/helper/src/main/java/me/lucko/helper/text3/Text.java b/helper/src/main/java/me/lucko/helper/text3/Text.java index 26b1fa98..f383cb66 100644 --- a/helper/src/main/java/me/lucko/helper/text3/Text.java +++ b/helper/src/main/java/me/lucko/helper/text3/Text.java @@ -38,7 +38,10 @@ /** * Utilities for working with {@link Component}s and formatted text strings. + * + * @deprecated Use {@link me.lucko.helper.text3.Text} */ +@Deprecated public final class Text { public static final char SECTION_CHAR = '\u00A7'; // § diff --git a/helper/src/main/java/me/lucko/helper/text3/package-info.java b/helper/src/main/java/me/lucko/helper/text3/package-info.java new file mode 100644 index 00000000..1b330872 --- /dev/null +++ b/helper/src/main/java/me/lucko/helper/text3/package-info.java @@ -0,0 +1,2 @@ +@Deprecated +package me.lucko.helper.text3; diff --git a/helper/src/main/java/me/lucko/helper/utils/Players.java b/helper/src/main/java/me/lucko/helper/utils/Players.java index 186f0e69..43f3ca14 100644 --- a/helper/src/main/java/me/lucko/helper/utils/Players.java +++ b/helper/src/main/java/me/lucko/helper/utils/Players.java @@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableList; import me.lucko.helper.Helper; -import me.lucko.helper.text.Text; +import me.lucko.helper.adventure.Text; import me.lucko.helper.utils.annotation.NonnullByDefault; import org.bukkit.Bukkit; From eba7de688e70944126f7cc4691140a75e6dc1058 Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Sat, 29 Jan 2022 22:04:04 +0100 Subject: [PATCH 2/5] remove double include Signed-off-by: powercas_gamer --- helper/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/helper/pom.xml b/helper/pom.xml index c12a8eba..6bc8586d 100644 --- a/helper/pom.xml +++ b/helper/pom.xml @@ -95,7 +95,6 @@ net.kyori:adventure-platform-bukkit net.kyori:examination org.spongepowered:configurate-core - org.spongepowered:configurate-core org.spongepowered:configurate-yaml org.spongepowered:configurate-gson org.spongepowered:configurate-hocon From f1f241ff5f444f016718f241977f46643ca87e8a Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Tue, 15 Mar 2022 17:09:19 +0100 Subject: [PATCH 3/5] update adventure Signed-off-by: powercas_gamer --- helper/pom.xml | 6 +++--- pom.xml | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/helper/pom.xml b/helper/pom.xml index 6bc8586d..da5c7718 100644 --- a/helper/pom.xml +++ b/helper/pom.xml @@ -308,7 +308,7 @@ net.kyori adventure-api - 4.9.3 + ${adventure.version} compile true @@ -321,14 +321,14 @@ net.kyori adventure-text-serializer-gson - 4.9.3 + ${adventure.version} compile true net.kyori adventure-text-serializer-legacy - 4.9.3 + ${adventure.version} compile true diff --git a/pom.xml b/pom.xml index 84a0848c..ebe34e4f 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,7 @@ 3.2.1 3.3.2 + 4.10.1 1.12.2-R0.1-SNAPSHOT From 95cd08f9b69f3ed4c704b5f018bbf09739382d1c Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Sat, 24 Jun 2023 01:09:00 +0200 Subject: [PATCH 4/5] update to 4.14.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ebe34e4f..31e3c84f 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ 3.2.1 3.3.2 - 4.10.1 + 4.14.0 1.12.2-R0.1-SNAPSHOT From dd242beb7dc546e2c3167128ac644e565353d383 Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Sat, 24 Jun 2023 01:30:49 +0200 Subject: [PATCH 5/5] rebase fix --- helper/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/pom.xml b/helper/pom.xml index da5c7718..0d904bc9 100644 --- a/helper/pom.xml +++ b/helper/pom.xml @@ -335,7 +335,7 @@ net.kyori adventure-platform-bukkit - 4.0.1 + 4. compile true