mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-31 20:22:05 -07:00
adventure: make calls with generic component lists more usable (#9008)
This should allow the usage of ItemStack#lore and other methods with a List<TextComponent>
This commit is contained in:
@@ -893,7 +893,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return adventures;
|
||||
+ }
|
||||
+
|
||||
+ public static List<String> asJson(final List<Component> adventures) {
|
||||
+ public static List<String> asJson(final List<? extends Component> adventures) {
|
||||
+ final List<String> jsons = new ArrayList<>(adventures.size());
|
||||
+ for (final Component component : adventures) {
|
||||
+ jsons.add(GsonComponentSerializer.gson().serialize(component));
|
||||
@@ -3176,7 +3176,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public static Component[] sanitizeLines(java.util.List<net.kyori.adventure.text.Component> lines) {
|
||||
+ public static Component[] sanitizeLines(java.util.List<? extends net.kyori.adventure.text.Component> lines) {
|
||||
+ Component[] components = new Component[4];
|
||||
+ for (int i = 0; i < 4; i++) {
|
||||
+ if (i < lines.size() && lines.get(i) != null) {
|
||||
@@ -3570,7 +3570,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void sendSignChange(Location loc, @Nullable List<net.kyori.adventure.text.Component> lines, DyeColor dyeColor, boolean hasGlowingText) {
|
||||
+ public void sendSignChange(Location loc, @Nullable List<? extends net.kyori.adventure.text.Component> lines, DyeColor dyeColor, boolean hasGlowingText) {
|
||||
+ if (getHandle().connection == null) {
|
||||
+ return;
|
||||
+ }
|
||||
@@ -4404,7 +4404,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void lore(final List<net.kyori.adventure.text.Component> lore) {
|
||||
+ public void lore(final List<? extends net.kyori.adventure.text.Component> lore) {
|
||||
+ this.lore = lore != null ? io.papermc.paper.adventure.PaperAdventure.asJson(lore) : null;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
Reference in New Issue
Block a user