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:
JOO200
2023-03-20 09:18:06 +01:00
parent 82f1c94258
commit c54215c1b2
3 changed files with 10 additions and 10 deletions

View File

@@ -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