@EventHandler public void onEntityInteract(EntityInteractEvent event) { if (!(event.getEntity() instanceof Player)) { return; } if (event.getBlock().getType() != Material.SOIL && event.getBlock().getType() != Material.WHEAT) { return; } Player player = (Player) event.getEntity(); Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player); if (game == null) { return; } if (game.getState() == GameState.WAITING) { event.setCancelled(true); } }
@EventHandler(priority = EventPriority.LOWEST) public void onEntityInteract(final EntityInteractEvent event) { final Block block = event.getBlock(); // Confirms that the block is not null. if (block == null) { return; } final Location location = block.getLocation(); if (!reinforcementManager.isWorldActive(location.getWorld().getName())) { return; } // If the affected block is soil, and it is reinforced, then the soil is not allowed to decay. if (Material.SOIL.equals(block.getType()) && reinforcementManager.isReinforced(location)) { event.setCancelled(true); } }
@EventHandler public void EntityFarmChecker(EntityInteractEvent event){ if(ConfigFunction.ProtectFarmenable){ if(event.getEntityType() != EntityType.PLAYER){ Block block = event.getBlock(); if(block.getType() == Material.SOIL||block.getType() == Material.CROPS){ event.setCancelled(true); } } } }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onMobJump(EntityInteractEvent e) { if (!cm.farmProtectEnabled) { return; } if (e.getEntityType() == EntityType.PLAYER) { return; } if (e.getBlock().getType() == Material.SOIL) { e.setCancelled(true); } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onEntityInteract(EntityInteractEvent event) { if(!GriefPrevention.instance.config_creaturesTrampleCrops && event.getBlock().getType() == Material.SOIL) { event.setCancelled(true); } }
@EventHandler public void onEntityInteract(EntityInteractEvent event) { BlockProtection blockProtection = this.module.getProtectManager().getBlockProtection(event.getBlock().getLocation()); if(blockProtection.exists()) { event.setCancelled(true); } }
@EventHandler(priority = EventPriority.NORMAL) public void OnEntityInteractEvent(EntityInteractEvent event) { if (event.getBlock() != null) { if (CivSettings.switchItems.contains(event.getBlock().getType())) { coord.setFromLocation(event.getBlock().getLocation()); TownChunk tc = CivGlobal.getTownChunk(coord); if (tc == null) { return; } /* A non-player entity is trying to trigger something, if interact permission is * off for others then disallow it. */ if (tc.perms.interact.isPermitOthers()) { return; } if (event.getEntity() instanceof Player) { CivMessage.sendErrorNoRepeat((Player)event.getEntity(), "You do not have permission to interact here..."); } event.setCancelled(true); } } }
@EventHandler public void onEntityInteract(EntityInteractEvent event){ if(event.getBlock().getType() == Material.WOOD_BUTTON){ if(event.getEntity() instanceof Arrow){ Arrow a = (Arrow) event.getEntity(); if(a.getShooter() instanceof Player){ Player p = (Player) a.getShooter(); if(!canBuild(p, event.getBlock())){ event.setCancelled(true); } } } } }
@EventHandler public void entityInteractEvent (EntityInteractEvent event) { System.out.println("An entity has interacted with something."); System.out.println("The block is " + event.getBlock().getType().name().toString() + "."); if (event.getBlock().getType() == Material.STONE_PLATE) { Block b = event.getBlock(); if (!(getMinePlacer(b) == null)) { System.out.println("Mine will now be explodified."); explodeMine(b, event.getEntity(), 5); } } }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityInteractEvent(final ExtendedEntityInteractEvent ext) { final EntityInteractEvent event = (EntityInteractEvent)ext.getBaseEvent(); if (event.getBlock().getType() == Material.SOIL) { if (ext.getRegion() != null && ext.getRegion().getFlag(Flag.FARM)) { event.setCancelled(true); } } }
@EventHandler public void onInteract(EntityInteractEvent e) { if(e.isCancelled()) { return; } if(e.getEntity() instanceof LivingEntity && e.getEntity().getType() != EntityType.PLAYER) { if(e.getBlock().getType() == Material.STONE_PLATE) { e.setCancelled(true); } } }
@Test public void shouldHandleSimpleEvents() { withServiceMock(listenerService) .check(listener::onEntityTarget, EntityTargetEvent.class) .check(listener::onFoodLevelChange, FoodLevelChangeEvent.class) .check(listener::onShoot, EntityShootBowEvent.class) .check(listener::onEntityInteract, EntityInteractEvent.class) .check(listener::onLowestEntityInteract, EntityInteractEvent.class); }
@EventHandler (priority = EventPriority.LOW, ignoreCancelled = true) public void onEntityInteract(EntityInteractEvent event) { // Prevent trampling from other Entities final Material mat = event.getBlock().getType(); final Entity entity = event.getEntity(); //TODO: Placement source is generic, not limited to soil or soulsand if (entity instanceof LivingEntity && (mat == Material.SOIL || mat == Material.SOUL_SAND)) { event.setCancelled(true); } }
@EventHandler public void onEntityInteract(EntityInteractEvent event) { if (event.getBlock().getType() == Material.SOIL) event.setCancelled(true); }
@EventHandler public void onEntityEvent(EntityInteractEvent e) { RedProtect.get().logger.debug("RPEntityListener - Is EntityInteractEvent"); }
@EventHandler(priority = EventPriority.HIGHEST) public void onEntityInteractEvent(EntityInteractEvent event) { if (!RuleNoBreak.RULE.check(event.getEntity())) return; event.setCancelled(true); }
@EventHandler(priority = EventPriority.MONITOR) public void onEntityInteractEvent(EntityInteractEvent event) { }
private void n(World world, int i, int j, int k) { int l = world.getData(i, j, k); int i1 = l & 7; boolean flag = (l & 8) != 0; this.d(l); List list = world.a(EntityArrow.class, AxisAlignedBB.a().a((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) j + this.maxY, (double) k + this.maxZ)); boolean flag1 = !list.isEmpty(); // CraftBukkit start - Call interact event when arrows turn on wooden buttons if (flag != flag1 && flag1) { org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); boolean allowed = false; // If all of the events are cancelled block the button press, else allow for (Object object : list) { if (object != null) { EntityInteractEvent event = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block); world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { allowed = true; break; } } } if (!allowed) { return; } } // CraftBukkit end if (flag1 && !flag) { world.setData(i, j, k, i1 | 8, 3); this.d(world, i, j, k, i1); world.g(i, j, k, i, j, k); world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); } if (!flag1 && flag) { world.setData(i, j, k, i1, 3); this.d(world, i, j, k, i1); world.g(i, j, k, i, j, k); world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.5F); } if (flag1) { world.a(i, j, k, this.id, this.a(world)); } }
private void func_150046_n(World p_150046_1_, int p_150046_2_, int p_150046_3_, int p_150046_4_) { int l = p_150046_1_.getBlockMetadata(p_150046_2_, p_150046_3_, p_150046_4_); int i1 = l & 7; boolean flag = (l & 8) != 0; this.func_150043_b(l); List list = p_150046_1_.getEntitiesWithinAABB(EntityArrow.class, AxisAlignedBB.getBoundingBox((double)p_150046_2_ + this.minX, (double)p_150046_3_ + this.minY, (double)p_150046_4_ + this.minZ, (double)p_150046_2_ + this.maxX, (double)p_150046_3_ + this.maxY, (double)p_150046_4_ + this.maxZ)); boolean flag1 = !list.isEmpty(); // CraftBukkit start - Call interact event when arrows turn on wooden buttons if (flag != flag1 && flag1) { org.bukkit.block.Block block = p_150046_1_.getWorld().getBlockAt(p_150046_2_, p_150046_3_, p_150046_4_); boolean allowed = false; // If all of the events are cancelled block the button press, else allow for (Object object : list) { if (object != null) { EntityInteractEvent event = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block); p_150046_1_.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { allowed = true; break; } } } if (!allowed) { return; } } // CraftBukkit end if (flag1 && !flag) { p_150046_1_.setBlockMetadataWithNotify(p_150046_2_, p_150046_3_, p_150046_4_, i1 | 8, 3); this.func_150042_a(p_150046_1_, p_150046_2_, p_150046_3_, p_150046_4_, i1); p_150046_1_.markBlockRangeForRenderUpdate(p_150046_2_, p_150046_3_, p_150046_4_, p_150046_2_, p_150046_3_, p_150046_4_); p_150046_1_.playSoundEffect((double)p_150046_2_ + 0.5D, (double)p_150046_3_ + 0.5D, (double)p_150046_4_ + 0.5D, "random.click", 0.3F, 0.6F); } if (!flag1 && flag) { p_150046_1_.setBlockMetadataWithNotify(p_150046_2_, p_150046_3_, p_150046_4_, i1, 3); this.func_150042_a(p_150046_1_, p_150046_2_, p_150046_3_, p_150046_4_, i1); p_150046_1_.markBlockRangeForRenderUpdate(p_150046_2_, p_150046_3_, p_150046_4_, p_150046_2_, p_150046_3_, p_150046_4_); p_150046_1_.playSoundEffect((double)p_150046_2_ + 0.5D, (double)p_150046_3_ + 0.5D, (double)p_150046_4_ + 0.5D, "random.click", 0.3F, 0.5F); } if (flag1) { p_150046_1_.scheduleBlockUpdate(p_150046_2_, p_150046_3_, p_150046_4_, this, this.tickRate(p_150046_1_)); } }
@EventHandler public void soilChangeEntity(EntityInteractEvent event) { if (event.getEntityType() != EntityType.PLAYER && event.getBlock().getType().equals(Material.SOIL)) { event.setCancelled(true); } }
public ExtendedEntityInteractEvent(final RegionDb db, final EntityInteractEvent event) { super(db.getPlugin(), event); this.regions = db.getAllByLocation(event.getBlock().getLocation()); this.region = db.getPrior(this.regions); }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onEntityInteract(final EntityInteractEvent event) { Bukkit.getPluginManager().callEvent(new ExtendedEntityInteractEvent(this.getPlugin().getDb(), event)); }
@EventHandler(priority = EventPriority.HIGH) public void onEntityInteract(final EntityInteractEvent event) { if (Zones.inNoDemigodsZone(event.getEntity().getLocation()) || !(event.getEntity() instanceof Projectile) || DemigodsStructureType.Util.getInRadiusWithFlag(event.getBlock().getLocation(), DemigodsStructureType.Flag.NO_GRIEFING) == null) return; event.setCancelled(true); }
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onEntityInteract(EntityInteractEvent event) { if (listenerService.shouldCancelEvent(event)) { event.setCancelled(true); } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onLowestEntityInteract(EntityInteractEvent event) { if (listenerService.shouldCancelEvent(event)) { event.setCancelled(true); } }