Files
ParchmentMC/patches/api/0006-Expanded-Adventure-support.patch
lexikiq cba86f93d9 Expanded Adventure support
Adds support for Adventure in a few places where it was previously missing.
2021-07-05 01:47:42 -04:00

216 lines
7.6 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 4594701d77c5d0f744bece871b98d9f6f73eb5a7..136f87f6cd2f3a56cfa645084fd6446a20f2e88e 100644
--- a/src/main/java/org/bukkit/ChatColor.java
+++ b/src/main/java/org/bukkit/ChatColor.java
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable;
/**
* All supported color values for chat
*/
-public enum ChatColor {
+public enum ChatColor implements net.kyori.adventure.text.format.StyleBuilderApplicable, net.kyori.adventure.text.format.TextFormat { // Parchment
/**
* Represents black
*/
@@ -181,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.
@@ -191,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.
@@ -201,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.
@@ -211,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.
@@ -221,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.
@@ -231,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
};
/**
@@ -263,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 deae003b7e9a96bbf1c0167d3e1d864e61b07f82..53afcd97fc34bceff741ee118f63226781f9c895 100644
--- a/src/main/java/org/bukkit/Color.java
+++ b/src/main/java/org/bukkit/Color.java
@@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
* 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;
/**
@@ -242,6 +242,13 @@ public final class Color implements ConfigurationSerializable {
return getRed() << 16 | getGreen() << 8 | getBlue() << 0;
}
+ // 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.
*
diff --git a/src/main/java/org/bukkit/Keyed.java b/src/main/java/org/bukkit/Keyed.java
index 32c92621c2c15eec14c50965f5ecda00c46e6c80..3876a03ab9df9a0aef7a5c05a38b39b07a6dd285 100644
--- a/src/main/java/org/bukkit/Keyed.java
+++ b/src/main/java/org/bukkit/Keyed.java
@@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents an object which has a {@link NamespacedKey} attached to it.
*/
-public interface Keyed {
+public interface Keyed extends net.kyori.adventure.key.Keyed { // Parchment
/**
* Return the namespaced identifier for this object.
@@ -14,4 +14,11 @@ public interface Keyed {
*/
@NotNull
NamespacedKey getKey();
+
+ // Parchment start
+ @Override
+ default net.kyori.adventure.key.@org.checkerframework.checker.nullness.qual.NonNull Key key() {
+ return getKey();
+ }
+ // Parchment end
}