if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
LocalPlayer player = CraftBookPlugin.inst().wrapPlayer(event.getPlayer());
boolean save = false;
ChangedSign sign = event.getSign();
if (!sign.getLine(1).equals("[Area]") && !sign.getLine(1).equals("[SaveArea]")) return;
if (!player.hasPermission("craftbook.mech.area.use")) {
if(CraftBookPlugin.inst().getConfiguration().showPermissionMessages)
player.print("mech.use-permission");
return;
}
if(!ProtectionUtil.canUse(event.getPlayer(), event.getClickedBlock().getLocation(), event.getBlockFace(), event.getAction())) {
if(CraftBookPlugin.inst().getConfiguration().showPermissionMessages)
player.printError("area.use-permissions");
return;
}
// check if the namespace and area exists
if(!isValidArea(sign)) {
player.printError("mech.area.missing");
return;
}
save = sign.getLine(1).equals("[SaveArea]");
// toggle the area on or off
toggle(event.getClickedBlock(), sign, save);
event.setCancelled(true);