mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 10:22:29 +00:00
Show WorldGuard permission message when trying to create a shop
(e.g. when not allowed to open the chest) This also has the effect that the original event won't be un-cancelled anymore, so the flag "chest-access" now also has to be allowed!
This commit is contained in:
parent
460abc722e
commit
53a9bb0274
@ -148,21 +148,33 @@ public class WorldGuardListener implements Listener {
|
|||||||
if (type == Material.CHEST || type == Material.TRAPPED_CHEST) {
|
if (type == Material.CHEST || type == Material.TRAPPED_CHEST) {
|
||||||
if (isAllowed(player, orig.getClickedBlock().getLocation(), orig.getAction())) {
|
if (isAllowed(player, orig.getClickedBlock().getLocation(), orig.getAction())) {
|
||||||
event.setAllowed(true);
|
event.setAllowed(true);
|
||||||
|
|
||||||
|
ClickType ct = ClickType.getPlayerClickType(player);
|
||||||
|
if (!(ct != null && ct.getClickType() == ClickType.EnumClickType.CREATE)) {
|
||||||
|
// Don't un-cancel original event when trying to create shop.
|
||||||
|
// Flag "chest-access" has to be allowed too, so the original event won't be cancelled.
|
||||||
orig.setCancelled(false);
|
orig.setCancelled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (event.getOriginalEvent() instanceof InventoryOpenEvent) {
|
} else if (event.getOriginalEvent() instanceof InventoryOpenEvent) {
|
||||||
InventoryOpenEvent orig = (InventoryOpenEvent) event.getOriginalEvent();
|
InventoryOpenEvent orig = (InventoryOpenEvent) event.getOriginalEvent();
|
||||||
|
|
||||||
if (orig.getInventory().getHolder() instanceof Chest) {
|
if (orig.getInventory().getHolder() instanceof Chest) {
|
||||||
if (isAllowed(player, ((Chest)orig.getInventory().getHolder()).getLocation(), Action.RIGHT_CLICK_BLOCK)) {
|
if (isAllowed(player, ((Chest)orig.getInventory().getHolder()).getLocation(), Action.RIGHT_CLICK_BLOCK)) {
|
||||||
event.setAllowed(true);
|
event.setAllowed(true);
|
||||||
|
|
||||||
|
ClickType ct = ClickType.getPlayerClickType(player);
|
||||||
|
if (!(ct != null && ct.getClickType() == ClickType.EnumClickType.CREATE)) {
|
||||||
|
// Don't un-cancel original event when trying to create shop.
|
||||||
|
// Flag "chest-access" has to be allowed too, so the original event won't be cancelled.
|
||||||
orig.setCancelled(false);
|
orig.setCancelled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user