当前位置: 首页>>代码示例>>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;未经允许,请勿转载。