Java Code Examples for org.bukkit.event.block.BlockGrowEvent#setCancelled()
The following examples show how to use
org.bukkit.event.block.BlockGrowEvent#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: BlockGrowListener.java From IridiumSkyblock with GNU General Public License v2.0 | 6 votes |
@EventHandler public void onBlockGrow(BlockGrowEvent event) { try { final Block block = event.getBlock(); final Location location = block.getLocation(); final IslandManager islandManager = IridiumSkyblock.getIslandManager(); final Island island = islandManager.getIslandViaLocation(location); if (island == null) return; if (island.getFarmingBooster() == 0) return; final Material material = block.getType(); if (!XBlock.isCrops(material)) return; event.setCancelled(true); final Crops crops = new Crops(CropState.RIPE); final BlockState blockState = block.getState(); blockState.setData(crops); blockState.update(); } catch (Exception e) { IridiumSkyblock.getInstance().sendErrorMessage(e); } }
Example 2
Source File: BlockEventHandler.java From GriefDefender with MIT License | 6 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onBlockGrow(BlockGrowEvent event) { final Block block = event.getBlock(); final World world = event.getBlock().getWorld(); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) { return; } final Location location = block.getLocation(); final GDClaim targetClaim = this.storage.getClaimAt(location); if (targetClaim.isWilderness()) { return; } final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.BLOCK_GROW, null, event.getBlock(), (GDPermissionUser) null, TrustTypes.BUILDER, false); if (result == Tristate.FALSE) { event.setCancelled(true); return; } }
Example 3
Source File: FarmYield.java From GlobalWarming with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler public void onCropGrow(BlockGrowEvent event) { WorldClimateEngine worldEngine = ClimateEngine.getInstance().getClimateEngine(event.getBlock().getWorld().getUID()); if (worldEngine != null && worldEngine.isEffectEnabled(ClimateEffectType.FARM_YIELD)) { Distribution distribution = cropDistribution.get(event.getBlock().getType()); if (distribution != null) { double random = GlobalWarming.getInstance().getRandom().nextDouble(); double chance = distribution.getValue(worldEngine.getTemperature()); if (chance / 100.f <= random) { event.setCancelled(true); } } } }
Example 4
Source File: BlockListener.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onBlockGrow(BlockGrowEvent grow) { Game game = BedwarsRel.getInstance().getGameManager().getGameByLocation(grow.getBlock().getLocation()); if (game == null) { return; } grow.setCancelled(true); }
Example 5
Source File: ShopItemListener.java From ShopChest with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGH) public void onBlockGrow(BlockGrowEvent e) { Block newBlock = e.getNewState().getBlock(); if (shopUtils.isShop(newBlock.getLocation()) || shopUtils.isShop(newBlock.getRelative(BlockFace.DOWN).getLocation())) { e.setCancelled(true); } }
Example 6
Source File: BlockListener.java From civcraft with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.NORMAL) public void onBlockGrowEvent(BlockGrowEvent event) { bcoord.setFromLocation(event.getBlock().getLocation().add(0, -1, 0)); if (CivGlobal.vanillaGrowthLocations.contains(bcoord)) { /* Allow vanilla growth on these plots. */ return; } Block b = event.getBlock(); if (Farm.isBlockControlled(b)) { event.setCancelled(true); } }
Example 7
Source File: BukkitPlotListener.java From PlotMe-Core with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockGrow(BlockGrowEvent event) { Location location = BukkitUtil.adapt(event.getBlock().getLocation()); if (manager.isPlotWorld(location)) { PlotId id = manager.getPlotId(location); if (id == null) { event.setCancelled(true); } else { event.setCancelled(api.isPlotLocked(id)); } } }
Example 8
Source File: WorldFreeze.java From CardinalPGM with MIT License | 4 votes |
@EventHandler public void onBlockGrow(BlockGrowEvent event) { if (!match.isRunning()) { event.setCancelled(true); } }
Example 9
Source File: BlockEventRegion.java From CardinalPGM with MIT License | 4 votes |
@EventHandler public void onBlockGrow(BlockGrowEvent event) { if (filter.evaluate(event.getBlock(), event).equals(FilterState.DENY) && region.contains(new BlockRegion(null, event.getBlock().getLocation().toVector()))) { event.setCancelled(true); } }