Java Code Examples for org.bukkit.Material#LOG_2

The following examples show how to use org.bukkit.Material#LOG_2 . 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: NetherPortals.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Converts trees to gravel and glowstone
 * 
 * @param e - event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());

    if (!Settings.netherTrees) {
        return;
    }
    if (!Settings.createNether || ASkyBlock.getNetherWorld() == null) {
        return;
    }
    // Check world
    if (!e.getLocation().getWorld().equals(ASkyBlock.getNetherWorld())) {
        return;
    }
    for (BlockState b : e.getBlocks()) {
        if (b.getType() == Material.LOG || b.getType() == Material.LOG_2) {
            b.setType(Material.GRAVEL);
        } else if (b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
            b.setType(Material.GLOWSTONE);
        }
    }
}
 
Example 2
Source File: EntityLimits.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Prevents trees from growing outside of the protected area.
 *
 * @param e - event
 */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    // Check world
    if (!IslandGuard.inWorld(e.getLocation())) {
        return;
    }
    // Check if this is on an island
    Island island = plugin.getGrid().getIslandAt(e.getLocation());
    if (island == null || island.isSpawn()) {
        return;
    }
    Iterator<BlockState> it = e.getBlocks().iterator();
    while (it.hasNext()) {
        BlockState b = it.next();
        if (b.getType() == Material.LOG || b.getType() == Material.LOG_2
                || b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
            if (!island.onIsland(b.getLocation())) {
                it.remove();
            }
        }
    }
}
 
Example 3
Source File: Wood.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Correct the block type for certain species-type combinations.
 *
 * @param type    The desired type
 * @param species The required species
 * @return The actual type for this species given the desired type
 */
private static Material getSpeciesType(Material type, TreeSpecies species) {
    switch (species) {
        case GENERIC:
        case REDWOOD:
        case BIRCH:
        case JUNGLE:
            switch (type) {
                case LOG_2:
                    return Material.LOG;
                case LEAVES_2:
                    return Material.LEAVES;
                default:
            }
            break;
        case ACACIA:
        case DARK_OAK:
            switch (type) {
                case LOG:
                    return Material.LOG_2;
                case LEAVES:
                    return Material.LEAVES_2;
                default:
            }
            break;
    }
    return type;
}