Make book byte limits configurable per player permissions
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package com.alttd.playerutils.util;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
@@ -19,8 +22,30 @@ public final class BookByteUtils {
|
||||
}
|
||||
|
||||
// 65,000 bytes per book (below CoreProtect hard limit ~65,535)
|
||||
public static final int MAX_BOOK_BYTES = 30_000;
|
||||
public static final int BIG_BOOK_BYTES = 10_000;
|
||||
@Getter
|
||||
private static final int MAX_BOOK_BYTES = 30_000;
|
||||
@Getter
|
||||
private static final int BIG_BOOK_BYTES = 10_000;
|
||||
|
||||
public static int getBigBookBytes(HumanEntity humanEntity) {
|
||||
return calcBookBytes(humanEntity, BIG_BOOK_BYTES);
|
||||
}
|
||||
|
||||
public static int getMaxBookBytes(HumanEntity humanEntity) {
|
||||
return calcBookBytes(humanEntity, MAX_BOOK_BYTES);
|
||||
}
|
||||
|
||||
private static int calcBookBytes(HumanEntity humanEntity, int bookBytes) {
|
||||
if (humanEntity.hasPermission("playerutils.bigbook.bypass")) {
|
||||
return Integer.MAX_VALUE;
|
||||
} else if (humanEntity.hasPermission("playerutils.bigbook.double")) {
|
||||
return bookBytes * 2;
|
||||
} else if (humanEntity.hasPermission("playerutils.bigbook.quadruple")) {
|
||||
return bookBytes * 4;
|
||||
} else {
|
||||
return bookBytes;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean shouldCountForBookByteLimit(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
|
||||
Reference in New Issue
Block a user