public void onFrameBreak(HangingBreakByEntityEvent e) { if (e.getRemover() instanceof Player) { return; } Player p = (Player) e.getRemover(); Map cpl = RegionMapGen.getPlayerLocations(); cpl.put(p.getUniqueId(), RegionMapGen.getMap()[(int)p.getLocation().getX()][(int)p.getLocation().getZ()]); RegionMapGen.setPlayerLocations(cpl); if (cpl.get(p.getUniqueId()).equals("lava")) { Broadcast.toPlayer(p.getPlayer(), Broadcast.BroadcastType.FAILURE, "You cannot break item frames in Warvale's territory."); e.setCancelled(true); } else if (cpl.get(p.getUniqueId()).equals(Main.get().getConfig().getString("Player-Data."+p.getUniqueId()+"Guild-Name"))) { e.setCancelled(false); } else { Broadcast.toPlayer(p, Broadcast.BroadcastType.FAILURE, "You cannot break item frames in "+cpl.get(p.getUniqueId())+"'s territory."); e.setCancelled(true); } }
@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 (!Util.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); } } }
@EventHandler public void onHangingDamaged(HangingBreakByEntityEvent e) { if (e.isCancelled()) { return; } 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); } } }
@EventHandler public void onFrameBrake(HangingBreakByEntityEvent e) { RedProtect.get().logger.debug("Is BlockListener - HangingBreakByEntityEvent event"); if (e.isCancelled()){ return; } 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); } } }
@EventHandler public void onHangingDamaged(HangingBreakByEntityEvent e) { if (e.isCancelled()) { return; } RedProtect.get().logger.debug("Is RPPlayerListener - 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())) { RPLang.sendMessage(player, "blocklistener.region.cantbuild"); e.setCancelled(true); } } if (ent instanceof Monster){ if (r != null && !r.canMobLoot()) { e.setCancelled(true); } } }
@EventHandler(priority = EventPriority.HIGHEST) public void onHangingBreakByEntityEvent(HangingBreakByEntityEvent event) { User user = API.to(event.getRemover()); if (user == null) return; ItemStack item = user.getItemInHand(); UItem object = UItemManager.getInstance().getItem(item); if (object == null) return; UItemEvent result = object.call(new UItemEventClick(user, object, item, true), object.call(new UItemEventClickEntity(user, object, item, true, event.getEntity())) ); if (result.isCancelled()) { user.setItemInHand(result.getItem()); event.setCancelled(true); } }
@EventHandler public void onHangingBreak(HangingBreakEvent event) { EntityProtection entityProtection = this.module.getProtectManager().getEntityProtection(event.getEntity().getType(), event.getEntity().getUniqueId()); if(entityProtection.exists()) { if(event instanceof HangingBreakByEntityEvent) { HangingBreakByEntityEvent entityEvent = (HangingBreakByEntityEvent) event; if(entityEvent.getRemover() instanceof Player) { Player player = (Player) entityEvent.getRemover(); if(entityProtection.getOwner().equals(player.getUniqueId()) || player.hasPermission(ProtectPermissions.MODIFY_ALL)) { entityProtection.remove(); sendMessage(player, "protect.entity-unprotected"); return; } sendMessage(player, "protect.entity-protected-by", getDisplayName(this.module.getManager().getUsername(entityProtection.getOwner()), event.getEntity().getWorld().getName())); } } event.setCancelled(true); } }
/** * 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); } }
@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); } } }
/** * On hanging break by entity. * * @param event * the event */ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onHangingBreakByEntity(HangingBreakByEntityEvent event) { Player player; if (event.getRemover() instanceof Player && !playerConf.get((player = (Player) event.getRemover())) .isAdminMod()) { IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea( event.getEntity().getLocation()); if ((land instanceof ILand && ((ILand) land).isBanned(player)) || !checkPermission(land, player, PermissionList.BUILD.getPermissionType()) || !checkPermission(land, player, PermissionList.BUILD_DESTROY.getPermissionType())) { messagePermission(player); event.setCancelled(true); } } }
@EventHandler public void onHangingBreak(HangingBreakByEntityEvent e) { if (e.getRemover() != null && e.getRemover() instanceof Player) { Player p = (Player) e.getRemover(); User u = Necessities.getUM().getUser(p.getUniqueId()); YamlConfiguration config = Necessities.getInstance().getConfig(); if (config.contains("Necessities.Guilds") && config.getBoolean("Necessities.Guilds") && !p.hasPermission("Necessities.guilds.admin")) { Guild owner = Necessities.getGM().chunkOwner(e.getEntity().getLocation().getChunk()); if (owner != null && u.getGuild() != owner) { Variables var = Necessities.getVar(); u.getPlayer().sendMessage(var.getEr() + "Error: " + var.getErMsg() + "You are not a part of that guild, and are not allowed to build there."); e.setCancelled(true); } } } }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onHangingBreakByEntity(final ExtendedHangingBreakEvent ext) { if (ext.getBaseEvent() instanceof HangingBreakByEntityEvent) { final HangingBreakByEntityEvent event = (HangingBreakByEntityEvent)ext.getBaseEvent(); if (event.getRemover().getType() == EntityType.PLAYER) { final Player player = (Player)event.getRemover(); if (ext.getRegion() != null && ext.getRegion().getFlag(Flag.BUILD) && !ext.getRegion().isUser(player)) { event.setCancelled(true); } } else { if (ext.getRegion() != null && (ext.getRegion().getFlag(Flag.BUILD) || ext.getRegion().getFlag(Flag.MOB))) { event.setCancelled(true); } } } }
/** * Checks the player is allowed to break the hanging entity. * * @param event event being handled */ @EventHandler (priority = EventPriority.HIGH, ignoreCancelled = true) public void onBreakEvent(HangingBreakByEntityEvent event) { if (!(event.getRemover() instanceof Player)) { return; } final Player player = (Player) event.getRemover(); final Block block = event.getEntity().getLocation().getBlock(); if (!canBuild(player, block)) { final Town town = plugin.getTown(block.getChunk()); if (town == null) { player.sendMessage(plugin.getLocalisation().get(LocalisationEntry.MSG_CANNOT_BUILD_HERE)); } else { player.sendMessage(plugin.getLocalisation().get(LocalisationEntry.MSG_ONLY_TOWN_MEMBERS_CAN_BREAK_BLOCKS, town.getName())); } event.setCancelled(true); } }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPaintingBreak(final HangingBreakByEntityEvent event) { final ProtectHolder settings = prot.getSettings(); Entity remover = event.getRemover(); if ((event.getCause() == HangingBreakEvent.RemoveCause.ENTITY) && ((remover instanceof Creeper) && getSettings().isCreeperBlockdamage()) || ((remover instanceof Wither) && getSettings().isWitherSpawnBlockdamage()) || ((remover instanceof Fireball) && getSettings().isFireballBlockdamage()) || ((remover instanceof TNTPrimed) && getSettings().isTntBlockdamage()) || ((remover instanceof WitherSkull) && getSettings().isWitherskullBlockdamage()) || ((remover instanceof ExplosiveMinecart) && getSettings().isTntMinecartBlockdamage())) { event.setCancelled(true); } }
@EventHandler public void onHangingDestroy(HangingBreakByEntityEvent event) { // Item Frames and Paintings if (event.getRemover() != null && event.getRemover() instanceof Player) { if (isSpectating((Player) event.getRemover())) { event.setCancelled(true); } } }
@EventHandler public void onHangingBreak(HangingBreakByEntityEvent event) { if (!(event.getRemover() instanceof Player)) event.setCancelled(true); PlayerDataRPG pd = plugin.getPD((Player) event.getRemover()); if (pd == null) event.setCancelled(true); if (((Player) event.getRemover()).getGameMode() != GameMode.CREATIVE) event.setCancelled(true); if (!canBuild(pd)) event.setCancelled(true); }
@EventHandler public void onDestroyByEntity(HangingBreakByEntityEvent event) { if ((event.getRemover() instanceof Player)) { if (event.getEntity().getType() == EntityType.ITEM_FRAME) { event.setCancelled(true); } } }
/** * Disable pre-breaking blocks * * @param event Event */ @EventHandler public void onHangingBreakByEntity(HangingBreakByEntityEvent event) { if (event.getEntity() instanceof Player) event.setCancelled(this.hasToCancel((Player) event.getEntity())); }
@EventHandler public void onHanging(HangingBreakByEntityEvent e) { if (ConfigGProtection.getConfig().getBoolean("Protection.HagingBreakByEntity.Enable")) { if (!ConfigGProtection.getConfig().getBoolean("Protection.HagingBreakByEntity.World.All_World")) { if (WorldUtils.getWHBBE().contains(e.getEntity().getWorld().getName())) { e.setCancelled(true); } } else { e.setCancelled(true); } } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) public void onHangingBreakByEntity(final HangingBreakByEntityEvent event) { final Entity remover = event.getRemover(); if (remover instanceof Player && !attemptBuild(remover, event.getEntity().getLocation(), ChatColor.GRAY + "You may not build in the territory of %1$s" + ChatColor.GRAY + '.')) { event.setCancelled(true); } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) public void onHangingBreakByEntity(HangingBreakByEntityEvent event) { Entity remover = event.getRemover(); if (remover instanceof Player) { if (!attemptBuild(remover, event.getEntity().getLocation(), ChatColor.YELLOW + "You may not build in the territory of %1$s" + ChatColor.YELLOW + '.')) { event.setCancelled(true); } } }
@EventHandler public void onHangingBreak(HangingBreakByEntityEvent event) { if (event.getRemover() instanceof Player) { if (isObserver((Player) event.getRemover())) { event.setCancelled(true); } } }
/** * Prevent players from destroying item frames in protected regions */ @EventHandler public void onHangingBreakByEntity(HangingBreakByEntityEvent event) { CuboidRegion region = regionHandler.getApplicableRegion(event.getEntity().getLocation()); if (!event.isCancelled() && region != null && !region.allows("destroy")) { event.setCancelled(true); if (event.getRemover() instanceof Player) { warnPlayer((Player) event.getRemover()); } } }
/** * Prevents a player that can't interact from breaking a hanging entity. * * @param event The event. */ @EventHandler(ignoreCancelled = true) public void onHangingBreakByEntity(HangingBreakByEntityEvent event) { if (event.getEntity() instanceof Player && !canInteract((Player) event.getEntity())) { event.setCancelled(true); } }
public boolean init(Expression<?>[] args, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) { if (!ScriptLoader.isCurrentEvent(HangingBreakEvent.class) && ScriptLoader.isCurrentEvent(HangingBreakByEntityEvent.class)) { Skript.error("You can not use HangingCause expression in any event but on unhang!"); return false; } return true; }
public boolean init(Expression<?>[] args, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) { if (!ScriptLoader.isCurrentEvent(HangingBreakByEntityEvent.class) && !ScriptLoader.isCurrentEvent(HangingBreakEvent.class)) { Skript.error("You can not use HangingCause expression in any event but on unhang remove!"); return false; } return true; }
@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); } } }
@EventHandler(priority = EventPriority.HIGHEST) public void onHangingBreak(HangingBreakByEntityEvent e) { if (e.getRemover() instanceof Player || (e.getRemover() instanceof Projectile && ((Projectile)e.getRemover()).getShooter() instanceof Player)) { for (Minigame mg : Minigame.getMinigameInstances()) { if (!mg.getConfigManager().isHangingBreakAllowed() && mg.isPlayer(e.getRemover() instanceof Player ? ((Player)e.getRemover()).getName() : ((Player)((Projectile)e.getRemover()).getShooter()).getName())) { e.setCancelled(true); } } } }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onHangingBreakByEntity(final HangingBreakByEntityEvent e) { final Entity r = e.getRemover(); if (r instanceof Player) { final Player p = (Player) r; final Location l = BukkitUtil.getLocation(e.getEntity()); final PlotPlayer pp = BukkitUtil.getPlayer(p); if (PlotSquared.isPlotWorld(l.getWorld())) { Plot plot = MainUtil.getPlot(l); if (plot == null) { if (MainUtil.isPlotAreaAbs(l)) { if (!Permissions.hasPermission(pp, "plots.admin.destroy.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road"); e.setCancelled(true); return; } } } else { if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, "plots.admin.destroy.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.unowned"); e.setCancelled(true); return; } } else if (!plot.isAdded(pp.getUUID())) { if (FlagManager.isPlotFlagTrue(plot, "hanging-break")) { return; } if (!Permissions.hasPermission(pp, "plots.admin.destroy.other")) { if (MainUtil.isPlotArea(l)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.other"); e.setCancelled(true); return; } } } } } } }
@EventHandler public void onHangingBreak(HangingBreakEvent event) { if(event instanceof HangingBreakByEntityEvent) { Entity attacker = ((HangingBreakByEntityEvent) event).getRemover(); if(attacker instanceof Player) { Player player = (Player) attacker; Lot lot = this.module.getLotManager().getLot(event.getEntity().getLocation()); Town town = this.module.getLotManager().getTown(event.getEntity().getLocation()); if(((lot != null && !lot.canBuild(player)) || (lot == null && town != null)) && !player.hasPermission(LotPermissions.BUILD_ANYWHERE)) { event.setCancelled(true); } } } }
@EventHandler public void itemFrame(HangingBreakByEntityEvent e) { if (e.getRemover() instanceof Player) { Player p = (Player) e.getRemover(); if (Main.WaitingPlayers.contains(p) || Main.PlayingPlayers.contains(p)) { e.setCancelled(true); } } }
@EventHandler public void onHangingBreak(HangingBreakEvent event) { if (event.getCause() == RemoveCause.ENTITY) { HangingBreakByEntityEvent entityEvent = (HangingBreakByEntityEvent) event; if (entityEvent.getRemover() instanceof Player) { Player remover = (Player) entityEvent.getRemover(); if (remover.isOp() && remover.getGameMode() == GameMode.CREATIVE) { return; } } } event.setCancelled(true); }
@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); } } } } }
/** * Checks if a player has permission to break paintings or item frames. * * @param event that triggers listener. */ @EventHandler(priority = EventPriority.LOW) public void NoHangingBreak(HangingBreakByEntityEvent event) { Entity entity = event.getRemover(); Player player = null; if (event.getRemover().getType() == EntityType.PLAYER) { player = (Player) entity; } if (player != null) { if (!player.hasPermission("antibuild.bypass")) { if (!player.hasPermission("antibuild.painting")) { event.setCancelled(true); PlayerMessenger.messageHandler(plugin.getConfigHandler().getNoInteractMessage(), player); } } // // // World lock check // if (!event.isCancelled() && plugin.isUsingLock()) { // if (plugin.isLockedWorld(player.getWorld().getName()) // && !player.hasPermission("antibuild.lock.bypass") && !player.hasPermission("antibuild.lock" + // ".bypass." + player.getWorld().getName())) { // event.setCancelled(true); // messageHandler(plugin.getLockedWorldMessage(), player); // } // } } }
@EventHandler(priority = EventPriority.HIGH) public void onHangingBreak(HangingBreakByEntityEvent event) { if (event.getEntity() instanceof Player) { if (SGApi.getArenaManager().isInGame((Player) event.getEntity())) { event.setCancelled(true); } } }