Makes formatting on book signing require the format permission
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good

This commit is contained in:
2025-08-14 20:01:34 +02:00
parent f05a15586a
commit 63ca95d247
2 changed files with 8 additions and 1 deletions

View File

@@ -27,6 +27,11 @@ public enum Permission {
*/
DECRYPT("decrypt"),
/**
* The permission for formatting a book's text either through the `/formatBook` command or automatically
*/
FORMAT("format"),
;
private final @NotNull String node;

View File

@@ -1,6 +1,7 @@
package net.knarcraft.bookswithoutborders.listener;
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
import net.knarcraft.bookswithoutborders.config.Permission;
import net.knarcraft.bookswithoutborders.utility.BookFormatter;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -16,7 +17,8 @@ public class BookEventListener implements Listener {
@EventHandler
public void onBookSign(@NotNull PlayerEditBookEvent event) {
if (event.isCancelled() || !event.isSigning() || !BooksWithoutBorders.getConfiguration().formatBooks()) {
if (event.isCancelled() || !event.isSigning() || !BooksWithoutBorders.getConfiguration().formatBooks() ||
!event.getPlayer().hasPermission(Permission.FORMAT.toString())) {
return;
}
event.setNewBookMeta(BookFormatter.formatPages(event.getNewBookMeta()));