类org.bukkit.event.block.LeavesDecayEvent源码实例Demo

下面列出了怎么用org.bukkit.event.block.LeavesDecayEvent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: GriefDefender   文件: BlockEventHandler.java
@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);
    }
}
 
源代码2 项目: ExoticGarden   文件: PlantsListener.java
@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);
    }
}
 
源代码3 项目: IridiumSkyblock   文件: LeafDecayListener.java
@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);
    }
}
 
源代码4 项目: UhcCore   文件: LuckyLeavesListener.java
@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));
}
 
源代码5 项目: UhcCore   文件: FastLeavesDecayListener.java
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);
    }
}
 
源代码6 项目: UhcCore   文件: BlockListener.java
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()));
	}
}
 
源代码7 项目: UhcCore   文件: BlockListener.java
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));
		}
	});
}
 
源代码8 项目: ProjectAres   文件: EnvironmentControlListener.java
@EventHandler(priority = EventPriority.HIGH)
public void noBucket(final LeavesDecayEvent event) {
    event.setCancelled(true);
}
 
源代码9 项目: UhcCore   文件: FastLeavesDecayListener.java
@EventHandler
public void onLeaveDecay(LeavesDecayEvent e){
    onBlockBreak(e.getBlock());
}
 
源代码10 项目: UhcCore   文件: BlockListener.java
@EventHandler
public void onLeavesDecay(LeavesDecayEvent event){
	handleAppleDrops(event);
}
 
源代码11 项目: Survival-Games   文件: LoggingManager.java
@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);

}
 
 类所在包
 类方法
 同包方法