mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2025-01-08 19:38:15 +01:00
Fixed up the book checking code.
This commit is contained in:
parent
d325c187d8
commit
a1c0086fe7
@ -15,6 +15,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.BookMeta;
|
||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@ -465,8 +466,8 @@ public class Main extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean allowBook(ItemStack item) {
|
private boolean allowBook(ItemStack item) {
|
||||||
if (item.getType() == Material.WRITTEN_BOOK || item.getType() == getMaterial("WRITABLE_BOOK", "BOOK_AND_QUILL")) {
|
if (item != null && item.hasItemMeta() && item.getItemMeta() instanceof BookMeta) {
|
||||||
return item.toString().length() > 2000;
|
return ((BookMeta) item.getItemMeta()).getPages().stream().mapToInt(String :: length).sum() < 2000;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user