From c54215c1b2a6f52c189b213ff60fa6d2bb1dd77a Mon Sep 17 00:00:00 2001 From: JOO200 Date: Mon, 20 Mar 2023 09:18:06 +0100 Subject: [PATCH] adventure: make calls with generic component lists more usable (#9008) This should allow the usage of ItemStack#lore and other methods with a List --- patches/api/Adventure.patch | 10 +++++----- ...emStack-API-additions-for-quantity-flags-lore.patch | 2 +- patches/server/Adventure.patch | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index 1a42c3c676..384b08e275 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -2151,7 +2151,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @throws IllegalArgumentException if location is null + * @throws IllegalArgumentException if lines is non-null and has a length less than 4 + */ -+ default void sendSignChange(@NotNull Location loc, @Nullable java.util.List lines) throws IllegalArgumentException { ++ default void sendSignChange(@NotNull Location loc, @Nullable java.util.List lines) throws IllegalArgumentException { + this.sendSignChange(loc, lines, DyeColor.BLACK); + } + @@ -2172,7 +2172,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @throws IllegalArgumentException if dyeColor is null + * @throws IllegalArgumentException if lines is non-null and has a length less than 4 + */ -+ default void sendSignChange(@NotNull Location loc, @Nullable java.util.List lines, @NotNull DyeColor dyeColor) throws IllegalArgumentException { ++ default void sendSignChange(@NotNull Location loc, @Nullable java.util.List lines, @NotNull DyeColor dyeColor) throws IllegalArgumentException { + this.sendSignChange(loc, lines, dyeColor, false); + } + @@ -2193,7 +2193,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @throws IllegalArgumentException if dyeColor is null + * @throws IllegalArgumentException if lines is non-null and has a length less than 4 + */ -+ default void sendSignChange(@NotNull Location loc, @Nullable java.util.List lines, boolean hasGlowingText) throws IllegalArgumentException { ++ default void sendSignChange(@NotNull Location loc, @Nullable java.util.List lines, boolean hasGlowingText) throws IllegalArgumentException { + this.sendSignChange(loc, lines, DyeColor.BLACK, hasGlowingText); + } + @@ -2215,7 +2215,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @throws IllegalArgumentException if dyeColor is null + * @throws IllegalArgumentException if lines is non-null and has a length less than 4 + */ -+ void sendSignChange(@NotNull Location loc, @Nullable java.util.List lines, @NotNull DyeColor dyeColor, boolean hasGlowingText) ++ void sendSignChange(@NotNull Location loc, @Nullable java.util.List lines, @NotNull DyeColor dyeColor, boolean hasGlowingText) + throws IllegalArgumentException; + // Paper end + @@ -4136,7 +4136,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param lore the lore to set + */ -+ void lore(final @Nullable List lore); ++ void lore(final @Nullable List lore); + // Paper end + /** diff --git a/patches/api/ItemStack-API-additions-for-quantity-flags-lore.patch b/patches/api/ItemStack-API-additions-for-quantity-flags-lore.patch index 0d3bfd4277..56a61718f2 100644 --- a/patches/api/ItemStack-API-additions-for-quantity-flags-lore.patch +++ b/patches/api/ItemStack-API-additions-for-quantity-flags-lore.patch @@ -139,7 +139,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param lore the lore that will be set + */ -+ public void lore(@Nullable List lore) { ++ public void lore(@Nullable List lore) { + ItemMeta itemMeta = getItemMeta(); + if (itemMeta == null) { + throw new IllegalStateException("Cannot set lore on " + getType()); diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 9f37264d52..e32d01bff3 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -893,7 +893,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return adventures; + } + -+ public static List asJson(final List adventures) { ++ public static List asJson(final List adventures) { + final List 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 lines) { ++ public static Component[] sanitizeLines(java.util.List 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 lines, DyeColor dyeColor, boolean hasGlowingText) { ++ public void sendSignChange(Location loc, @Nullable List lines, DyeColor dyeColor, boolean hasGlowingText) { + if (getHandle().connection == null) { + return; + } @@ -4404,7 +4404,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public void lore(final List lore) { ++ public void lore(final List lore) { + this.lore = lore != null ? io.papermc.paper.adventure.PaperAdventure.asJson(lore) : null; + } + // Paper end