org.bukkit.event.block.LeavesDecayEvent Java Examples
The following examples show how to use
org.bukkit.event.block.LeavesDecayEvent.
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: BlockEventHandler.java From GriefDefender with MIT License | 6 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onBlockDecay(LeavesDecayEvent event) { if (!GDFlags.LEAF_DECAY) { return; } final World world = event.getBlock().getWorld(); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) { return; } Location location = event.getBlock().getLocation(); GDClaim targetClaim = this.storage.getClaimAt(location); // check overrides final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.LEAF_DECAY, event.getBlock().getWorld(), event.getBlock(), (GDPermissionUser) null); if (result == Tristate.FALSE) { event.setCancelled(true); } }
Example #2
Source File: PlantsListener.java From ExoticGarden with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onDecay(LeavesDecayEvent e) { if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(e.getBlock().getWorld())) { return; } String id = BlockStorage.checkID(e.getBlock()); if (id != null) { for (Berry berry : ExoticGarden.getBerries()) { if (id.equalsIgnoreCase(berry.getID())) { e.setCancelled(true); return; } } } dropFruitFromTree(e.getBlock()); ItemStack item = BlockStorage.retrieve(e.getBlock()); if (item != null) { e.setCancelled(true); e.getBlock().setType(Material.AIR); e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), item); } }
Example #3
Source File: LeafDecayListener.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler public void onLeafDecay(LeavesDecayEvent event) { try { final Block block = event.getBlock(); final Location location = block.getLocation(); final IslandManager islandManager = IridiumSkyblock.getIslandManager(); if (!islandManager.isIslandWorld(location)) return; if (!IridiumSkyblock.getConfiguration().disableLeafDecay) return; event.setCancelled(true); } catch (Exception e) { IridiumSkyblock.getInstance().sendErrorMessage(e); } }
Example #4
Source File: LuckyLeavesListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onLeaveDecay(LeavesDecayEvent e){ int random = RandomUtils.randomInteger(0, 200); if (random > 1){ return; } // add gapple e.getBlock().getWorld().dropItem(e.getBlock().getLocation().add(.5,0,.5),new ItemStack(Material.GOLDEN_APPLE)); }
Example #5
Source File: FastLeavesDecayListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
private void onBlockBreak(Block block){ for (BlockFace face : NEIGHBOURS) { final Block relative = block.getRelative(face); if (!UniversalMaterial.isLeaves(relative.getType())){ continue; // Not a leave so don't fast decay } if (findLog(relative, DECAY_RANGE)){ continue; // A log is too close so don't fast decay } Bukkit.getScheduler().runTaskLater(UhcCore.getPlugin(), new Runnable() { @Override public void run() { if (!UniversalMaterial.isLeaves(relative.getType())){ return; // Double check to make sure the block hasn't changed since } LeavesDecayEvent event = new LeavesDecayEvent(relative); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { relative.breakNaturally(); relative.getWorld().playSound(relative.getLocation(), UniversalSound.BLOCK_GRASS_BREAK.getSound(), 1, 1); } } }, 5); } }
Example #6
Source File: BlockListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
private void handleShearedLeaves(BlockBreakEvent e){ MainConfiguration cfg = GameManager.getGameManager().getConfiguration(); if (!cfg.getAppleDropsFromShearing()){ return; } if (!UniversalMaterial.isLeaves(e.getBlock().getType())){ return; } if (e.getPlayer().getItemInHand().getType() == Material.SHEARS){ Bukkit.getPluginManager().callEvent(new LeavesDecayEvent(e.getBlock())); } }
Example #7
Source File: BlockListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
private void handleAppleDrops(LeavesDecayEvent e){ MainConfiguration cfg = GameManager.getGameManager().getConfiguration(); Block block = e.getBlock(); Material type = block.getType(); boolean isOak; if (cfg.getAppleDropsFromAllTrees()){ if (type != UniversalMaterial.OAK_LEAVES.getType()) { e.getBlock().setType(UniversalMaterial.OAK_LEAVES.getType()); } isOak = true; }else { isOak = type == UniversalMaterial.OAK_LEAVES.getType() || type == UniversalMaterial.DARK_OAK_LEAVES.getType(); } if (!isOak){ return; // Will never drop apples so drops don't need to increase } double percentage = cfg.getAppleDropPercentage()-0.5; if (percentage <= 0){ return; // No added drops } // Number 0-100 double random = RandomUtils.randomInteger(0, 200)/2D; if (random > percentage){ return; // Number above percentage so no extra apples. } // Add apple to drops Bukkit.getScheduler().runTask(UhcCore.getPlugin(), new Runnable() { @Override public void run() { block.getWorld().dropItem(block.getLocation().add(.5, .5, .5), new ItemStack(Material.APPLE)); } }); }
Example #8
Source File: EnvironmentControlListener.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGH) public void noBucket(final LeavesDecayEvent event) { event.setCancelled(true); }
Example #9
Source File: FastLeavesDecayListener.java From UhcCore with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onLeaveDecay(LeavesDecayEvent e){ onBlockBreak(e.getBlock()); }
Example #10
Source File: BlockListener.java From UhcCore with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onLeavesDecay(LeavesDecayEvent event){ handleAppleDrops(event); }
Example #11
Source File: LoggingManager.java From Survival-Games with GNU General Public License v3.0 | 3 votes |
@EventHandler(priority = EventPriority.MONITOR) public void blockChanged(LeavesDecayEvent e){ if(e.isCancelled())return; logBlockDestoryed(e.getBlock()); i.put("LDECAY", i.get("LDECAY")+1); // System.out.println(9); }