Java Code Examples for org.bukkit.event.hanging.HangingBreakByEntityEvent#getRemover()
The following examples show how to use
org.bukkit.event.hanging.HangingBreakByEntityEvent#getRemover() .
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: GlobalListener.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void onHangingDamaged(HangingBreakByEntityEvent e) { Entity ent = e.getRemover(); Location loc = e.getEntity().getLocation(); Region r = RedProtect.get().rm.getTopRegion(loc); if (r != null) { return; } if (ent instanceof Player) { Player p = (Player) ent; if (!bypassBuild(p, null, 0)) { e.setCancelled(true); } } }
Example 2
Source File: PlayerListener.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onHangingDamaged(HangingBreakByEntityEvent e) { if (e.isCancelled()) { return; } RedProtect.get().logger.debug(LogLevel.PLAYER, "Is PlayerListener - HangingBreakByEntityEvent event"); Entity ent = e.getRemover(); Location loc = e.getEntity().getLocation(); Region r = RedProtect.get().rm.getTopRegion(loc); if (ent instanceof Player) { Player player = (Player) ent; if (r != null && !r.canBuild(player) && !r.canBreak(e.getEntity().getType())) { RedProtect.get().lang.sendMessage(player, "blocklistener.region.cantbuild"); e.setCancelled(true); } } if (ent instanceof Monster) { if (r != null && !r.canMobLoot()) { e.setCancelled(true); } } }
Example 3
Source File: RegionInteractListener.java From NovaGuilds with GNU General Public License v3.0 | 6 votes |
/** * Handles breaking paintings, item frames, leashes * * @param event The event */ @EventHandler public void onHangingEntityBreak(HangingBreakByEntityEvent event) { if(!(event.getRemover() instanceof Player)) { return; } Player player = (Player) event.getRemover(); NovaPlayer nPlayer = PlayerManager.getPlayer(player); boolean isLeash = event.getEntity() instanceof LeashHitch; if(RegionManager.get(event.getEntity()) != null && (!plugin.getRegionManager().canInteract(player, event.getEntity()) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(isLeash ? GuildPermission.MOB_LEASH : GuildPermission.BLOCK_BREAK)))) { event.setCancelled(true); (isLeash ? Message.CHAT_REGION_DENY_UNLEASH : Message.CHAT_REGION_DENY_INTERACT).send(player); } }
Example 4
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 6 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onItemFrameDamage(final HangingBreakByEntityEvent e) { if (DEBUG) { plugin.getLogger().info("DEBUG: Hanging break by entity event"); plugin.getLogger().info("DEBUG: cause = " + e.getCause()); plugin.getLogger().info("DEBUG: entity = " + e.getEntity()); plugin.getLogger().info("DEBUG: remover = " + e.getRemover()); } // Check world if (!inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) { return; } if (e.getRemover() instanceof Skeleton || e.getRemover() instanceof Golem) { if (DEBUG) plugin.getLogger().info("DEBUG: Remover is mob"); if (!Settings.allowMobDamageToItemFrames) { if (DEBUG) plugin.getLogger().info("DEBUG: Damage not allowed, cancelling"); e.setCancelled(true); } } }
Example 5
Source File: LWCPlayerListener.java From Modern-LWC with MIT License | 5 votes |
@EventHandler public void hangingBreakByEvent(HangingBreakByEntityEvent 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 (event.getRemover() instanceof Projectile && protection != null) { event.setCancelled(true); } if (event.getRemover() instanceof Player) { Player p = (Player) event.getRemover(); if (p.hasPermission("lwc.lockentity." + entity.getType()) || p.hasPermission("lwc.lockentity.all")) { if (onPlayerEntityInteract(p, entity, event.isCancelled())) { event.setCancelled(true); } } if (!event.isCancelled() && protection != null) { boolean canAccess = lwc.canAccessProtection(p, protection); if (canAccess) { protection.remove(); protection.removeAllPermissions(); protection.removeCache(); return; } event.setCancelled(true); } } } }
Example 6
Source File: ProtectionHandler.java From Civs with GNU General Public License v3.0 | 5 votes |
private void onPaintingBreak(HangingBreakByEntityEvent event) { Player player = null; if (event.getRemover() instanceof Player) { player = (Player) event.getRemover(); } boolean setCancelled = event.isCancelled() || shouldBlockAction(event.getEntity().getLocation(), player, "block_break"); if (setCancelled) { event.setCancelled(true); } if (event.isCancelled() && player != null) { Civilian civilian = CivilianManager.getInstance().getCivilian(player.getUniqueId()); player.sendMessage(Civs.getPrefix() + LocaleManager.getInstance().getTranslationWithPlaceholders(player, LocaleConstants.REGION_PROTECTED)); } }
Example 7
Source File: BlockListener.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onFrameBrake(HangingBreakByEntityEvent e) { RedProtect.get().logger.debug(LogLevel.BLOCKS, "Is BlockListener - HangingBreakByEntityEvent event"); Entity remover = e.getRemover(); Entity ent = e.getEntity(); Location l = e.getEntity().getLocation(); if ((ent instanceof ItemFrame || ent instanceof Painting) && remover instanceof Monster) { Region r = RedProtect.get().rm.getTopRegion(l); if (r != null && !r.canMobLoot()) { e.setCancelled(true); } } }
Example 8
Source File: GrapplingHookListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onArrowHitHanging(HangingBreakByEntityEvent e) { if (!isEnabled()) { return; } // This is called when the arrow shoots off a painting or an item frame if (e.getRemover() instanceof Arrow) { handleGrapplingHook((Arrow) e.getRemover()); } }
Example 9
Source File: BukkitPlotListener.java From PlotMe-Core with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onHangingBreakByEntity(HangingBreakByEntityEvent event) { if (event.getRemover() instanceof Player) { BukkitPlayer player = (BukkitPlayer) plugin.wrapPlayer((Player) event.getRemover()); if (manager.isPlotWorld(player)) { if (player.hasPermission(PermissionNames.ADMIN_BUILDANYWHERE)) { return; } Plot plot = manager.getPlot(player); if (plot == null) { player.sendMessage(api.C("CannotBuild")); event.setCancelled(true); } else { if (plot.getOwnerId().equals(player.getUniqueId())) { return; } Optional<Plot.AccessLevel> member = plot.isMember(player.getUniqueId()); if (member.isPresent()) { if (member.get().equals(Plot.AccessLevel.TRUSTED) && !api.getServerBridge().getOfflinePlayer(plot.getOwnerId()).isOnline()) { player.sendMessage(api.C("CannotBuild")); event.setCancelled(true); } else if (api.isPlotLocked(plot.getId())) { player.sendMessage(api.C("PlotLocked")); event.setCancelled(true); } } else { player.sendMessage(api.C("CannotBuild")); event.setCancelled(true); } } } } }
Example 10
Source File: HangingBreak.java From FunnyGuilds with Apache License 2.0 | 5 votes |
@EventHandler public void onBreak(HangingBreakByEntityEvent e) { if (!(e.getRemover() instanceof Player)) { return; } Player p = (Player) e.getRemover(); if (ProtectionSystem.build(p, e.getEntity().getLocation())) { e.setCancelled(true); } }
Example 11
Source File: ObserverModule.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onHangingBreak(HangingBreakByEntityEvent event) { if (event.getRemover() instanceof Player) { if (testObserverOrDead((Player) event.getRemover())) { event.setCancelled(true); } } }
Example 12
Source File: CancellableChunkEvents.java From ClaimChunk with MIT License | 4 votes |
@EventHandler public void onItemFrameBroken(HangingBreakByEntityEvent e) { if (e != null && e.getRemover() != null && e.getRemover().getType() == EntityType.PLAYER) { ChunkEventHelper.handleBlockEvent((Player) e.getRemover(), e.getEntity().getLocation().getChunk(), e); } }
Example 13
Source File: BukkitImageListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onHangingBreakByEntity(HangingBreakByEntityEvent event) { if(!(event.getRemover() instanceof Player)) return; handleInteract(event, (Player) event.getRemover(), event.getEntity(), false); }
Example 14
Source File: BlockListener.java From civcraft with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.NORMAL) public void OnHangingBreakByEntityEvent(HangingBreakByEntityEvent event) { // CivLog.debug("hanging painting break event"); ItemFrameStorage frameStore = CivGlobal.getProtectedItemFrame(event.getEntity().getUniqueId()); if (frameStore != null) { // if (!(event.getRemover() instanceof Player)) { // event.setCancelled(true); // return; // } // // if (frameStore.getTown() != null) { // Resident resident = CivGlobal.getResident((Player)event.getRemover()); // if (resident == null) { // event.setCancelled(true); // return; // } // // if (resident.hasTown() == false || resident.getTown() != frameStore.getTown()) { // event.setCancelled(true); // CivMessage.sendError((Player)event.getRemover(), "Cannot remove item from protected item frame. Belongs to another town."); // return; // } // } // // CivGlobal.checkForEmptyDuplicateFrames(frameStore); // // ItemStack stack = ((ItemFrame)event.getEntity()).getItem(); // if (stack != null && !stack.getType().equals(Material.AIR)) { // BonusGoodie goodie = CivGlobal.getBonusGoodie(stack); // if (goodie != null) { // frameStore.getTown().onGoodieRemoveFromFrame(frameStore, goodie); // } // frameStore.clearItem(); // TaskMaster.syncTask(new DelayItemDrop(stack, event.getEntity().getLocation())); // } if (event.getRemover() instanceof Player) { CivMessage.sendError((Player)event.getRemover(), "Cannot break protected item frames. Right click to interact instead."); } event.setCancelled(true); return; } if (event.getRemover() instanceof Player) { Player player = (Player)event.getRemover(); coord.setFromLocation(player.getLocation()); TownChunk tc = CivGlobal.getTownChunk(coord); if (tc == null) { return; } Resident resident = CivGlobal.getResident(player.getName()); if (resident == null) { event.setCancelled(true); } if (!tc.perms.hasPermission(PlotPermissions.Type.DESTROY, resident)) { event.setCancelled(true); CivMessage.sendErrorNoRepeat(player, "You do not have permission to destroy here."); } } }
Example 15
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Prevents the breakage of hanging items * * @param e - event */ @EventHandler(priority = EventPriority.LOW) public void onBreakHanging(final HangingBreakByEntityEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); plugin.getLogger().info(e.getRemover().toString()); } if (inWorld(e.getEntity())) { if ((e.getRemover() instanceof Creeper) && !Settings.allowCreeperDamage) { e.setCancelled(true); return; } // Check if creeper griefing is allowed if ((e.getRemover() instanceof Creeper) && !Settings.allowCreeperGriefing) { // Find out who the creeper was targeting Creeper creeper = (Creeper)e.getRemover(); if (creeper.getTarget() instanceof Player) { Player target = (Player)creeper.getTarget(); // Check if the target is on their own island or not if (!plugin.getGrid().locationIsOnIsland(target, e.getEntity().getLocation())) { // They are a visitor tsk tsk e.setCancelled(true); return; } } // Check if this creeper was lit by a visitor if (litCreeper.contains(creeper.getUniqueId())) { if (DEBUG) { plugin.getLogger().info("DBEUG: preventing creeper from damaging"); } e.setCancelled(true); return; } } if (e.getRemover() instanceof Player) { Player p = (Player) e.getRemover(); // This permission bypasses protection if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { return; } if (actionAllowed(p,e.getEntity().getLocation(),SettingsFlag.BREAK_BLOCKS)) { return; } // Not allowed Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected); e.setCancelled(true); } } }