Skip to content

Commit

Permalink
Fix Book's incomplete mata bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Aug 13, 2023
1 parent c5d92ab commit 3f8251b
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringTag;
import net.minecraft.network.chat.Component;
import org.apache.commons.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.configuration.serialization.DelegateDeserialization;
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftMetaItem.SerializableMeta;
Expand All @@ -18,6 +19,7 @@
import org.bukkit.inventory.meta.BookMeta;
import org.spigotmc.ValidateUtils;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -450,8 +452,6 @@ private String componentsToPage(BaseComponent[] components) {
return CraftChatMessage.fromJSONComponent(ComponentSerializer.toString(components));
}
}

/**
@Override
public BaseComponent[] getPage(final int page) {
Validate.isTrue(isValidPage(page), "Invalid page number");
Expand All @@ -475,7 +475,7 @@ public void addPage(final BaseComponent[]... pages) {
if (page == null) {
page = new BaseComponent[0];
}
CraftMetaBook.this.pages.add(componentsToPage(page));
CraftMetaBook.this.internalAddPage(componentsToPage(page));
}
}
@Override
Expand Down Expand Up @@ -506,7 +506,7 @@ public void setPages(List<BaseComponent[]> pages) {
for (BaseComponent[] page : pages) {
addPage(page);
}
}*/
}
};

@Override
Expand Down
66 changes: 65 additions & 1 deletion src/main/java/org/bukkit/inventory/meta/BookMeta.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.bukkit.inventory.meta;

import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Material;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -186,10 +187,73 @@ enum Generation {
@Override
@NotNull
BookMeta clone();

// Spigot start
public class Spigot {

/**
* Gets the specified page in the book. The given page must exist.
*
* @param page the page number to get
* @return the page from the book
*/
@NotNull
public BaseComponent[] getPage(int page) {
throw new UnsupportedOperationException("Not supported yet.");
}

/**
* Sets the specified page in the book. Pages of the book must be
* contiguous.
* <p>
* The data can be up to 256 characters in length, additional characters
* are truncated.
*
* @param page the page number to set
* @param data the data to set for that page
*/
public void setPage(int page, @Nullable BaseComponent... data) {
throw new UnsupportedOperationException("Not supported yet.");
}

/**
* Gets all the pages in the book.
*
* @return list of all the pages in the book
*/
@NotNull
public List<BaseComponent[]> getPages() {
throw new UnsupportedOperationException("Not supported yet.");
}

/**
* Clears the existing book pages, and sets the book to use the provided
* pages. Maximum 50 pages with 256 characters per page.
*
* @param pages A list of pages to set the book to use
*/
public void setPages(@NotNull List<BaseComponent[]> pages) {
throw new UnsupportedOperationException("Not supported yet.");
}

/**
* Clears the existing book pages, and sets the book to use the provided
* pages. Maximum 50 pages with 256 characters per page.
*
* @param pages A list of component arrays, each being a page
*/
public void setPages(@NotNull BaseComponent[]... pages) {
throw new UnsupportedOperationException("Not supported yet.");
}

/**
* Adds new pages to the end of the book. Up to a maximum of 50 pages
* with 256 characters per page.
*
* @param pages A list of component arrays, each being a page
*/
public void addPage(@NotNull BaseComponent[]... pages) {
throw new UnsupportedOperationException("Not supported yet.");
}
}

@NotNull
Expand Down

0 comments on commit 3f8251b

Please sign in to comment.