下面列出了org.bukkit.Material#LEAVES_2 ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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);
}
}
}
/**
* 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();
}
}
}
}
/**
* 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;
}