mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-24 00:51:22 +01:00
Changed handling von PlayerTakeLecternBookEvent to match the chest-access flag
This commit is contained in:
parent
1652c9bfc0
commit
5ec3ed6092
@ -58,8 +58,10 @@
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerTakeLecternBookEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -261,6 +263,11 @@ public void onUseBlock(final UseBlockEvent event) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.CHEST_ACCESS));
|
||||
what = "open that";
|
||||
|
||||
/* Inventory for blocks with the possibility to be only use, e.g. lectern */
|
||||
} else if (handleAsInventoryUsage(event.getOriginalEvent())) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.CHEST_ACCESS));
|
||||
what = "take that";
|
||||
|
||||
/* Beds */
|
||||
} else if (Materials.isBed(type)) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT, Flags.SLEEP));
|
||||
@ -552,4 +559,14 @@ private static StateFlag[] combine(DelegateEvent event, StateFlag... flag) {
|
||||
return flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if that event should be handled as inventory usage, e.g. if a player takes a book from a lectern
|
||||
*
|
||||
* @param event the event to handle
|
||||
* @return whether it should be handled as inventory usage
|
||||
*/
|
||||
private static boolean handleAsInventoryUsage(Event event) {
|
||||
return event instanceof PlayerTakeLecternBookEvent;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user