Files
ParchmentMC/patches/api/0005-Expanded-Adventure-support.patch
2023-04-07 14:53:06 -04:00

192 lines
6.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: lexikiq <noellekiq@gmail.com>
Date: Mon, 5 Jul 2021 01:45:49 -0400
Subject: [PATCH] Expanded Adventure support
Adds support for Adventure in a few places where it was previously missing.
diff --git a/src/main/java/org/bukkit/ChatColor.java b/src/main/java/org/bukkit/ChatColor.java
index ea4ceb643239c26851bacbf45fc3f2efef3bb4be..eea8e60c363b6dc14383fb7758cbf41469f76425 100644
--- a/src/main/java/org/bukkit/ChatColor.java
+++ b/src/main/java/org/bukkit/ChatColor.java
@@ -11,8 +11,7 @@ import org.jetbrains.annotations.Nullable;
/**
* All supported color values for chat
*/
-@Deprecated // Paper
-public enum ChatColor {
+public enum ChatColor implements net.kyori.adventure.text.format.StyleBuilderApplicable, net.kyori.adventure.text.format.TextFormat { // Parchment
/**
* Represents black
*/
@@ -182,6 +181,13 @@ public enum ChatColor {
public net.md_5.bungee.api.ChatColor asBungee() {
return net.md_5.bungee.api.ChatColor.MAGIC;
}
+
+ // Parchment start
+ @Override
+ public void styleApply(net.kyori.adventure.text.format.Style.@NotNull Builder style) {
+ style.decorate(net.kyori.adventure.text.format.TextDecoration.OBFUSCATED);
+ }
+ // Parchment end
},
/**
* Makes the text bold.
@@ -192,6 +198,13 @@ public enum ChatColor {
public net.md_5.bungee.api.ChatColor asBungee() {
return net.md_5.bungee.api.ChatColor.BOLD;
}
+
+ // Parchment start
+ @Override
+ public void styleApply(net.kyori.adventure.text.format.Style.@NotNull Builder style) {
+ style.decorate(net.kyori.adventure.text.format.TextDecoration.BOLD);
+ }
+ // Parchment end
},
/**
* Makes a line appear through the text.
@@ -202,6 +215,13 @@ public enum ChatColor {
public net.md_5.bungee.api.ChatColor asBungee() {
return net.md_5.bungee.api.ChatColor.STRIKETHROUGH;
}
+
+ // Parchment start
+ @Override
+ public void styleApply(net.kyori.adventure.text.format.Style.@NotNull Builder style) {
+ style.decorate(net.kyori.adventure.text.format.TextDecoration.STRIKETHROUGH);
+ }
+ // Parchment end
},
/**
* Makes the text appear underlined.
@@ -212,6 +232,13 @@ public enum ChatColor {
public net.md_5.bungee.api.ChatColor asBungee() {
return net.md_5.bungee.api.ChatColor.UNDERLINE;
}
+
+ // Parchment start
+ @Override
+ public void styleApply(net.kyori.adventure.text.format.Style.@NotNull Builder style) {
+ style.decorate(net.kyori.adventure.text.format.TextDecoration.UNDERLINED);
+ }
+ // Parchment end
},
/**
* Makes the text italic.
@@ -222,6 +249,13 @@ public enum ChatColor {
public net.md_5.bungee.api.ChatColor asBungee() {
return net.md_5.bungee.api.ChatColor.ITALIC;
}
+
+ // Parchment start
+ @Override
+ public void styleApply(net.kyori.adventure.text.format.Style.@NotNull Builder style) {
+ style.decorate(net.kyori.adventure.text.format.TextDecoration.ITALIC);
+ }
+ // Parchment end
},
/**
* Resets all previous chat colors or formats.
@@ -232,6 +266,16 @@ public enum ChatColor {
public net.md_5.bungee.api.ChatColor asBungee() {
return net.md_5.bungee.api.ChatColor.RESET;
}
+
+ // Parchment start
+ @Override
+ public void styleApply(net.kyori.adventure.text.format.Style.@NotNull Builder style) {
+ style.color(null);
+ for (net.kyori.adventure.text.format.TextDecoration decoration : net.kyori.adventure.text.format.TextDecoration.values()) {
+ style.decoration(decoration, net.kyori.adventure.text.format.TextDecoration.State.NOT_SET);
+ }
+ }
+ // Parchment end
};
/**
@@ -264,6 +308,13 @@ public enum ChatColor {
return net.md_5.bungee.api.ChatColor.RESET;
};
+ // Parchment start
+ @Override
+ public void styleApply(net.kyori.adventure.text.format.Style.@NotNull Builder style) {
+ style.color(net.kyori.adventure.text.format.TextColor.color(asBungee().getColor().getRGB()));
+ }
+ // Parchment end
+
/**
* Gets the char value associated with this color
*
diff --git a/src/main/java/org/bukkit/Color.java b/src/main/java/org/bukkit/Color.java
index e088390ec3fb87eeabc73dfe90e3544980c02e5b..5d4fbb08832fd0490a9375580f909beaf941e8fa 100644
--- a/src/main/java/org/bukkit/Color.java
+++ b/src/main/java/org/bukkit/Color.java
@@ -16,7 +16,7 @@ import org.jetbrains.annotations.Nullable;
* but subject to change.
*/
@SerializableAs("Color")
-public final class Color implements ConfigurationSerializable {
+public final class Color implements ConfigurationSerializable, net.kyori.adventure.text.format.TextColor { // Parchment
private static final int BIT_MASK = 0xff;
private static final int DEFAULT_ALPHA = 255;
@@ -309,6 +309,13 @@ public final class Color implements ConfigurationSerializable {
return getAlpha() << 24 | getRed() << 16 | getGreen() << 8 | getBlue();
}
+ // Parchment start
+ @Override
+ public int value() {
+ return asRGB();
+ }
+ // Parchment end
+
/**
* Gets the color as an BGR integer.
*
diff --git a/src/main/java/org/bukkit/DyeColor.java b/src/main/java/org/bukkit/DyeColor.java
index bd213cabddd8752e609544f24cfba95405726155..7e89cadecde96f9c2394446669dc4d98df391940 100644
--- a/src/main/java/org/bukkit/DyeColor.java
+++ b/src/main/java/org/bukkit/DyeColor.java
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
/**
* All supported color values for dyes and cloth
*/
-public enum DyeColor {
+public enum DyeColor implements net.kyori.adventure.util.RGBLike, net.kyori.adventure.text.format.StyleBuilderApplicable { // Parchment
/**
* Represents white dye.
@@ -135,6 +135,28 @@ public enum DyeColor {
return firework;
}
+ // Parchment start
+ @Override
+ public @org.jetbrains.annotations.Range(from = 0L, to = 255L) int red() {
+ return color.getRed();
+ }
+
+ @Override
+ public @org.jetbrains.annotations.Range(from = 0L, to = 255L) int green() {
+ return color.getGreen();
+ }
+
+ @Override
+ public @org.jetbrains.annotations.Range(from = 0L, to = 255L) int blue() {
+ return color.getBlue();
+ }
+
+ @Override
+ public void styleApply(net.kyori.adventure.text.format.Style.@org.jetbrains.annotations.NotNull Builder style) {
+ style.color(net.kyori.adventure.text.format.TextColor.color(color));
+ }
+ // Parchment end
+
/**
* Gets the DyeColor with the given wool data value.
*