本文整理汇总了Java中org.bukkit.Material.SAPLING属性的典型用法代码示例。如果您正苦于以下问题:Java Material.SAPLING属性的具体用法?Java Material.SAPLING怎么用?Java Material.SAPLING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.SAPLING属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TreeGrowChecker
@EventHandler
public void TreeGrowChecker(StructureGrowEvent event) {
if (ConfigPatch.safetyBonemeal) {
if(event.isFromBonemeal() == false) {
return;
}
List<BlockState> blocks = event.getBlocks();
int bs = blocks.size();
for(int i = 0;i<bs;i++){
Block block = blocks.get(i).getBlock();
if(block.getType() != Material.AIR && block.getType() != Material.SAPLING && block.getType() != event.getLocation().getBlock().getRelative(BlockFace.DOWN).getType()){
event.setCancelled(true);
if (event.getPlayer() != null) {
AzureAPI.log(event.getPlayer(), "§c这棵树生长区域有方块阻挡,请不要尝试利用骨粉BUG!");
return;
}
}
}
}
}
示例2: getTrackedTypeMaterial
public Material getTrackedTypeMaterial(String trackedType) {
for (Material material : harvestableCrops.keySet()) {
if (material.toString().equals(trackedType))
return material;
}
if (Material.MELON_BLOCK.toString().equals(trackedType))
return Material.MELON_BLOCK;
else if (Material.PUMPKIN.toString().equals(trackedType))
return Material.PUMPKIN;
for (Byte i = 0; i < 6; i++) {
if (getSaplingType(i).equals(trackedType)) // TODO: odd structure here
return Material.SAPLING;
}
for (TreeType treeType : TreeType.values()) {
if (treeType.toString().equals(trackedType)) {
if (treeType == TreeType.ACACIA || treeType == TreeType.DARK_OAK)
return Material.LOG_2;
else if (treeType == TreeType.BROWN_MUSHROOM)
return Material.HUGE_MUSHROOM_1;
else if (treeType == TreeType.RED_MUSHROOM)
return Material.HUGE_MUSHROOM_2;
else
return Material.LOG;
}
}
if (Material.CHORUS_PLANT.toString().equals(trackedType))
return Material.CHORUS_PLANT;
CropControl.getPlugin().debug("Unable to match tracked type material {0}", trackedType);
return null;
}
示例3: getTrackedSaplingMaterial
public Material getTrackedSaplingMaterial(String trackedType) {
for (Byte i = 0; i < 6; i++) {
if (getSaplingType(i).equals(trackedType))
return Material.SAPLING;
}
CropControl.getPlugin().debug("Unable to match tracked sapling type material {0}", trackedType);
return null;
}
示例4: onPlaceBlock
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlaceBlock(BlockPlaceEvent e) {
Block block = e.getBlock();
Material blockMaterial = block.getType();
int x = block.getX();
int y = block.getY();
int z = block.getZ();
WorldChunk chunk = CropControl.getDAO().getChunk(block.getChunk());
if (CropControl.getDAO().isTracked(block) == true) {
// We've got a replacement
CropControl.getPlugin().debug("Ghost object? Placement is overtop a tracked object at {0}, {1}, {2}", x, y, z);
handleRemoval(block, chunk);
}
if (harvestableCrops.containsKey(blockMaterial)) {
// we placed a block overtop an existing crop. Will be handled by a break event?
/*Crop crop = chunk.getCrop(x, y, z);
if (crop != null) {
crop.setRemoved();
CropControl.getPlugin().debug("Missed an event? Replacing a Crop at {0}, {1}, {2}", x, y, z);
//return;
}*/
// We've placed a crop!
Crop.create(chunk, x, y, z, blockMaterial.toString(), getBaseCropState(blockMaterial),
e.getPlayer().getUniqueId(), System.currentTimeMillis(), harvestableCrops.get(blockMaterial));
} else if (blockMaterial == Material.SAPLING) {
// we placed a block overtop an existing sapling. TODO: Do I need to remove sapling here, or will there be a break event?
/*Sapling sapling = chunk.getSapling(x, y, z);
if (sapling != null) {
sapling.setRemoved();
CropControl.getPlugin().debug("Missed an event? Replacing a Sapling at {0}, {1}, {2}", x, y, z);
//return;
}*/
// We've placed a sapling!
Sapling.create(chunk, x, y, z, getSaplingType(block.getData()),
e.getPlayer().getUniqueId(), System.currentTimeMillis(), false);
} else if (blockMaterial == Material.CHORUS_FLOWER) {
/*if (CropControl.getDAO().isTracked(block) == true) {
CropControl.getPlugin().debug("Ghost object? Placement is overtop a tracked object at {0}, {1}, {2}", x, y, z);
//return;
}*/
// TODO: Check if connected to an existing chorus tree.
// First register the "tree"
Tree chorusPlant = Tree.create(chunk, x, y, z, Material.CHORUS_PLANT.toString(),
e.getPlayer().getUniqueId(), System.currentTimeMillis());
// Then the component in the tree.
TreeComponent.create(chorusPlant, chunk, x, y, z, Material.CHORUS_PLANT.toString(),
e.getPlayer().getUniqueId(), false);
} else if (blockMaterial.isSolid()){ // check for cactus.
for (BlockFace face : CropControlEventHandler.directions) {
Block adj = block.getRelative(face);
if (Material.CACTUS.equals(adj.getType())) {
Location loc = adj.getLocation();
if (!pendingChecks.contains(loc)) {
pendingChecks.add(loc);
handleBreak(adj, BreakType.PLAYER, e.getPlayer().getUniqueId(), null);
}
}
}
}
}