Java Code Examples for org.bukkit.event.hanging.HangingBreakEvent#setCancelled()
The following examples show how to use
org.bukkit.event.hanging.HangingBreakEvent#setCancelled() .
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: LWCPlayerListener.java From Modern-LWC with MIT License | 6 votes |
@EventHandler public void hangingBreak(HangingBreakEvent event) { Entity entity = event.getEntity(); if (plugin.getLWC().isProtectable(event.getEntity().getType())) { int A = 50000 + entity.getUniqueId().hashCode(); LWC lwc = LWC.getInstance(); Protection protection = lwc.getPhysicalDatabase().loadProtection(entity.getWorld().getName(), A, A, A); if (protection != null) { if (event.getCause() == RemoveCause.PHYSICS || event.getCause() == RemoveCause.EXPLOSION || event.getCause() == RemoveCause.OBSTRUCTION) { event.setCancelled(true); } } } }
Example 2
Source File: ExhibitionListener.java From NyaaUtils with MIT License | 5 votes |
@EventHandler(priority = HIGHEST, ignoreCancelled = true) public void onItemFrameBreak(HangingBreakEvent ev) { if (!(ev.getEntity() instanceof ItemFrame)) return; ItemFrame f = (ItemFrame) ev.getEntity(); if (f.getItem() == null || f.getItem().getType() == Material.AIR) return; if (ExhibitionFrame.fromItemFrame(f).isSet()) { if (ev.getCause() == HangingBreakEvent.RemoveCause.EXPLOSION) { // Explosion protect ev.setCancelled(true); } else { plugin.getLogger().warning(String.format("Exhibition broken: Location: %s, item: %s", f.getLocation().toString(), f.getItem().toString())); f.setItem(new ItemStack(Material.AIR)); } } }
Example 3
Source File: HangingListener.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onHangingBreak(HangingBreakEvent event) { Hanging hanging = event.getEntity(); if (event.getCause().equals(RemoveCause.OBSTRUCTION)) { hanging.getLocation().getBlock().breakNaturally(); event.setCancelled(true); } else if (event.getCause().equals(RemoveCause.EXPLOSION)) { event.setCancelled(true); } }
Example 4
Source File: GlobalListener.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onFrameBrake(HangingBreakEvent e) { Location l = e.getEntity().getLocation(); Region r = RedProtect.get().rm.getTopRegion(l); if (r != null) { return; } if (e.getCause().toString().equals("EXPLOSION")) { if (!RedProtect.get().config.globalFlagsRoot().worlds.get(l.getWorld().getName()).entity_block_damage) { e.setCancelled(true); } } }
Example 5
Source File: BlockListener.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onFrameBrake(HangingBreakEvent e) { RedProtect.get().logger.debug(LogLevel.BLOCKS, "Is BlockListener - HangingBreakEvent event"); Entity ent = e.getEntity(); Location l = e.getEntity().getLocation(); if ((ent instanceof ItemFrame || ent instanceof Painting) && (e.getCause().toString().equals("EXPLOSION"))) { Region r = RedProtect.get().rm.getTopRegion(l); if (r != null && !r.canFire()) { e.setCancelled(true); } } }
Example 6
Source File: BlockBreakRegion.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onHangingBreak(HangingBreakEvent event) { if (event instanceof HangingBreakByEntityEvent) { if (region.contains(event.getEntity().getLocation().toVector()) && filter.evaluate(event.getEntity(), ((HangingBreakByEntityEvent) event).getRemover(), event).equals(FilterState.DENY)) { event.setCancelled(true); } } else { if (region.contains(event.getEntity().getLocation().toVector()) && filter.evaluate(event.getEntity(), event).equals(FilterState.DENY)) { event.setCancelled(true); } } }
Example 7
Source File: BlockEventRegion.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onHangingBreak(HangingBreakEvent event) { if (event instanceof HangingBreakByEntityEvent) { if (region.contains(event.getEntity().getLocation().toVector()) && filter.evaluate(event.getEntity(), ((HangingBreakByEntityEvent) event).getRemover(), event).equals(FilterState.DENY)) { event.setCancelled(true); } } else { if (region.contains(event.getEntity().getLocation().toVector()) && filter.evaluate(event.getEntity(), event).equals(FilterState.DENY)) { event.setCancelled(true); } } }
Example 8
Source File: WorldFreeze.java From CardinalPGM with MIT License | 4 votes |
@EventHandler public void onHangingBreak(HangingBreakEvent event) { if (!match.isRunning()) { event.setCancelled(true); } }