diff --git a/src/main/java/net/minestom/server/bossbar/BarColor.java b/src/main/java/net/minestom/server/bossbar/BarColor.java index 9173782ea..0467e4235 100644 --- a/src/main/java/net/minestom/server/bossbar/BarColor.java +++ b/src/main/java/net/minestom/server/bossbar/BarColor.java @@ -2,7 +2,7 @@ package net.minestom.server.bossbar; /** * Represents the displayed color of a {@link BossBar}. - * @deprecated Use {@link net.kyori.adventure.bossbar.BossBar} + * @deprecated Use {@link net.kyori.adventure.bossbar.BossBar.Color} */ @Deprecated public enum BarColor { diff --git a/src/main/java/net/minestom/server/bossbar/BarDivision.java b/src/main/java/net/minestom/server/bossbar/BarDivision.java index 54f9fe79f..07bd95a1f 100644 --- a/src/main/java/net/minestom/server/bossbar/BarDivision.java +++ b/src/main/java/net/minestom/server/bossbar/BarDivision.java @@ -3,7 +3,7 @@ package net.minestom.server.bossbar; /** * Used to define the number of segments on a {@link BossBar}. * - * @deprecated Use {@link net.kyori.adventure.bossbar.BossBar} + * @deprecated Use {@link net.kyori.adventure.bossbar.BossBar.Overlay} */ @Deprecated public enum BarDivision { diff --git a/src/main/java/net/minestom/server/bossbar/BossBar.java b/src/main/java/net/minestom/server/bossbar/BossBar.java index b2a043989..c64b2265a 100644 --- a/src/main/java/net/minestom/server/bossbar/BossBar.java +++ b/src/main/java/net/minestom/server/bossbar/BossBar.java @@ -20,7 +20,7 @@ import java.util.concurrent.CopyOnWriteArraySet; *

* You can retrieve all the boss bars of a {@link Player} with {@link #getBossBars(Player)}. * - * @deprecated Use {@link net.kyori.adventure.audience.Audience#showBossBar(net.kyori.adventure.bossbar.BossBar)} + * @deprecated Use {@link net.kyori.adventure.bossbar.BossBar} */ @Deprecated public class BossBar implements Viewable { diff --git a/src/main/java/net/minestom/server/chat/ChatClickEvent.java b/src/main/java/net/minestom/server/chat/ChatClickEvent.java index 331ed1d3c..a1d300334 100644 --- a/src/main/java/net/minestom/server/chat/ChatClickEvent.java +++ b/src/main/java/net/minestom/server/chat/ChatClickEvent.java @@ -1,9 +1,11 @@ package net.minestom.server.chat; +import net.kyori.adventure.text.event.ClickEvent; import org.jetbrains.annotations.NotNull; /** * Represents a click event for a specific portion of the message. + * @deprecated Use {@link ClickEvent} */ @Deprecated public class ChatClickEvent { diff --git a/src/main/java/net/minestom/server/chat/ChatColor.java b/src/main/java/net/minestom/server/chat/ChatColor.java index 1d54d8bdd..b7e74893f 100644 --- a/src/main/java/net/minestom/server/chat/ChatColor.java +++ b/src/main/java/net/minestom/server/chat/ChatColor.java @@ -4,24 +4,31 @@ import it.unimi.dsi.fastutil.chars.Char2ObjectMap; import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import net.kyori.adventure.text.format.TextColor; +import net.kyori.adventure.text.ComponentBuilder; +import net.kyori.adventure.text.format.*; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.minestom.server.color.Color; +import net.minestom.server.color.DyeColor; import net.minestom.server.utils.validate.Check; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.Objects; /** * Represents a color in a text. You can either use one of the pre-made colors * or make your own using RGB. {@link ChatColor#fromRGB(byte, byte, byte)}. *

* Immutable class. + * @deprecated For chat colors, use {@link TextColor} or {@link NamedTextColor#}. For styles, use {@link TextDecoration}. + * For colors in other contexts, see {@link Color} or {@link DyeColor}. */ @Deprecated -public final class ChatColor { +public final class ChatColor implements StyleBuilderApplicable { // Special public static final ChatColor NO_COLOR = new ChatColor(); @@ -310,4 +317,26 @@ public final class ChatColor { return header + code + footer; } + + @Override + @Contract(mutates = "param") + public void styleApply(Style.@NotNull Builder style) { + if (this.isEmpty()) { + style.color(NamedTextColor.WHITE); + } else if (Objects.equals(this.codeName, "reset")) { + style.color(NamedTextColor.WHITE); + + for (TextDecoration value : TextDecoration.NAMES.values()) { + style.decoration(value, TextDecoration.State.FALSE); + } + } else if (this.isSpecial() && this.codeName != null) { + TextDecoration decoration = TextDecoration.NAMES.value(this.codeName); + + if (decoration != null) { + style.decorate(decoration); + } + } else { + style.color(TextColor.color(this.red, this.green, this.blue)); + } + } } diff --git a/src/main/java/net/minestom/server/chat/ChatHoverEvent.java b/src/main/java/net/minestom/server/chat/ChatHoverEvent.java index f10722f71..963338dea 100644 --- a/src/main/java/net/minestom/server/chat/ChatHoverEvent.java +++ b/src/main/java/net/minestom/server/chat/ChatHoverEvent.java @@ -17,6 +17,7 @@ import java.util.UUID; /** * Represents a hover event for a specific portion of the message. + * @deprecated Use {@link HoverEvent} */ @Deprecated public class ChatHoverEvent { diff --git a/src/main/java/net/minestom/server/chat/ChatParser.java b/src/main/java/net/minestom/server/chat/ChatParser.java index 7628ff9c0..79c5bb148 100644 --- a/src/main/java/net/minestom/server/chat/ChatParser.java +++ b/src/main/java/net/minestom/server/chat/ChatParser.java @@ -2,10 +2,12 @@ package net.minestom.server.chat; import com.google.gson.*; +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import org.jetbrains.annotations.NotNull; /** * Class used to convert JSON string to proper chat message representation. + * @deprecated Use {@link GsonComponentSerializer} */ @Deprecated public final class ChatParser { diff --git a/src/main/java/net/minestom/server/chat/ColoredText.java b/src/main/java/net/minestom/server/chat/ColoredText.java index 7739a8655..95c52c073 100644 --- a/src/main/java/net/minestom/server/chat/ColoredText.java +++ b/src/main/java/net/minestom/server/chat/ColoredText.java @@ -2,6 +2,8 @@ package net.minestom.server.chat; import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.TextColor; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -16,6 +18,7 @@ import java.util.regex.Pattern; *

* To create one, you simply call one of the static methods like {@link #of(ChatColor, String)}, * you can then continue to append text with {@link #append(ChatColor, String)}. + * @deprecated Use {@link Component#text(String, TextColor)} */ @Deprecated public class ColoredText extends JsonMessage { diff --git a/src/main/java/net/minestom/server/chat/JsonMessage.java b/src/main/java/net/minestom/server/chat/JsonMessage.java index af8f79262..2c1626210 100644 --- a/src/main/java/net/minestom/server/chat/JsonMessage.java +++ b/src/main/java/net/minestom/server/chat/JsonMessage.java @@ -16,6 +16,7 @@ import java.util.Objects; * Examples are {@link ColoredText} and {@link RichMessage}. * * @see Chat Format + * @deprecated Use {@link Component} */ @Deprecated public abstract class JsonMessage implements ComponentLike { diff --git a/src/main/java/net/minestom/server/chat/RichMessage.java b/src/main/java/net/minestom/server/chat/RichMessage.java index 52a70d0a0..58a671cbe 100644 --- a/src/main/java/net/minestom/server/chat/RichMessage.java +++ b/src/main/java/net/minestom/server/chat/RichMessage.java @@ -2,6 +2,7 @@ package net.minestom.server.chat; import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import net.kyori.adventure.text.Component; import net.minestom.server.utils.validate.Check; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -18,6 +19,7 @@ import java.util.List; * You will need to call the static method to initialize the message {@link #of(ColoredText)}, * events can be assigned with {@link #setClickEvent(ChatClickEvent)} and {@link #setHoverEvent(ChatHoverEvent)} * and new text element can also be appended {@link #append(ColoredText)}. + * @deprecated Use {@link Component} */ @Deprecated public class RichMessage extends JsonMessage { diff --git a/src/main/java/net/minestom/server/chat/TranslatableText.java b/src/main/java/net/minestom/server/chat/TranslatableText.java index 62a88ad2d..ac6b7b357 100644 --- a/src/main/java/net/minestom/server/chat/TranslatableText.java +++ b/src/main/java/net/minestom/server/chat/TranslatableText.java @@ -1,10 +1,12 @@ package net.minestom.server.chat; +import net.kyori.adventure.text.TranslatableComponent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Represents a translatable component which can be used in {@link ColoredText}. + * @deprecated Use {@link TranslatableComponent} */ @Deprecated public class TranslatableText {