Java Code Examples for com.griefcraft.lwc.LWC#sendLocaleToActionBar()
The following examples show how to use
com.griefcraft.lwc.LWC#sendLocaleToActionBar() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DestroyModule.java From Modern-LWC with MIT License | 4 votes |
@Override public void onDestroyProtection(LWCProtectionDestroyEvent event) { if (event.isCancelled()) { return; } if (event.getMethod() != LWCProtectionDestroyEvent.Method.BLOCK_DESTRUCTION && event.getMethod() != LWCProtectionDestroyEvent.Method.ENTITY_DESTRUCTION) { return; } LWC lwc = event.getLWC(); Protection protection = event.getProtection(); Player player = event.getPlayer(); boolean isOwner = protection.isOwner(player); if (isOwner) { if (!lwc.isAdmin(player) && Boolean.parseBoolean(lwc.resolveProtectionConfiguration(protection.getBlock(), "readonly-remove"))) { lwc.sendLocale(player, "protection.accessdenied"); event.setCancelled(true); return; } // bind the player of destroyed the protection // We don't need to save the history we modify because it will be saved anyway immediately after this for (History history : protection.getRelatedHistory(History.Type.TRANSACTION)) { if (history.getStatus() != History.Status.ACTIVE) { continue; } history.addMetaData("destroyer=" + player.getName()); history.addMetaData("destroyerTime=" + System.currentTimeMillis() / 1000L); } protection.remove(); if (!Boolean.parseBoolean(lwc.resolveProtectionConfiguration(protection.getBlock(), "quiet"))) { BlockCache blockCache = BlockCache.getInstance(); lwc.sendLocaleToActionBar(player, "protection.unregistered", "block", LWC.materialToString(blockCache.getBlockType(protection.getBlockId()))); } return; } event.setCancelled(true); }
Example 2
Source File: FreeModule.java From Modern-LWC with MIT License | 4 votes |
@Override public void onProtectionInteract(LWCProtectionInteractEvent event) { if (event.getResult() != Result.DEFAULT) { return; } if (!event.hasAction("free")) { return; } LWC lwc = event.getLWC(); Protection protection = event.getProtection(); Player player = event.getPlayer(); event.setResult(Result.CANCEL); /* Due to treating entities as blocks some issues are triggered * such as when clicking an armor stand the block is air. * I feel there is something better to be done here but this works */ if (protection.getBlock().getType() == Material.AIR) { if (!protection.toString().contains("ARMOR_STAND")) { return; } } if (!lwc.isAdmin(player) && Boolean.parseBoolean(lwc.resolveProtectionConfiguration(protection.getBlock(), "readonly-remove"))) { lwc.sendLocale(player, "protection.accessdenied"); return; } if (lwc.hasAdminPermission(player, "lwc.admin.remove") || protection.isOwner(player)) { LWCProtectionDestroyEvent evt = new LWCProtectionDestroyEvent(player, protection, LWCProtectionDestroyEvent.Method.COMMAND, true, true); lwc.getModuleLoader().dispatchEvent(evt); if (!evt.isCancelled()) { // bind the player of destroyed the protection // We don't need to save the history we modify because it will // be saved anyway immediately after this for (History history : protection.getRelatedHistory(History.Type.TRANSACTION)) { if (history.getStatus() != History.Status.ACTIVE) { continue; } history.addMetaData("destroyer=" + player.getName()); history.addMetaData("destroyerTime=" + System.currentTimeMillis() / 1000L); } protection.remove(); if (protection.getBlock() instanceof EntityBlock) { lwc.sendLocaleToActionBar(player, "protection.interact.remove.finalize", "block", EntityBlock.getEntity().getType().name()); } else { lwc.sendLocaleToActionBar(player, "protection.interact.remove.finalize", "block", !protection.toString().contains("ARMOR_STAND") ? LWC.materialToString(protection.getBlock()) : "ARMOR_STAND"); } } lwc.removeModes(player); } else { if (protection.getBlock() instanceof EntityBlock) { lwc.sendLocale(player, "protection.interact.error.notowner", "block", EntityBlock.getEntity().getType().name()); } else { lwc.sendLocale(player, "protection.interact.error.notowner", "block", LWC.materialToString(protection.getBlock())); } lwc.removeModes(player); } }
Example 3
Source File: FreeModule.java From Modern-LWC with MIT License | 4 votes |
@Override public void onEntityInteractProtection(LWCProtectionInteractEntityEvent event) { if (event.getResult() != Result.DEFAULT) { return; } if (!event.hasAction("free")) { return; } LWC lwc = event.getLWC(); Protection protection = event.getProtection(); Player player = event.getPlayer(); event.setResult(Result.CANCEL); if (protection.getBlock().getType() != Material.AIR) { return; } if (!lwc.isAdmin(player) && Boolean.parseBoolean(lwc.resolveProtectionConfiguration(protection.getBlock(), "readonly-remove"))) { lwc.sendLocale(player, "protection.accessdenied"); return; } if (lwc.hasAdminPermission(player, "lwc.admin.remove") || protection.isOwner(player)) { LWCProtectionDestroyEvent evt = new LWCProtectionDestroyEvent(player, protection, LWCProtectionDestroyEvent.Method.COMMAND, true, true); lwc.getModuleLoader().dispatchEvent(evt); if (!evt.isCancelled()) { // bind the player of destroyed the protection // We don't need to save the history we modify because it will // be saved anyway immediately after this for (History history : protection.getRelatedHistory(History.Type.TRANSACTION)) { if (history.getStatus() != History.Status.ACTIVE) { continue; } history.addMetaData("destroyer=" + player.getName()); history.addMetaData("destroyerTime=" + System.currentTimeMillis() / 1000L); } protection.remove(); lwc.sendLocaleToActionBar(player, "protection.interact.remove.finalize", "block", event.getEvent().getRightClicked().getType().name()); } lwc.removeModes(player); } else { lwc.sendLocale(player, "protection.interact.error.notowner", "block", event.getEvent().getRightClicked().getType().name()); lwc.removeModes(player); } }