@Override public void onProtectionInteract(LWCProtectionInteractEvent event) { if (event.getResult() != Result.DEFAULT) { return; } if (!event.hasAction("create")) { return; } LWC lwc = event.getLWC(); Protection protection = event.getProtection(); Player player = event.getPlayer(); if (protection.isOwner(player)) { lwc.sendLocale( player, "protection.interact.error.alreadyregistered", "block", LWC.materialToString(protection.getBlockId())); } else { lwc.sendLocale( player, "protection.interact.error.notowner", "block", LWC.materialToString(protection.getBlockId())); } lwc.removeModes(player); event.setResult(Result.CANCEL); }
@Override public void onProtectionInteract(LWCProtectionInteractEvent event) { if (event.getResult() != Result.DEFAULT) { return; } if (!event.hasAction("forceowner")) { return; } LWC lwc = event.getLWC(); Protection protection = event.getProtection(); Player player = event.getPlayer(); Action action = lwc.getMemoryDatabase().getAction("forceowner", player.getName()); String newOwner = action.getData(); protection.setOwner(newOwner); protection.save(); lwc.sendLocale(player, "protection.interact.forceowner.finalize", "player", newOwner); lwc.removeModes(player); event.setResult(Result.CANCEL); return; }
@Override public void onProtectionInteract(LWCProtectionInteractEvent event) { if (event.getResult() != Result.DEFAULT) { return; } if (!event.hasAction("info")) { return; } LWC lwc = event.getLWC(); Protection protection = event.getProtection(); Player player = event.getPlayer(); event.setResult(Result.CANCEL); String type = lwc.getPlugin().getMessageParser().parseMessage(protection.typeToString().toLowerCase()); lwc.sendLocale(player, "lwc.info", "owner", protection.getOwner(), "type", type); if (event.canAdmin()) { if (protection.getType() == Protection.Type.PRIVATE || protection.getType() == Protection.Type.DONATION) { lwc.sendLocale(player, "lwc.acl", "size", protection.getPermissions().size()); int index = 0; for (Permission permission : protection.getPermissions()) { if (index >= 9) { break; } player.sendMessage(permission.toString()); index++; } if (index == 0) { lwc.sendLocale(player, "lwc.acl.empty"); } else if (index >= 9) { lwc.sendLocale(player, "lwc.acl.limitreached"); } player.sendMessage(""); } } if (lwc.isAdmin(player)) { lwc.sendLocale(player, "protection.interact.info.raw", "raw", protection.toString()); } lwc.removeModes(player); }