當前位置: 首頁>>代碼示例>>Java>>正文


Java Material.SAPLING屬性代碼示例

本文整理匯總了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;
                }
    		}
    	}
    }
}
 
開發者ID:GelandiAssociation,項目名稱:EscapeLag,代碼行數:20,代碼來源:BonemealDupePatch.java

示例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;
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:35,代碼來源:CropControlEventHandler.java

示例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;
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:8,代碼來源:CropControlEventHandler.java

示例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);
				}		
			}
		}
	}
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:66,代碼來源:CropControlEventHandler.java


注:本文中的org.bukkit.Material.SAPLING屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。