geforkt von Mirrors/Paper
Fix a couple of ItemMeta related NPEs (#11149)
Dieser Commit ist enthalten in:
Ursprung
0139f28d62
Commit
61ad933f4d
@ -4927,15 +4927,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public net.kyori.adventure.text.Component page(final int page) {
|
+ public net.kyori.adventure.text.Component page(final int page) {
|
||||||
+ Preconditions.checkArgument(this.isValidPage(page), "Invalid page number");
|
+ Preconditions.checkArgument(this.isValidPage(page), "Invalid page number (%s/%s)", page, this.getPageCount());
|
||||||
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.pages.get(page - 1));
|
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.pages.get(page - 1));
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void page(final int page, net.kyori.adventure.text.Component data) {
|
+ public void page(final int page, net.kyori.adventure.text.Component data) {
|
||||||
+ if (!this.isValidPage(page)) {
|
+ Preconditions.checkArgument(this.isValidPage(page), "Invalid page number (%s/%s)", page, this.getPageCount());
|
||||||
+ throw new IllegalArgumentException("Invalid page number " + page + "/" + this.pages.size());
|
|
||||||
+ }
|
|
||||||
+ if (data == null) {
|
+ if (data == null) {
|
||||||
+ data = net.kyori.adventure.text.Component.empty();
|
+ data = net.kyori.adventure.text.Component.empty();
|
||||||
+ }
|
+ }
|
||||||
@ -5120,15 +5118,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public net.kyori.adventure.text.Component page(final int page) {
|
+ public net.kyori.adventure.text.Component page(final int page) {
|
||||||
+ Preconditions.checkArgument(this.isValidPage(page), "Invalid page number");
|
+ Preconditions.checkArgument(this.isValidPage(page), "Invalid page number (%s/%s)", page, this.getPageCount());
|
||||||
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.pages.get(page - 1));
|
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.pages.get(page - 1));
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void page(final int page, net.kyori.adventure.text.Component data) {
|
+ public void page(final int page, net.kyori.adventure.text.Component data) {
|
||||||
+ if (!this.isValidPage(page)) {
|
+ Preconditions.checkArgument(this.isValidPage(page), "Invalid page number (%s/%s)", page, this.getPageCount());
|
||||||
+ throw new IllegalArgumentException("Invalid page number " + page + "/" + this.pages.size());
|
|
||||||
+ }
|
|
||||||
+ this.pages.set(page - 1, io.papermc.paper.adventure.PaperAdventure.asVanillaNullToEmpty(data));
|
+ this.pages.set(page - 1, io.papermc.paper.adventure.PaperAdventure.asVanillaNullToEmpty(data));
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
@ -71,6 +71,16 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||||
|
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeEnchantments() {
|
||||||
|
+ if (this.handle != null) { // Paper - fix NPE
|
||||||
|
this.handle.remove(DataComponents.ENCHANTMENTS);
|
||||||
|
+ } // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
||||||
// Paper end - improve handled tags on type change
|
// Paper end - improve handled tags on type change
|
||||||
// Paper start
|
// Paper start
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren