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
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);
}
}
}