@EventHandler public void onFrameBrake(HangingBreakEvent e) { if (e.isCancelled()){ return; } Location l = e.getEntity().getLocation(); Region r = RedProtect.get().rm.getTopRegion(l); if (r != null){ return; } if (e.getCause().toString().equals("EXPLOSION") || e.getCause().toString().equals("ENTITY")) { if (!RPConfig.getGlobalFlagBool(l.getWorld().getName()+".entity-block-damage")){ e.setCancelled(true); } } }
@EventHandler public void onFrameBrake(HangingBreakEvent e) { RedProtect.get().logger.debug("Is BlockListener - HangingBreakEvent event"); if (e.isCancelled()){ return; } 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); } } }
public void move(double d0, double d1, double d2) { if (!this.world.isStatic && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { if (this.dead) return; // CraftBukkit // CraftBukkit start - fire break events // TODO - Does this need its own cause? Seems to only be triggered by pistons HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS); this.world.getServer().getPluginManager().callEvent(event); if (this.dead || event.isCancelled()) { return; } // CraftBukkit end this.die(); this.b((Entity) null); } }
@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); } }
public void moveEntity(double p_70091_1_, double p_70091_3_, double p_70091_5_) { if (!this.worldObj.isRemote && !this.isDead && p_70091_1_ * p_70091_1_ + p_70091_3_ * p_70091_3_ + p_70091_5_ * p_70091_5_ > 0.0D) { if (this.isDead) { return; // CraftBukkit } // CraftBukkit start // TODO - Does this need its own cause? Seems to only be triggered by pistons HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS); this.worldObj.getServer().getPluginManager().callEvent(event); if (this.isDead || event.isCancelled()) { return; } // CraftBukkit end this.setDead(); this.onBroken((Entity)null); } }
public void move(double d0, double d1, double d2) { if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { if (this.dead) return; // CraftBukkit // CraftBukkit start - fire break events // TODO - Does this need its own cause? Seems to only be triggered by pistons HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS); this.world.getServer().getPluginManager().callEvent(event); if (this.dead || event.isCancelled()) { return; } // CraftBukkit end this.die(); this.a((Entity) null); } }
/** * Event handler to watch whenever an itemframe is broken by something other than a player.. * This will remove the cache of the hoppers around it. * * @param event HangingBreakEvent containing data about the broken hanging item. We care about the ItemFrame being removed. */ @EventHandler(ignoreCancelled=true) public void onHangingBreakEvent(HangingBreakEvent event) { if (event.getEntity() instanceof ItemFrame) { //get the item frame entity ItemFrame itemFrame = (ItemFrame)event.getEntity(); //get the block location that represents the ItemFrame location Location itemFrameLocation = itemFrame.getLocation().getBlock().getLocation(); //debug if requested if (plugin.debugLevel_get() > 0) plugin.getLogger().info("ItemFrame broken by non-player at (" + itemFrameLocation.toString() + ")"); //an itemFrame was broken. Clear the cache from the hoppers around the frame. plugin.knownHoppersCache_ClearAroundLocation(itemFrameLocation); } }
@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 onHangingDamage(HangingBreakEvent event) { if (!event.isCancelled()) { for (Region region : regions) { if (region.contains(event.getEntity().getLocation())) { event.setCancelled(true); } } } }
@Override public boolean check(Event event) { return removeCauseOptional.map(cause -> cause.check(event, new Checker<HangingBreakEvent.RemoveCause>() { @Override public boolean check(HangingBreakEvent.RemoveCause removeCause) { return removeCause == ((HangingBreakEvent) event).getCause(); } })).orElse(true); }
@Override public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) { if (ScriptLoader.isCurrentEvent(HangingPlaceEvent.class) || ScriptLoader.isCurrentEvent(HangingBreakEvent.class)) { return true; } Skript.error("'hanged entity' can only be used in hang and unhang events!"); return false; }
@EventHandler public void onHangingBreak(HangingBreakEvent event) { if(event.isCancelled()) return; if(event.getCause() == RemoveCause.ENTITY) event.setCancelled(true); }
@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)); } } }
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(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); } }
@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 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); }
/** * On hanging break. * * @param event the event */ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onHangingBreak(HangingBreakEvent event) { if (conf.isOverrideExplosions()) { // Check for painting if (event.getCause() == RemoveCause.EXPLOSION) { Factoid.getThisPlugin().iLog().write("Cancel HangingBreak : " + event.getEntity() + ", Cause: " + event.getCause()); event.setCancelled(true); } } }
@EventHandler public void onHangingDestroy(HangingBreakEvent event) { for(Game game : SurvivalGames.gameManager.getGames()) { for(Arena arena : game.getArenas()) { if(arena.containsBlock(event.getEntity().getLocation())) event.setCancelled(true); } } }
public void m() { this.lastX = this.locX; this.lastY = this.locY; this.lastZ = this.locZ; if (this.d++ == this.world.spigotConfig.hangingTickFrequency && !this.world.isClientSide) { // Spigot this.d = 0; if (!this.dead && !this.survives()) { // CraftBukkit start - fire break events Material material = this.world.getType(new BlockPosition(this)).getMaterial(); HangingBreakEvent.RemoveCause cause; if (!material.equals(Material.AIR)) { // TODO: This feels insufficient to catch 100% of suffocation cases cause = HangingBreakEvent.RemoveCause.OBSTRUCTION; } else { cause = HangingBreakEvent.RemoveCause.PHYSICS; } HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause); this.world.getServer().getPluginManager().callEvent(event); if (dead || event.isCancelled()) { return; } // CraftBukkit end this.die(); this.a((Entity) null); } } }
@EventHandler public void onHangingBreak(HangingBreakEvent event) { // If there's no portal, we don't care. final ABPortal portal = plugin.getManager().getByFrame(event.getEntity()); if (portal == null) return; // Cancel it so it doesn't break. event.setCancelled(true); }
@EventHandler public void onHangingBreak(HangingBreakEvent event) { Entity hanging = event.getEntity(); ArenaManager am = SimpleSurvivalGames.instance.getArenaManager(); for(Arena a : am.getArenas()) if(a.isArenaCuboidSet()) if(a.getArenaCuboid().isInsideCuboid(hanging.getLocation())) if(!a.isInEditMode()) event.setCancelled(true); }
@EventHandler (priority = EventPriority.HIGH) public void onHangingBreak(HangingBreakEvent event) { if (event.isCancelled() || (event.getEntity().getType() != EntityType.ITEM_FRAME)) return; ItemFrame entity = (ItemFrame)event.getEntity(); Frame frame = this.manager.getFrame(entity); if (frame == null) return; Player player = null; if (event instanceof HangingBreakByEntityEvent) { Entity remover = ((HangingBreakByEntityEvent)event).getRemover(); if (remover.getType() == EntityType.PLAYER) { player = (Player) remover; } } if ((player != null) && Config.WORLDGUARD_ENABLED && Config.WORLDGUARD_BREAK && !player.hasPermission("FramePicture.ignoreWorldGuard")) { RegionManager rm = FramePicturePlugin.getWorldGuard().getRegionManager(player.getWorld()); LocalPlayer localPlayer = FramePicturePlugin.getWorldGuard().wrapPlayer(player); if (!rm.getApplicableRegions(frame.getLocation()).canBuild(localPlayer)) { player.sendMessage(Lang.PREFIX.getText() + Lang.NO_PERMISSION.getText()); event.setCancelled(true); return; } } this.manager.removeFrame(frame); if (player != null) player.sendMessage(Lang.PREFIX.getText() + Lang.FRAME_REMOVED.getText().replace("%id", String.valueOf(frame.getId()))); for (Entity e : entity.getNearbyEntities(32.0, 32.0, 32.0)) { if (e.getType() != EntityType.PLAYER) continue; Player p = (Player)e; this.sendFrameDestroy(p, entity.getEntityId()); } }
@EventHandler public void onHangingBreak(HangingBreakEvent event) { if (event.getCause() == RemoveCause.DEFAULT || event.getCause() == RemoveCause.EXPLOSION) event.setCancelled(true); }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onHangingBreak(final HangingBreakEvent event) { cancelUnlessInteracting(event, event instanceof HangingBreakByEntityEvent ? ((HangingBreakByEntityEvent) event).getRemover() : null); }
@EventHandler public void onHangingBreak(HangingBreakEvent event) { event.setCancelled(true); }
@Override public boolean init(Literal<?>[] literals, int i, SkriptParser.ParseResult parseResult) { removeCauseOptional = Optional.ofNullable((Literal<HangingBreakEvent.RemoveCause>) literals[0]); return true; }
@Nullable protected String[] get(Event e) { return new String[]{((HangingBreakEvent)e).getCause().toString()}; }
@EventHandler public void zoneCrystalExplosionFrame(HangingBreakEvent event) { if (event.getEntity().getWorld().getName().equals("world")) if (event.getCause() == HangingBreakEvent.RemoveCause.EXPLOSION) event.setCancelled(true); }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onHangingBreak(HangingBreakEvent event) { handleEntityEvent(event.getEntity(), false, event); }
@EventHandler public void onHangingBreak(HangingBreakEvent event) { callHandlers("hanging.break", event); }
@EventHandler public void onHangingBreak(HangingBreakEvent event) { if (!match.isRunning()) { event.setCancelled(true); } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onHangingBreak(HangingBreakEvent event) { //don't track in worlds where claims are not enabled if(!GriefPrevention.instance.claimsEnabledForWorld(event.getEntity().getWorld())) return; //FEATURE: claimed paintings are protected from breakage //explosions don't destroy hangings if(event.getCause() == RemoveCause.EXPLOSION) { event.setCancelled(true); return; } //only allow players to break paintings, not anything else (like water and explosions) if(!(event instanceof HangingBreakByEntityEvent)) { event.setCancelled(true); return; } HangingBreakByEntityEvent entityEvent = (HangingBreakByEntityEvent)event; //who is removing it? Entity remover = entityEvent.getRemover(); //again, making sure the breaker is a player if(!(remover instanceof Player)) { event.setCancelled(true); return; } //if the player doesn't have build permission, don't allow the breakage Player playerRemover = (Player)entityEvent.getRemover(); String noBuildReason = GriefPrevention.instance.allowBuild(playerRemover, event.getEntity().getLocation(), Material.AIR); if(noBuildReason != null) { event.setCancelled(true); GriefPrevention.sendMessage(playerRemover, TextMode.Err, noBuildReason); } }