From 111ea7029e3530853517247541c61c768a4a1c90 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 30 Mar 2024 10:31:04 +0100 Subject: [PATCH] fix: allow trusted players to remove books from lecterns while lectern-read-book flag is true (#4336) allow trusted players to remove books from lecterns --- .../bukkit/listener/PlayerEventListener.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java index 6c2da8f45..85fe92c10 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java @@ -1936,7 +1936,9 @@ public class PlayerEventListener implements Listener { @EventHandler public void onPlayerTakeLecternBook(PlayerTakeLecternBookEvent event) { - Location location = BukkitUtil.adapt(event.getPlayer().getLocation()); + Player player = event.getPlayer(); + BukkitPlayer pp = BukkitUtil.adapt(player); + Location location = pp.getLocation(); PlotArea area = location.getPlotArea(); if (area == null) { return; @@ -1948,9 +1950,11 @@ public class PlayerEventListener implements Listener { } return; } - if (plot.getFlag(LecternReadBookFlag.class)) { - plot.debug(event.getPlayer().getName() + " could not take the book because of lectern-read-book = true"); - event.setCancelled(true); + if (!plot.isAdded(pp.getUUID())) { + if (plot.getFlag(LecternReadBookFlag.class)) { + plot.debug(event.getPlayer().getName() + " could not take the book because of lectern-read-book = true"); + event.setCancelled(true); + } } }