Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-25 07:40:06 +01:00
Don't support hex in book title and author (#9493)
Dieser Commit ist enthalten in:
Ursprung
d8b8f61961
Commit
2c54b3949f
@ -4357,7 +4357,7 @@ index 9e05a8515c5f6f340182e91150fcad8bbf80a22b..adf22ce4f0bcd3bd57dc2030c6c92d3d
|
|||||||
@Override
|
@Override
|
||||||
public CraftMerchant getCraftMerchant() {
|
public CraftMerchant getCraftMerchant() {
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
||||||
index bd4524fd987877a287680cfa5744ce12045ebfbd..cf928745c36af0e6fa0a95e177395c5fb1aa821a 100644
|
index bd4524fd987877a287680cfa5744ce12045ebfbd..5d72d2c6fcab478121eb9b4216cf79532b58299e 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
||||||
@@ -2,8 +2,9 @@ package org.bukkit.craftbukkit.inventory;
|
@@ -2,8 +2,9 @@ package org.bukkit.craftbukkit.inventory;
|
||||||
@ -4371,30 +4371,30 @@ index bd4524fd987877a287680cfa5744ce12045ebfbd..cf928745c36af0e6fa0a95e177395c5f
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -261,6 +262,145 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
@@ -261,6 +262,148 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||||
this.generation = (generation == null) ? null : generation.ordinal();
|
this.generation = (generation == null) ? null : generation.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public net.kyori.adventure.text.Component title() {
|
+ public net.kyori.adventure.text.Component title() {
|
||||||
+ return this.title == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.title);
|
+ return this.title == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.deserialize(this.title);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public org.bukkit.inventory.meta.BookMeta title(net.kyori.adventure.text.Component title) {
|
+ public org.bukkit.inventory.meta.BookMeta title(net.kyori.adventure.text.Component title) {
|
||||||
+ this.setTitle(title == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(title));
|
+ this.setTitle(title == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(title));
|
||||||
+ return this;
|
+ return this;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public net.kyori.adventure.text.Component author() {
|
+ public net.kyori.adventure.text.Component author() {
|
||||||
+ return this.author == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.author);
|
+ return this.author == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.deserialize(this.author);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public org.bukkit.inventory.meta.BookMeta author(net.kyori.adventure.text.Component author) {
|
+ public org.bukkit.inventory.meta.BookMeta author(net.kyori.adventure.text.Component author) {
|
||||||
+ this.setAuthor(author == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(author));
|
+ this.setAuthor(author == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(author));
|
||||||
+ return this;
|
+ return this;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@ -4456,10 +4456,13 @@ index bd4524fd987877a287680cfa5744ce12045ebfbd..cf928745c36af0e6fa0a95e177395c5f
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ protected static final net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.builder()
|
||||||
|
+ .character(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.SECTION_CHAR)
|
||||||
|
+ .build();
|
||||||
+ private CraftMetaBook(net.kyori.adventure.text.Component title, net.kyori.adventure.text.Component author, List<net.kyori.adventure.text.Component> pages) {
|
+ private CraftMetaBook(net.kyori.adventure.text.Component title, net.kyori.adventure.text.Component author, List<net.kyori.adventure.text.Component> pages) {
|
||||||
+ super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(org.bukkit.Material.WRITABLE_BOOK));
|
+ super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(org.bukkit.Material.WRITABLE_BOOK));
|
||||||
+ this.title = title == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(title);
|
+ this.title = title == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(title);
|
||||||
+ this.author = author == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(author);
|
+ this.author = author == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(author);
|
||||||
+ this.pages = pages.subList(0, Math.min(MAX_PAGES, pages.size())).stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::serialize).collect(java.util.stream.Collectors.toList());
|
+ this.pages = pages.subList(0, Math.min(MAX_PAGES, pages.size())).stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::serialize).collect(java.util.stream.Collectors.toList());
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@ -4517,7 +4520,7 @@ index bd4524fd987877a287680cfa5744ce12045ebfbd..cf928745c36af0e6fa0a95e177395c5f
|
|||||||
@Override
|
@Override
|
||||||
public String getPage(final int page) {
|
public String getPage(final int page) {
|
||||||
Preconditions.checkArgument(this.isValidPage(page), "Invalid page number (%s)", page);
|
Preconditions.checkArgument(this.isValidPage(page), "Invalid page number (%s)", page);
|
||||||
@@ -402,7 +542,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
@@ -402,7 +545,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -4527,7 +4530,7 @@ index bd4524fd987877a287680cfa5744ce12045ebfbd..cf928745c36af0e6fa0a95e177395c5f
|
|||||||
|
|
||||||
if (this.hasTitle()) {
|
if (this.hasTitle()) {
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
|
||||||
index 507fa96a3fb904b74429df5756c9a6378ec8c5b7..abb9e88abc74135284b941e040d4058690a82b27 100644
|
index 507fa96a3fb904b74429df5756c9a6378ec8c5b7..5c6eb9b6f3ca4fc6534fe023fe78be5c9f97e1a9 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
|
||||||
@@ -1,6 +1,6 @@
|
@@ -1,6 +1,6 @@
|
||||||
@ -4551,8 +4554,8 @@ index 507fa96a3fb904b74429df5756c9a6378ec8c5b7..abb9e88abc74135284b941e040d40586
|
|||||||
+ // Paper start - adventure
|
+ // Paper start - adventure
|
||||||
+ private CraftMetaBookSigned(net.kyori.adventure.text.Component title, net.kyori.adventure.text.Component author, java.util.List<net.kyori.adventure.text.Component> pages) {
|
+ private CraftMetaBookSigned(net.kyori.adventure.text.Component title, net.kyori.adventure.text.Component author, java.util.List<net.kyori.adventure.text.Component> pages) {
|
||||||
+ super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(Material.WRITABLE_BOOK));
|
+ super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(Material.WRITABLE_BOOK));
|
||||||
+ this.title = title == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(title);
|
+ this.title = title == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(title);
|
||||||
+ this.author = author == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(author);
|
+ this.author = author == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(author);
|
||||||
+ this.pages = io.papermc.paper.adventure.PaperAdventure.asJson(pages.subList(0, Math.min(MAX_PAGES, pages.size())));
|
+ this.pages = io.papermc.paper.adventure.PaperAdventure.asJson(pages.subList(0, Math.min(MAX_PAGES, pages.size())));
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren