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
This commit is contained in:
Maurice 2024-03-30 10:31:04 +01:00 committed by GitHub
parent 9be2eedf7f
commit 111ea7029e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1936,7 +1936,9 @@ public class PlayerEventListener implements Listener {
@EventHandler @EventHandler
public void onPlayerTakeLecternBook(PlayerTakeLecternBookEvent event) { 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(); PlotArea area = location.getPlotArea();
if (area == null) { if (area == null) {
return; return;
@ -1948,9 +1950,11 @@ public class PlayerEventListener implements Listener {
} }
return; return;
} }
if (plot.getFlag(LecternReadBookFlag.class)) { if (!plot.isAdded(pp.getUUID())) {
plot.debug(event.getPlayer().getName() + " could not take the book because of lectern-read-book = true"); if (plot.getFlag(LecternReadBookFlag.class)) {
event.setCancelled(true); plot.debug(event.getPlayer().getName() + " could not take the book because of lectern-read-book = true");
event.setCancelled(true);
}
} }
} }