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


Java Material.equals方法代碼示例

本文整理匯總了Java中org.bukkit.Material.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java Material.equals方法的具體用法?Java Material.equals怎麽用?Java Material.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.Material的用法示例。


在下文中一共展示了Material.equals方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getLineOfSight

import org.bukkit.Material; //導入方法依賴的package包/類
private List<Block> getLineOfSight(Set<Material> transparent, int maxDistance, int maxLength) {
    if (maxDistance > 120) {
        maxDistance = 120;
    }
    ArrayList<Block> blocks = new ArrayList<Block>();
    Iterator<Block> itr = new BlockIterator(this, maxDistance);
    while (itr.hasNext()) {
        Block block = itr.next();
        blocks.add(block);
        if (maxLength != 0 && blocks.size() > maxLength) {
            blocks.remove(0);
        }
        Material material = block.getType();
        if (transparent == null) {
            if (!material.equals(Material.AIR)) {
                break;
            }
        } else {
            if (!transparent.contains(material)) {
                break;
            }
        }
    }
    return blocks;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:26,代碼來源:CraftLivingEntity.java

示例2: onBlockBreak

import org.bukkit.Material; //導入方法依賴的package包/類
/**
 * Drops the smelted form of items that spawn when a block is broken.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
  Block block = event.getBlock();
  Material type = block.getType();

  BlockDropModule module = OpenUHC.getCurrentGame().getModuleHandler().getModule(BlockDropModule.class);
  if (type.equals(Material.IRON_ORE)) {
    module.addBlockDrop(block, new BlockDrop(new ItemStack(Material.IRON_INGOT), true));
    event.setExpToDrop(4);
  } else if (type.equals(Material.GOLD_ORE)) {
    module.addBlockDrop(block, new BlockDrop(new ItemStack(Material.GOLD_INGOT), true));
    event.setExpToDrop(8);
  } else if (type.equals(Material.POTATO)) {
    module.addBlockDrop(block, new BlockDrop(new ItemStack(Material.BAKED_POTATO), true));
    event.setExpToDrop(2);
  }
}
 
開發者ID:twizmwazin,項目名稱:OpenUHC,代碼行數:23,代碼來源:Cutclean.java

示例3: onCraftItem

import org.bukkit.Material; //導入方法依賴的package包/類
/**
 * Prevents players from crafting leather or iron armor.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onCraftItem(CraftItemEvent event) {
  Material result = event.getRecipe().getResult().getType();
  if (result.equals(Material.LEATHER_HELMET)
      || result.equals(Material.LEATHER_CHESTPLATE)
      || result.equals(Material.LEATHER_LEGGINGS)
      || result.equals(Material.LEATHER_BOOTS)) {
    event.setCancelled(true);
    event.getWhoClicked().sendMessage(ChatColor.RED + "You may not craft leather armor!");
  } else if (result.equals(Material.IRON_HELMET)
      || result.equals(Material.IRON_CHESTPLATE)
      || result.equals(Material.IRON_LEGGINGS)
      || result.equals(Material.IRON_BOOTS)) {
    event.setCancelled(true);
    event.getWhoClicked().sendMessage(ChatColor.RED + "You may not craft iron armor!");
  }
}
 
開發者ID:twizmwazin,項目名稱:OpenUHC,代碼行數:23,代碼來源:GoldRush.java

示例4: getTrackedCropMaterial

import org.bukkit.Material; //導入方法依賴的package包/類
public Material getTrackedCropMaterial(String _trackedType) {
	Material trackedType = Material.getMaterial(_trackedType);
	if (Material.MELON_BLOCK.equals(trackedType))
		return Material.MELON_BLOCK;
	else if (Material.PUMPKIN.equals(trackedType))
		return Material.PUMPKIN;
	else {
		for (Material material : harvestableCrops.keySet()) {
			if (material.equals(trackedType))
				return material;
		}
	}
	CropControl.getPlugin().debug("Unable to match tracked crop type material {0}", trackedType);
	return null;
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:16,代碼來源:CropControlEventHandler.java

示例5: teleportSpotUp

import org.bukkit.Material; //導入方法依賴的package包/類
public Location teleportSpotUp(Location loc, int min, int max) {
    int k = min;
    while (k < max) {
    	Material m = new Location(loc.getWorld(), loc.getBlockX(), k - 1, loc.getBlockZ()).getBlock().getType();
        Material m1 = new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ()).getBlock().getType();
        Material m2 = new Location(loc.getWorld(), loc.getBlockX(), (k + 1), loc.getBlockZ()).getBlock().getType();
        if (m1.equals(Material.AIR) && m2.equals(Material.AIR) && m.isSolid() && !m.equals(Material.SIGN_POST) && !m.equals(Material.WALL_SIGN)) {
            return new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ());
        }
        ++k;
    }
    return new Location(loc.getWorld(), loc.getBlockX(), loc.getWorld().getHighestBlockYAt(loc.getBlockX(), loc.getBlockZ()), loc.getBlockZ());
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:14,代碼來源:ElevatorListener.java

示例6: teleportSpotDown

import org.bukkit.Material; //導入方法依賴的package包/類
public Location teleportSpotDown(Location loc, int min, int max) {
    int k = min;
    while (k > max) {
    	Material m = new Location(loc.getWorld(), loc.getBlockX(), k - 1, loc.getBlockZ()).getBlock().getType();
        Material m1 = new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ()).getBlock().getType();
        Material m2 = new Location(loc.getWorld(), loc.getBlockX(), (k + 1), loc.getBlockZ()).getBlock().getType();
        if (m1.equals(Material.AIR) && m2.equals(Material.AIR) && m.isSolid() && !m.equals(Material.SIGN_POST) && !m.equals(Material.WALL_SIGN)) {
            return new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ());
        }
        --k;
    }
    return new Location(loc.getWorld(), loc.getBlockX(), loc.getWorld().getHighestBlockYAt(loc.getBlockX(), loc.getBlockZ()), loc.getBlockZ());
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:14,代碼來源:ElevatorListener.java


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