Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 11:00:06 +01:00
fixup adventure's book meta handling
Dieser Commit ist enthalten in:
Ursprung
e85e1ec4a6
Commit
10e6143499
@ -4358,10 +4358,182 @@ index cf1733bc76d1e29ad0f533f6e49818f83e8e3358..f2a6f62f0344684668febc0999b81748
|
||||
+ // 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 9bab73c3c2ca759b8e1c7d07d98cc593c961666a..7cc66e5dd6f19295728d3c0e6c0898338281b8a7 100644
|
||||
index 9bab73c3c2ca759b8e1c7d07d98cc593c961666a..f0c6943da3f783101ca647b75b3230fae3a310da 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/meta/BookMeta.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/meta/BookMeta.java
|
||||
@@ -124,8 +124,10 @@ public interface BookMeta extends WritableBookMeta {
|
||||
@@ -7,10 +7,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
- * Represents a {@link Material#WRITTEN_BOOK}) that can have a title, an author,
|
||||
+ * Represents a {@link Material#WRITTEN_BOOK} that can have a title, an author,
|
||||
* and pages.
|
||||
+ * <p>
|
||||
+ * Before using this type, make sure to check the itemstack's material with
|
||||
+ * {@link org.bukkit.inventory.ItemStack#getType()}. {@code instanceof} on
|
||||
+ * the meta instance is not sufficient due to unusual inheritance
|
||||
+ * with relation to {@link WritableBookMeta}.
|
||||
*/
|
||||
-public interface BookMeta extends WritableBookMeta {
|
||||
+public interface BookMeta extends WritableBookMeta, net.kyori.adventure.inventory.Book { // Paper - adventure
|
||||
|
||||
/**
|
||||
* Represents the generation (or level of copying) of a written book
|
||||
@@ -116,6 +121,153 @@ public interface BookMeta extends WritableBookMeta {
|
||||
@NotNull
|
||||
BookMeta clone();
|
||||
|
||||
+ // Paper start - adventure
|
||||
+ //<editor-fold desc="deprecations" defaultstate="collapsed">
|
||||
+ /**
|
||||
+ * @deprecated use {@link #page(int)}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ @Override
|
||||
+ @NotNull String getPage(int page);
|
||||
+
|
||||
+ /**
|
||||
+ * @deprecated use {@link #page(int, net.kyori.adventure.text.Component)}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ @Override
|
||||
+ void setPage(int page, @NotNull String data);
|
||||
+
|
||||
+ /**
|
||||
+ * @deprecated use {@link #pages()}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ @Override
|
||||
+ @NotNull List<String> getPages();
|
||||
+
|
||||
+ /**
|
||||
+ * @deprecated use {@link #pages(List)}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ @Override
|
||||
+ void setPages(@NotNull List<String> pages);
|
||||
+
|
||||
+ /**
|
||||
+ * @deprecated use {@link #pages(net.kyori.adventure.text.Component...)}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ @Override
|
||||
+ void setPages(@NotNull String... pages);
|
||||
+
|
||||
+ /**
|
||||
+ * @deprecated use {@link #addPages(net.kyori.adventure.text.Component...)}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ @Override
|
||||
+ void addPage(@NotNull String... pages);
|
||||
+ //</editor-fold>
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the title of the book.
|
||||
+ * <p>
|
||||
+ * Plugins should check that hasTitle() returns true before calling this
|
||||
+ * method.
|
||||
+ *
|
||||
+ * @return the title of the book
|
||||
+ */
|
||||
+ @Override
|
||||
+ net.kyori.adventure.text.@Nullable Component title();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the title of the book.
|
||||
+ * <p>
|
||||
+ * Limited to 32 characters. Removes title when given null.
|
||||
+ *
|
||||
+ * @param title the title to set
|
||||
+ * @return the same {@link BookMeta} instance
|
||||
+ */
|
||||
+ @org.jetbrains.annotations.Contract(value = "_ -> this", pure = false)
|
||||
+ @Override
|
||||
+ @NotNull BookMeta title(net.kyori.adventure.text.@Nullable Component title);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the author of the book.
|
||||
+ * <p>
|
||||
+ * Plugins should check that hasAuthor() returns true before calling this
|
||||
+ * method.
|
||||
+ *
|
||||
+ * @return the author of the book
|
||||
+ */
|
||||
+ @Override
|
||||
+ net.kyori.adventure.text.@Nullable Component author();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the author of the book. Removes author when given null.
|
||||
+ *
|
||||
+ * @param author the author to set
|
||||
+ * @return the same {@link BookMeta} instance
|
||||
+ */
|
||||
+ @org.jetbrains.annotations.Contract(value = "_ -> this", pure = false)
|
||||
+ @Override
|
||||
+ @NotNull BookMeta author(net.kyori.adventure.text.@Nullable Component author);
|
||||
+
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the specified page in the book. The page must exist.
|
||||
+ * <p>
|
||||
+ * Pages are 1-indexed.
|
||||
+ *
|
||||
+ * @param page the page number to get, in range [1, getPageCount()]
|
||||
+ * @return the page from the book
|
||||
+ */
|
||||
+ net.kyori.adventure.text.@NotNull Component page(int page);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the specified page in the book. Pages of the book must be
|
||||
+ * contiguous.
|
||||
+ * <p>
|
||||
+ * The data can be up to 1024 characters in length, additional characters
|
||||
+ * are truncated.
|
||||
+ * <p>
|
||||
+ * Pages are 1-indexed.
|
||||
+ *
|
||||
+ * @param page the page number to set, in range [1, getPageCount()]
|
||||
+ * @param data the data to set for that page
|
||||
+ */
|
||||
+ void page(int page, net.kyori.adventure.text.@NotNull Component data);
|
||||
+
|
||||
+ /**
|
||||
+ * Adds new pages to the end of the book. Up to a maximum of 100 pages with
|
||||
+ * 1024 characters per page.
|
||||
+ *
|
||||
+ * @param pages A list of strings, each being a page
|
||||
+ */
|
||||
+ void addPages(net.kyori.adventure.text.@NotNull Component @NotNull ... pages);
|
||||
+
|
||||
+ interface BookMetaBuilder extends net.kyori.adventure.inventory.Book.Builder {
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMetaBuilder title(net.kyori.adventure.text.@Nullable Component title);
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMetaBuilder author(net.kyori.adventure.text.@Nullable Component author);
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMetaBuilder addPage(net.kyori.adventure.text.@NotNull Component page);
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMetaBuilder pages(net.kyori.adventure.text.@NotNull Component @NotNull ... pages);
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMetaBuilder pages(java.util.@NotNull Collection<net.kyori.adventure.text.Component> pages);
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMeta build();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMetaBuilder toBuilder();
|
||||
+ // Paper end
|
||||
+
|
||||
// Spigot start
|
||||
public class Spigot {
|
||||
|
||||
@@ -124,8 +276,10 @@ public interface BookMeta extends WritableBookMeta {
|
||||
*
|
||||
* @param page the page number to get
|
||||
* @return the page from the book
|
||||
@ -4372,7 +4544,7 @@ index 9bab73c3c2ca759b8e1c7d07d98cc593c961666a..7cc66e5dd6f19295728d3c0e6c089833
|
||||
public BaseComponent[] getPage(int page) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
@@ -139,7 +141,9 @@ public interface BookMeta extends WritableBookMeta {
|
||||
@@ -139,7 +293,9 @@ public interface BookMeta extends WritableBookMeta {
|
||||
*
|
||||
* @param page the page number to set
|
||||
* @param data the data to set for that page
|
||||
@ -4382,7 +4554,7 @@ index 9bab73c3c2ca759b8e1c7d07d98cc593c961666a..7cc66e5dd6f19295728d3c0e6c089833
|
||||
public void setPage(int page, @Nullable BaseComponent... data) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
@@ -148,8 +152,10 @@ public interface BookMeta extends WritableBookMeta {
|
||||
@@ -148,8 +304,10 @@ public interface BookMeta extends WritableBookMeta {
|
||||
* Gets all the pages in the book.
|
||||
*
|
||||
* @return list of all the pages in the book
|
||||
@ -4393,7 +4565,7 @@ index 9bab73c3c2ca759b8e1c7d07d98cc593c961666a..7cc66e5dd6f19295728d3c0e6c089833
|
||||
public List<BaseComponent[]> getPages() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
@@ -159,7 +165,9 @@ public interface BookMeta extends WritableBookMeta {
|
||||
@@ -159,7 +317,9 @@ public interface BookMeta extends WritableBookMeta {
|
||||
* pages. Maximum 50 pages with 256 characters per page.
|
||||
*
|
||||
* @param pages A list of pages to set the book to use
|
||||
@ -4403,7 +4575,7 @@ index 9bab73c3c2ca759b8e1c7d07d98cc593c961666a..7cc66e5dd6f19295728d3c0e6c089833
|
||||
public void setPages(@NotNull List<BaseComponent[]> pages) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
@@ -169,7 +177,9 @@ public interface BookMeta extends WritableBookMeta {
|
||||
@@ -169,7 +329,9 @@ public interface BookMeta extends WritableBookMeta {
|
||||
* pages. Maximum 50 pages with 256 characters per page.
|
||||
*
|
||||
* @param pages A list of component arrays, each being a page
|
||||
@ -4413,7 +4585,7 @@ index 9bab73c3c2ca759b8e1c7d07d98cc593c961666a..7cc66e5dd6f19295728d3c0e6c089833
|
||||
public void setPages(@NotNull BaseComponent[]... pages) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
@@ -179,7 +189,9 @@ public interface BookMeta extends WritableBookMeta {
|
||||
@@ -179,7 +341,9 @@ public interface BookMeta extends WritableBookMeta {
|
||||
* with 256 characters per page.
|
||||
*
|
||||
* @param pages A list of component arrays, each being a page
|
||||
@ -4518,188 +4690,26 @@ index 255f79d5bca15620cb17d7b54ffebb6ff00bff6b..d7c178b3584db5866a5a21c6ddaab876
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/inventory/meta/WritableBookMeta.java b/src/main/java/org/bukkit/inventory/meta/WritableBookMeta.java
|
||||
index 12595536080ffe09df2b6ecdb83d846f50100d38..dec77fc3aff1baf21aeff8d8d681a46f597935c9 100644
|
||||
index 12595536080ffe09df2b6ecdb83d846f50100d38..9fc47c879ee6b8edf2503f20e4736c2997d2de2e 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/meta/WritableBookMeta.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/meta/WritableBookMeta.java
|
||||
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Represents a book ({@link Material#WRITABLE_BOOK} or {@link
|
||||
* Material#WRITTEN_BOOK}) that can have pages.
|
||||
@@ -5,8 +5,14 @@ import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
- * Represents a book ({@link Material#WRITABLE_BOOK} or {@link
|
||||
- * Material#WRITTEN_BOOK}) that can have pages.
|
||||
+ * Represents a book ({@link Material#WRITABLE_BOOK}) that can have pages.
|
||||
+ * <p>
|
||||
+ * For {@link Material#WRITTEN_BOOK}, use {@link BookMeta}.
|
||||
+ * <p>
|
||||
+ * Before using this type, make sure to check the itemstack's material with
|
||||
+ * {@link org.bukkit.inventory.ItemStack#getType()}. {@code instanceof} on
|
||||
+ * the meta instance is not sufficient due to unusual inheritance
|
||||
+ * with relation to {@link BookMeta}.
|
||||
*/
|
||||
-public interface WritableBookMeta extends ItemMeta {
|
||||
+public interface WritableBookMeta extends ItemMeta, net.kyori.adventure.inventory.Book { // Paper
|
||||
public interface WritableBookMeta extends ItemMeta {
|
||||
|
||||
/**
|
||||
* Checks for the existence of pages in the book.
|
||||
@@ -17,6 +17,108 @@ public interface WritableBookMeta extends ItemMeta {
|
||||
*/
|
||||
boolean hasPages();
|
||||
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Gets the title of the book.
|
||||
+ * <p>
|
||||
+ * Plugins should check that hasTitle() returns true before calling this
|
||||
+ * method.
|
||||
+ *
|
||||
+ * @return the title of the book
|
||||
+ */
|
||||
+ @Override
|
||||
+ net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component title();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the title of the book.
|
||||
+ * <p>
|
||||
+ * Limited to 32 characters. Removes title when given null.
|
||||
+ *
|
||||
+ * @param title the title to set
|
||||
+ * @return the same {@link BookMeta} instance
|
||||
+ */
|
||||
+ @org.jetbrains.annotations.Contract(value = "_ -> this", pure = false)
|
||||
+ @Override
|
||||
+ @NotNull BookMeta title(net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component title);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the author of the book.
|
||||
+ * <p>
|
||||
+ * Plugins should check that hasAuthor() returns true before calling this
|
||||
+ * method.
|
||||
+ *
|
||||
+ * @return the author of the book
|
||||
+ */
|
||||
+ @Override
|
||||
+ net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component author();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the author of the book. Removes author when given null.
|
||||
+ *
|
||||
+ * @param author the author to set
|
||||
+ * @return the same {@link BookMeta} instance
|
||||
+ */
|
||||
+ @org.jetbrains.annotations.Contract(value = "_ -> this", pure = false)
|
||||
+ @Override
|
||||
+ @NotNull BookMeta author(net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component author);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the specified page in the book. The page must exist.
|
||||
+ * <p>
|
||||
+ * Pages are 1-indexed.
|
||||
+ *
|
||||
+ * @param page the page number to get, in range [1, getPageCount()]
|
||||
+ * @return the page from the book
|
||||
+ */
|
||||
+ net.kyori.adventure.text.@NotNull Component page(int page);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the specified page in the book. Pages of the book must be
|
||||
+ * contiguous.
|
||||
+ * <p>
|
||||
+ * The data can be up to 1024 characters in length, additional characters
|
||||
+ * are truncated.
|
||||
+ * <p>
|
||||
+ * Pages are 1-indexed.
|
||||
+ *
|
||||
+ * @param page the page number to set, in range [1, getPageCount()]
|
||||
+ * @param data the data to set for that page
|
||||
+ */
|
||||
+ void page(int page, net.kyori.adventure.text.@NotNull Component data);
|
||||
+
|
||||
+ /**
|
||||
+ * Adds new pages to the end of the book. Up to a maximum of 100 pages with
|
||||
+ * 1024 characters per page.
|
||||
+ *
|
||||
+ * @param pages A list of strings, each being a page
|
||||
+ */
|
||||
+ void addPages(net.kyori.adventure.text.@NotNull Component @NotNull ... pages);
|
||||
+
|
||||
+ interface BookMetaBuilder extends net.kyori.adventure.inventory.Book.Builder {
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMetaBuilder title(net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component title);
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMetaBuilder author(net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component author);
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMetaBuilder addPage(net.kyori.adventure.text.@NotNull Component page);
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMetaBuilder pages(net.kyori.adventure.text.@NotNull Component @NotNull ... pages);
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMetaBuilder pages(java.util.@NotNull Collection<net.kyori.adventure.text.Component> pages);
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMeta build();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull BookMetaBuilder toBuilder();
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Gets the specified page in the book. The given page must exist.
|
||||
* <p>
|
||||
@@ -24,8 +126,10 @@ public interface WritableBookMeta extends ItemMeta {
|
||||
*
|
||||
* @param page the page number to get, in range [1, getPageCount()]
|
||||
* @return the page from the book
|
||||
+ * @deprecated in favour of {@link #page(int)}
|
||||
*/
|
||||
@NotNull
|
||||
+ @Deprecated // Paper
|
||||
String getPage(int page);
|
||||
|
||||
/**
|
||||
@@ -39,15 +143,19 @@ public interface WritableBookMeta extends ItemMeta {
|
||||
*
|
||||
* @param page the page number to set, in range [1, getPageCount()]
|
||||
* @param data the data to set for that page
|
||||
+ * @deprecated in favour of {@link #page(int, net.kyori.adventure.text.Component)}
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
void setPage(int page, @NotNull String data);
|
||||
|
||||
/**
|
||||
* Gets all the pages in the book.
|
||||
*
|
||||
* @return list of all the pages in the book
|
||||
+ * @deprecated in favour of {@link #pages()}
|
||||
*/
|
||||
@NotNull
|
||||
+ @Deprecated // Paper
|
||||
List<String> getPages();
|
||||
|
||||
/**
|
||||
@@ -55,7 +163,9 @@ public interface WritableBookMeta extends ItemMeta {
|
||||
* pages. Maximum 100 pages with 1024 characters per page.
|
||||
*
|
||||
* @param pages A list of pages to set the book to use
|
||||
+ * @deprecated in favour of {@link #pages(List)}
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
void setPages(@NotNull List<String> pages);
|
||||
|
||||
/**
|
||||
@@ -63,7 +173,9 @@ public interface WritableBookMeta extends ItemMeta {
|
||||
* pages. Maximum 100 pages with 1024 characters per page.
|
||||
*
|
||||
* @param pages A list of strings, each being a page
|
||||
+ * @deprecated in favour of {@link #pages(net.kyori.adventure.text.Component...)}
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
void setPages(@NotNull String... pages);
|
||||
|
||||
/**
|
||||
@@ -71,7 +183,9 @@ public interface WritableBookMeta extends ItemMeta {
|
||||
* 1024 characters per page.
|
||||
*
|
||||
* @param pages A list of strings, each being a page
|
||||
+ * @deprecated in favour of {@link #addPages(net.kyori.adventure.text.Component...)}
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
void addPage(@NotNull String... pages);
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java b/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java
|
||||
index eb80f24da65918a21a2fa6691eeb64b621febaf4..941fac4eee338870d8c30cb1f64cab572cf54548 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java
|
||||
@ -5028,7 +5038,7 @@ index 78fd35e6115072c6bc2ff5a899ffc2edb8f45801..22b1dc5fd4d453161a5ee520072f8e8f
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/scoreboard/Scoreboard.java b/src/main/java/org/bukkit/scoreboard/Scoreboard.java
|
||||
index bf52375e9ed9ec172eca1d27c06c379e3fc216bc..e6aeb01e80fb63a4ebd6a7cbda1815e49775246d 100644
|
||||
index bf52375e9ed9ec172eca1d27c06c379e3fc216bc..3377511e1a6dd4aeb78871e47169d5bd9456c1aa 100644
|
||||
--- a/src/main/java/org/bukkit/scoreboard/Scoreboard.java
|
||||
+++ b/src/main/java/org/bukkit/scoreboard/Scoreboard.java
|
||||
@@ -26,6 +26,71 @@ public interface Scoreboard {
|
||||
@ -5103,7 +5113,7 @@ index bf52375e9ed9ec172eca1d27c06c379e3fc216bc..e6aeb01e80fb63a4ebd6a7cbda1815e4
|
||||
/**
|
||||
* Registers an Objective on this Scoreboard
|
||||
*
|
||||
@@ -37,10 +102,11 @@ public interface Scoreboard {
|
||||
@@ -37,7 +102,7 @@ public interface Scoreboard {
|
||||
* characters.
|
||||
* @throws IllegalArgumentException if an objective by that name already
|
||||
* exists
|
||||
@ -5112,11 +5122,7 @@ index bf52375e9ed9ec172eca1d27c06c379e3fc216bc..e6aeb01e80fb63a4ebd6a7cbda1815e4
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
+ @Deprecated // Paper
|
||||
Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @NotNull String displayName);
|
||||
|
||||
/**
|
||||
@@ -55,10 +121,11 @@ public interface Scoreboard {
|
||||
@@ -55,7 +120,7 @@ public interface Scoreboard {
|
||||
* characters.
|
||||
* @throws IllegalArgumentException if an objective by that name already
|
||||
* exists
|
||||
@ -5125,11 +5131,7 @@ index bf52375e9ed9ec172eca1d27c06c379e3fc216bc..e6aeb01e80fb63a4ebd6a7cbda1815e4
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
+ @Deprecated // Paper
|
||||
Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @NotNull String displayName, @NotNull RenderType renderType);
|
||||
|
||||
/**
|
||||
@@ -72,8 +139,10 @@ public interface Scoreboard {
|
||||
@@ -72,8 +137,10 @@ public interface Scoreboard {
|
||||
* characters.
|
||||
* @throws IllegalArgumentException if an objective by that name already
|
||||
* exists
|
||||
@ -5140,7 +5142,7 @@ index bf52375e9ed9ec172eca1d27c06c379e3fc216bc..e6aeb01e80fb63a4ebd6a7cbda1815e4
|
||||
Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName);
|
||||
|
||||
/**
|
||||
@@ -88,8 +157,10 @@ public interface Scoreboard {
|
||||
@@ -88,8 +155,10 @@ public interface Scoreboard {
|
||||
* characters.
|
||||
* @throws IllegalArgumentException if an objective by that name already
|
||||
* exists
|
||||
|
@ -968,7 +968,7 @@ index 53119742beda00a38111063243665bb995ae2188..2d084214e991fecc51f8e18e3d733e43
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
diff --git a/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java b/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java
|
||||
index f2edd4a9357832e9dec3fb0aafa006335d7b289b..378b44c3df1612283c7f993b32fc7b329ec01a9a 100644
|
||||
index f2edd4a9357832e9dec3fb0aafa006335d7b289b..f05ce4fd6c4bbd79edc5f65e7edd1e4a63e93fb8 100644
|
||||
--- a/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java
|
||||
@@ -23,7 +23,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab
|
||||
@ -980,15 +980,7 @@ index f2edd4a9357832e9dec3fb0aafa006335d7b289b..378b44c3df1612283c7f993b32fc7b32
|
||||
super(view);
|
||||
this.enchanter = enchanter;
|
||||
this.table = table;
|
||||
@@ -68,6 +68,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab
|
||||
* @return experience level costs offered
|
||||
* @deprecated Use {@link #getOffers()} instead of this method
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public int[] getExpLevelCostsOffered() {
|
||||
@@ -86,8 +87,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab
|
||||
@@ -86,8 +86,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab
|
||||
*
|
||||
* @return list of available enchantment offers
|
||||
*/
|
||||
@ -1851,18 +1843,6 @@ index 3e46603f8cd38041394e0e1baf788d9009b3ffc7..b15c141f1db07296bb349f11c6f39b0f
|
||||
public interface Redstone {
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/material/Step.java b/src/main/java/org/bukkit/material/Step.java
|
||||
index ea94222120ddd4e692b67cf48b029af9ed0e5835..7e49f254032a8a1cf864372a246a49dda6f773c7 100644
|
||||
--- a/src/main/java/org/bukkit/material/Step.java
|
||||
+++ b/src/main/java/org/bukkit/material/Step.java
|
||||
@@ -78,6 +78,7 @@ public class Step extends TexturedMaterial {
|
||||
*
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
@Override
|
||||
@Deprecated
|
||||
protected int getTextureIndex() {
|
||||
diff --git a/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java b/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java
|
||||
index 0ea9c6b2420a0f990bd1fdf50fc015e37a7060d8..e99644eae1c662b117aa19060d2484aca19fe0a4 100644
|
||||
--- a/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java
|
||||
|
@ -37,10 +37,10 @@ index a625bcab8e77b05b3341a52c708fae1542b7e3d5..a193ffabb05160b462dee1ba8f687fdb
|
||||
+ // Paper end - improve scoreboard entries
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/scoreboard/Scoreboard.java b/src/main/java/org/bukkit/scoreboard/Scoreboard.java
|
||||
index e6aeb01e80fb63a4ebd6a7cbda1815e49775246d..51bc41ed8ea46a20372065e1e29488dffef796c1 100644
|
||||
index 3377511e1a6dd4aeb78871e47169d5bd9456c1aa..4a59f2734833cf39800b9aafbc1c5c6953c2d8f3 100644
|
||||
--- a/src/main/java/org/bukkit/scoreboard/Scoreboard.java
|
||||
+++ b/src/main/java/org/bukkit/scoreboard/Scoreboard.java
|
||||
@@ -217,9 +217,8 @@ public interface Scoreboard {
|
||||
@@ -215,9 +215,8 @@ public interface Scoreboard {
|
||||
* @param player the player whose scores are being retrieved
|
||||
* @return immutable set of all scores tracked for the player
|
||||
* @see #getScores(String)
|
||||
@ -51,7 +51,7 @@ index e6aeb01e80fb63a4ebd6a7cbda1815e49775246d..51bc41ed8ea46a20372065e1e29488df
|
||||
@NotNull
|
||||
Set<Score> getScores(@NotNull OfflinePlayer player);
|
||||
|
||||
@@ -237,9 +236,8 @@ public interface Scoreboard {
|
||||
@@ -235,9 +234,8 @@ public interface Scoreboard {
|
||||
*
|
||||
* @param player the player to drop all current scores for
|
||||
* @see #resetScores(String)
|
||||
@ -62,7 +62,7 @@ index e6aeb01e80fb63a4ebd6a7cbda1815e49775246d..51bc41ed8ea46a20372065e1e29488df
|
||||
void resetScores(@NotNull OfflinePlayer player);
|
||||
|
||||
/**
|
||||
@@ -255,9 +253,8 @@ public interface Scoreboard {
|
||||
@@ -253,9 +251,8 @@ public interface Scoreboard {
|
||||
* @param player the player to search for
|
||||
* @return the player's Team or null if the player is not on a team
|
||||
* @see #getEntryTeam(String)
|
||||
@ -73,7 +73,7 @@ index e6aeb01e80fb63a4ebd6a7cbda1815e49775246d..51bc41ed8ea46a20372065e1e29488df
|
||||
@Nullable
|
||||
Team getPlayerTeam(@NotNull OfflinePlayer player);
|
||||
|
||||
@@ -322,4 +319,35 @@ public interface Scoreboard {
|
||||
@@ -320,4 +317,35 @@ public interface Scoreboard {
|
||||
* @param slot the slot to remove objectives
|
||||
*/
|
||||
void clearSlot(@NotNull DisplaySlot slot);
|
||||
|
@ -4806,7 +4806,7 @@ index 9e05a8515c5f6f340182e91150fcad8bbf80a22b..adf22ce4f0bcd3bd57dc2030c6c92d3d
|
||||
@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 61ad00c38cfef8a1de61b4597ec1042428feccf4..4c308de19e26b228151dc05606dd6339649e1765 100644
|
||||
index 61ad00c38cfef8a1de61b4597ec1042428feccf4..4da38ebb7fdbdb0f8fa422ebcd2e3eec2b2be846 100644
|
||||
--- a/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;
|
||||
@ -4820,13 +4820,213 @@ index 61ad00c38cfef8a1de61b4597ec1042428feccf4..4c308de19e26b228151dc05606dd6339
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -170,6 +171,148 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta, WritableBo
|
||||
@@ -170,6 +171,130 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta, WritableBo
|
||||
public void setGeneration(Generation generation) {
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.Component title() {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.meta.BookMeta title(net.kyori.adventure.text.Component title) {
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.Component author() {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.meta.BookMeta author(net.kyori.adventure.text.Component author) {
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.Component page(final int page) {
|
||||
+ Preconditions.checkArgument(this.isValidPage(page), "Invalid page number");
|
||||
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.pages.get(page - 1));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void page(final int page, net.kyori.adventure.text.Component data) {
|
||||
+ if (!this.isValidPage(page)) {
|
||||
+ throw new IllegalArgumentException("Invalid page number " + page + "/" + this.pages.size());
|
||||
+ }
|
||||
+ if (data == null) {
|
||||
+ data = net.kyori.adventure.text.Component.empty();
|
||||
+ }
|
||||
+ this.pages.set(page - 1, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(data));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<net.kyori.adventure.text.Component> pages() {
|
||||
+ if (this.pages == null) return ImmutableList.of();
|
||||
+ return this.pages.stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::deserialize).collect(ImmutableList.toImmutableList());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMeta pages(List<net.kyori.adventure.text.Component> pages) {
|
||||
+ if (this.pages != null) this.pages.clear();
|
||||
+ for (net.kyori.adventure.text.Component page : pages) {
|
||||
+ this.addPages(page);
|
||||
+ }
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMeta pages(net.kyori.adventure.text.Component... pages) {
|
||||
+ if (this.pages != null) this.pages.clear();
|
||||
+ this.addPages(pages);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void addPages(net.kyori.adventure.text.Component... pages) {
|
||||
+ if (this.pages == null) this.pages = new ArrayList<>();
|
||||
+ for (net.kyori.adventure.text.Component page : pages) {
|
||||
+ if (this.pages.size() >= MAX_PAGES) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (page == null) {
|
||||
+ page = net.kyori.adventure.text.Component.empty();
|
||||
+ }
|
||||
+
|
||||
+ this.pages.add(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(page));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private CraftMetaBook(List<net.kyori.adventure.text.Component> pages) {
|
||||
+ super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(org.bukkit.Material.WRITABLE_BOOK));
|
||||
+ 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());
|
||||
+ }
|
||||
+
|
||||
+ static class CraftMetaBookBuilder implements BookMetaBuilder {
|
||||
+ protected final List<net.kyori.adventure.text.Component> pages = new java.util.ArrayList<>();
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder title(net.kyori.adventure.text.Component title) {
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder author(net.kyori.adventure.text.Component author) {
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder addPage(net.kyori.adventure.text.Component page) {
|
||||
+ this.pages.add(page);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder pages(net.kyori.adventure.text.Component... pages) {
|
||||
+ java.util.Collections.addAll(this.pages, pages);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder pages(java.util.Collection<net.kyori.adventure.text.Component> pages) {
|
||||
+ this.pages.addAll(pages);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMeta build() {
|
||||
+ return new CraftMetaBook(this.pages);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder toBuilder() {
|
||||
+ return new CraftMetaBookBuilder();
|
||||
+ }
|
||||
+
|
||||
+ // Paper end
|
||||
@Override
|
||||
public String getPage(final int page) {
|
||||
Preconditions.checkArgument(this.isValidPage(page), "Invalid page number (%s)", page);
|
||||
@@ -286,7 +411,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta, WritableBo
|
||||
}
|
||||
|
||||
@Override
|
||||
- Builder<String, Object> serialize(Builder<String, Object> builder) {
|
||||
+ ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
|
||||
super.serialize(builder);
|
||||
|
||||
if (this.pages != null) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
|
||||
index 9c57b883783145ad4483481a2c2e7f0f188cd174..b653c2c80e8e8524ea6d7625c6a86f8204c50709 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
|
||||
@@ -2,7 +2,7 @@ package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
-import com.google.common.collect.ImmutableMap.Builder;
|
||||
+import com.google.common.collect.ImmutableMap; // Paper
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -346,7 +346,7 @@ public class CraftMetaBookSigned extends CraftMetaItem implements BookMeta {
|
||||
}
|
||||
|
||||
@Override
|
||||
- Builder<String, Object> serialize(Builder<String, Object> builder) {
|
||||
+ ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
|
||||
super.serialize(builder);
|
||||
|
||||
if (this.hasTitle()) {
|
||||
@@ -459,4 +459,113 @@ public class CraftMetaBookSigned extends CraftMetaItem implements BookMeta {
|
||||
return this.spigot;
|
||||
}
|
||||
// Spigot end
|
||||
+
|
||||
+ // Paper start - adventure
|
||||
+ public 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 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));
|
||||
+ this.title = title == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(title);
|
||||
+ this.author = author == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(author);
|
||||
+ this.pages = io.papermc.paper.adventure.PaperAdventure.asVanilla(pages.subList(0, Math.min(MAX_PAGES, pages.size())));
|
||||
+ }
|
||||
+
|
||||
+ static final class CraftMetaBookSignedBuilder extends CraftMetaBook.CraftMetaBookBuilder {
|
||||
+ private net.kyori.adventure.text.Component title;
|
||||
+ private net.kyori.adventure.text.Component author;
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.meta.BookMeta.BookMetaBuilder title(final net.kyori.adventure.text.Component title) {
|
||||
+ this.title = title;
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.meta.BookMeta.BookMetaBuilder author(final net.kyori.adventure.text.Component author) {
|
||||
+ this.author = author;
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.meta.BookMeta build() {
|
||||
+ return new CraftMetaBookSigned(this.title, this.author, this.pages);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder toBuilder() {
|
||||
+ return new CraftMetaBookSignedBuilder();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.Component title() {
|
||||
+ return this.title == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.deserialize(this.title);
|
||||
+ }
|
||||
+
|
||||
@ -4849,35 +5049,29 @@ index 61ad00c38cfef8a1de61b4597ec1042428feccf4..4c308de19e26b228151dc05606dd6339
|
||||
+
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.Component page(final int page) {
|
||||
+ Preconditions.checkArgument(isValidPage(page), "Invalid page number");
|
||||
+ return this instanceof CraftMetaBookSigned ? net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(pages.get(page - 1)) : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(pages.get(page - 1));
|
||||
+ Preconditions.checkArgument(this.isValidPage(page), "Invalid page number");
|
||||
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.pages.get(page - 1));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void page(final int page, net.kyori.adventure.text.Component data) {
|
||||
+ if (!isValidPage(page)) {
|
||||
+ throw new IllegalArgumentException("Invalid page number " + page + "/" + pages.size());
|
||||
+ if (!this.isValidPage(page)) {
|
||||
+ throw new IllegalArgumentException("Invalid page number " + page + "/" + this.pages.size());
|
||||
+ }
|
||||
+ if (data == null) {
|
||||
+ data = net.kyori.adventure.text.Component.empty();
|
||||
+ }
|
||||
+ pages.set(page - 1, this instanceof CraftMetaBookSigned ? net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().serialize(data) : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(data));
|
||||
+ this.pages.set(page - 1, io.papermc.paper.adventure.PaperAdventure.asVanillaNullToEmpty(data));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<net.kyori.adventure.text.Component> pages() {
|
||||
+ if (this.pages == null) return ImmutableList.of();
|
||||
+ if (this instanceof CraftMetaBookSigned)
|
||||
+ return pages.stream().map(net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson()::deserialize).collect(ImmutableList.toImmutableList());
|
||||
+ else
|
||||
+ return pages.stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::deserialize).collect(ImmutableList.toImmutableList());
|
||||
+ return this.pages.stream().map(io.papermc.paper.adventure.PaperAdventure::asAdventure).collect(ImmutableList.toImmutableList());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMeta pages(List<net.kyori.adventure.text.Component> pages) {
|
||||
+ if (this.pages != null) this.pages.clear();
|
||||
+ for (net.kyori.adventure.text.Component page : pages) {
|
||||
+ addPages(page);
|
||||
+ this.addPages(page);
|
||||
+ }
|
||||
+ return this;
|
||||
+ }
|
||||
@ -4885,7 +5079,7 @@ index 61ad00c38cfef8a1de61b4597ec1042428feccf4..4c308de19e26b228151dc05606dd6339
|
||||
+ @Override
|
||||
+ public BookMeta pages(net.kyori.adventure.text.Component... pages) {
|
||||
+ if (this.pages != null) this.pages.clear();
|
||||
+ addPages(pages);
|
||||
+ this.addPages(pages);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
@ -4897,133 +5091,9 @@ index 61ad00c38cfef8a1de61b4597ec1042428feccf4..4c308de19e26b228151dc05606dd6339
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (page == null) {
|
||||
+ page = net.kyori.adventure.text.Component.empty();
|
||||
+ }
|
||||
+
|
||||
+ this.pages.add(this instanceof CraftMetaBookSigned ? net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().serialize(page) : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(page));
|
||||
+ this.pages.add(io.papermc.paper.adventure.PaperAdventure.asVanillaNullToEmpty(page));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public 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) {
|
||||
+ super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(org.bukkit.Material.WRITABLE_BOOK));
|
||||
+ this.title = title == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(title);
|
||||
+ 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());
|
||||
+ }
|
||||
+
|
||||
+ static class CraftMetaBookBuilder implements BookMetaBuilder {
|
||||
+ private net.kyori.adventure.text.Component title = null;
|
||||
+ private net.kyori.adventure.text.Component author = null;
|
||||
+ private final List<net.kyori.adventure.text.Component> pages = new java.util.ArrayList<>();
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder title(net.kyori.adventure.text.Component title) {
|
||||
+ this.title = title;
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder author(net.kyori.adventure.text.Component author) {
|
||||
+ this.author = author;
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder addPage(net.kyori.adventure.text.Component page) {
|
||||
+ this.pages.add(page);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder pages(net.kyori.adventure.text.Component... pages) {
|
||||
+ java.util.Collections.addAll(this.pages, pages);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder pages(java.util.Collection<net.kyori.adventure.text.Component> pages) {
|
||||
+ this.pages.addAll(pages);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMeta build() {
|
||||
+ return this.build(title, author, pages);
|
||||
+ }
|
||||
+
|
||||
+ protected BookMeta build(net.kyori.adventure.text.Component title, net.kyori.adventure.text.Component author, java.util.List<net.kyori.adventure.text.Component> pages) {
|
||||
+ return new CraftMetaBook(title, author, pages);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder toBuilder() {
|
||||
+ return new CraftMetaBookBuilder();
|
||||
+ }
|
||||
+
|
||||
+ // Paper end
|
||||
@Override
|
||||
public String getPage(final int page) {
|
||||
Preconditions.checkArgument(this.isValidPage(page), "Invalid page number (%s)", page);
|
||||
@@ -286,7 +429,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta, WritableBo
|
||||
}
|
||||
|
||||
@Override
|
||||
- Builder<String, Object> serialize(Builder<String, Object> builder) {
|
||||
+ ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
|
||||
super.serialize(builder);
|
||||
|
||||
if (this.pages != null) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
|
||||
index 9c57b883783145ad4483481a2c2e7f0f188cd174..3795207a024ddf2e93baa09bcce56a1253eec8ed 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
|
||||
@@ -2,7 +2,7 @@ package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
-import com.google.common.collect.ImmutableMap.Builder;
|
||||
+import com.google.common.collect.ImmutableMap; // Paper
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -346,7 +346,7 @@ public class CraftMetaBookSigned extends CraftMetaItem implements BookMeta {
|
||||
}
|
||||
|
||||
@Override
|
||||
- Builder<String, Object> serialize(Builder<String, Object> builder) {
|
||||
+ ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
|
||||
super.serialize(builder);
|
||||
|
||||
if (this.hasTitle()) {
|
||||
@@ -459,4 +459,25 @@ public class CraftMetaBookSigned extends CraftMetaItem implements BookMeta {
|
||||
return this.spigot;
|
||||
}
|
||||
// Spigot end
|
||||
+
|
||||
+ // 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) {
|
||||
+ super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(Material.WRITABLE_BOOK));
|
||||
+ this.title = title == null ? null : CraftMetaBook.LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(title);
|
||||
+ this.author = author == null ? null : CraftMetaBook.LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(author);
|
||||
+ this.pages = io.papermc.paper.adventure.PaperAdventure.asVanilla(pages.subList(0, Math.min(MAX_PAGES, pages.size())));
|
||||
+ }
|
||||
+
|
||||
+ static final class CraftMetaBookSignedBuilder extends CraftMetaBook.CraftMetaBookBuilder {
|
||||
+ @Override
|
||||
+ protected BookMeta build(net.kyori.adventure.text.Component title, net.kyori.adventure.text.Component author, java.util.List<net.kyori.adventure.text.Component> pages) {
|
||||
+ return new CraftMetaBookSigned(title, author, pages);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BookMetaBuilder toBuilder() {
|
||||
+ return new CraftMetaBookSignedBuilder();
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren