Fix missing CraftMetaBook#toBuilder override

Dieser Commit ist enthalten in:
Shane Freeder 2021-05-06 17:27:19 +01:00
Ursprung 48aa061063
Commit 2a67a9e512
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A3F61EA5A085289C
3 geänderte Dateien mit 54 neuen und 23 gelöschten Zeilen

Datei anzeigen

@ -1306,7 +1306,7 @@ index 9566e4306ada5e82dede0f002aa06da12c44996b..4d5f0837bd0e02a30c943d8969fb6b13
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
index 344c14a5ed86e9ebe401bfb5ba3aedc0c0ed0b04..41a1bc45cc5eb7f19374115ade7f5328c7fc1dae 100644
index b71530e94569f8ade829e655e3a89ec70215ea39..b21fe6c631d5a6cd52f133786270c8f5ad0dafc4 100644
--- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.Nullable;
@ -2898,10 +2898,22 @@ index f70a6a22b85ff0da76e67e9b223ad4e0b020b5c4..4b20b557eaa958cf1ad1baf8d6cc17f3
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/inventory/meta/BookMeta.java b/src/main/java/org/bukkit/inventory/meta/BookMeta.java
index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4a95f513c 100644
index 94852d50e88d0594b84b581cd627174043629995..fdbd32c4bb6428f2dde484ecb53acdaaba2a0d18 100644
--- a/src/main/java/org/bukkit/inventory/meta/BookMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/BookMeta.java
@@ -10,7 +10,7 @@ import org.jetbrains.annotations.Nullable;
@@ -1,8 +1,11 @@
package org.bukkit.inventory.meta;
import java.util.List;
+
+import net.kyori.adventure.inventory.Book;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Material;
+import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -10,7 +13,7 @@ import org.jetbrains.annotations.Nullable;
* Represents a book ({@link Material#WRITABLE_BOOK} or {@link
* Material#WRITTEN_BOOK}) that can have a title, an author, and pages.
*/
@ -2910,7 +2922,7 @@ index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4
/**
* Represents the generation (or level of copying) of a written book
@@ -119,6 +119,111 @@ public interface BookMeta extends ItemMeta {
@@ -119,6 +122,116 @@ public interface BookMeta extends ItemMeta {
*/
boolean hasPages();
@ -3017,12 +3029,17 @@ index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4
+ @Override
+ BookMeta build();
+ }
+
+ @Override
+ @NonNull
+ BookMetaBuilder toBuilder();
+
+ // Paper end
+
/**
* Gets the specified page in the book. The given page must exist.
* <p>
@@ -126,8 +231,10 @@ public interface BookMeta extends ItemMeta {
@@ -126,8 +239,10 @@ public interface BookMeta extends ItemMeta {
*
* @param page the page number to get, in range [1, getPageCount()]
* @return the page from the book
@ -3033,7 +3050,7 @@ index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4
String getPage(int page);
/**
@@ -141,15 +248,19 @@ public interface BookMeta extends ItemMeta {
@@ -141,15 +256,19 @@ public interface BookMeta extends ItemMeta {
*
* @param page the page number to set, in range [1, getPageCount()]
* @param data the data to set for that page
@ -3053,7 +3070,7 @@ index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4
List<String> getPages();
/**
@@ -157,7 +268,9 @@ public interface BookMeta extends ItemMeta {
@@ -157,7 +276,9 @@ public interface BookMeta extends ItemMeta {
* pages. Maximum 100 pages with 256 characters per page.
*
* @param pages A list of pages to set the book to use
@ -3063,7 +3080,7 @@ index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4
void setPages(@NotNull List<String> pages);
/**
@@ -165,7 +278,9 @@ public interface BookMeta extends ItemMeta {
@@ -165,7 +286,9 @@ public interface BookMeta extends ItemMeta {
* pages. Maximum 50 pages with 256 characters per page.
*
* @param pages A list of strings, each being a page
@ -3073,7 +3090,7 @@ index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4
void setPages(@NotNull String... pages);
/**
@@ -173,7 +288,9 @@ public interface BookMeta extends ItemMeta {
@@ -173,7 +296,9 @@ public interface BookMeta extends ItemMeta {
* 256 characters per page.
*
* @param pages A list of strings, each being a page
@ -3083,7 +3100,7 @@ index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4
void addPage(@NotNull String... pages);
/**
@@ -195,8 +312,10 @@ public interface BookMeta extends ItemMeta {
@@ -195,8 +320,10 @@ public interface BookMeta extends ItemMeta {
*
* @param page the page number to get
* @return the page from the book
@ -3094,7 +3111,7 @@ index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4
public BaseComponent[] getPage(int page) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -210,7 +329,9 @@ public interface BookMeta extends ItemMeta {
@@ -210,7 +337,9 @@ public interface BookMeta extends ItemMeta {
*
* @param page the page number to set
* @param data the data to set for that page
@ -3104,7 +3121,7 @@ index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4
public void setPage(int page, @Nullable BaseComponent... data) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -219,8 +340,10 @@ public interface BookMeta extends ItemMeta {
@@ -219,8 +348,10 @@ public interface BookMeta extends ItemMeta {
* Gets all the pages in the book.
*
* @return list of all the pages in the book
@ -3115,7 +3132,7 @@ index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4
public List<BaseComponent[]> getPages() {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -230,7 +353,9 @@ public interface BookMeta extends ItemMeta {
@@ -230,7 +361,9 @@ public interface BookMeta extends ItemMeta {
* pages. Maximum 50 pages with 256 characters per page.
*
* @param pages A list of pages to set the book to use
@ -3125,7 +3142,7 @@ index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4
public void setPages(@NotNull List<BaseComponent[]> pages) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -240,7 +365,9 @@ public interface BookMeta extends ItemMeta {
@@ -240,7 +373,9 @@ public interface BookMeta extends ItemMeta {
* pages. Maximum 50 pages with 256 characters per page.
*
* @param pages A list of component arrays, each being a page
@ -3135,7 +3152,7 @@ index 94852d50e88d0594b84b581cd627174043629995..0cfd4b02cc2095da56b4dc8d4ea4e9b4
public void setPages(@NotNull BaseComponent[]... pages) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -250,7 +377,9 @@ public interface BookMeta extends ItemMeta {
@@ -250,7 +385,9 @@ public interface BookMeta extends ItemMeta {
* with 256 characters per page.
*
* @param pages A list of component arrays, each being a page

Datei anzeigen

@ -2637,7 +2637,7 @@ index ef10c7ab1d615cdba182eca63eb14309339a5314..206c133ebc6c44038585236b0628543b
@Override
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
index 4cdc504df4cad6f7725f6d18482e88433523943a..af1f45bb8bbe380eec1dcdef1beacb06c9d932a8 100644
index 4cdc504df4cad6f7725f6d18482e88433523943a..65b6d32e3e1130a64df33082f3292cb1ce6f500a 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
@@ -1,8 +1,9 @@
@ -2651,7 +2651,15 @@ index 4cdc504df4cad6f7725f6d18482e88433523943a..af1f45bb8bbe380eec1dcdef1beacb06
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -269,6 +270,135 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
@@ -21,6 +22,7 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.inventory.meta.BookMeta.Generation;
+import org.checkerframework.checker.nullness.qual.NonNull;
// Spigot start
import static org.spigotmc.ValidateUtils.*;
@@ -269,6 +271,141 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
this.generation = (generation == null) ? null : generation.ordinal();
}
@ -2783,11 +2791,17 @@ index 4cdc504df4cad6f7725f6d18482e88433523943a..af1f45bb8bbe380eec1dcdef1beacb06
+ return new CraftMetaBook(title, author, pages);
+ }
+ }
+
+ @Override
+ public BookMetaBuilder toBuilder() {
+ return new CraftMetaBookBuilder();
+ }
+
+ // Paper end
@Override
public String getPage(final int page) {
Validate.isTrue(isValidPage(page), "Invalid page number");
@@ -413,7 +543,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
@@ -413,7 +550,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
}
@Override

Datei anzeigen

@ -11,10 +11,10 @@ to make books with as much data as they want. Do not use this without
limiting incoming data from packets in some other way.
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
index 123616ed018fbc4d69f46e65d5ff15734008a00d..34449ac7899abbc863266da1e6197873f80940b0 100644
index 0acf6571c02b41f178503966be7be3eface6a335..27217b633f9259a6fbad15ea566c8a188775f447 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
@@ -40,6 +40,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
@@ -41,6 +41,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
static final int MAX_PAGES = 100;
static final int MAX_PAGE_LENGTH = 320; // 256 limit + 64 characters to allow for psuedo colour codes
static final int MAX_TITLE_LENGTH = 32;
@ -22,7 +22,7 @@ index 123616ed018fbc4d69f46e65d5ff15734008a00d..34449ac7899abbc863266da1e6197873
protected String title;
protected String author;
@@ -242,7 +243,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
@@ -243,7 +244,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
if (title == null) {
this.title = null;
return true;
@ -31,7 +31,7 @@ index 123616ed018fbc4d69f46e65d5ff15734008a00d..34449ac7899abbc863266da1e6197873
return false;
}
@@ -433,7 +434,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
@@ -440,7 +441,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
String validatePage(String page) {
if (page == null) {
page = "";
@ -40,7 +40,7 @@ index 123616ed018fbc4d69f46e65d5ff15734008a00d..34449ac7899abbc863266da1e6197873
page = page.substring(0, MAX_PAGE_LENGTH);
}
return page;
@@ -443,7 +444,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
@@ -450,7 +451,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
// asserted: page != null
if (this.pages == null) {
this.pages = new ArrayList<String>();