本文整理汇总了Java中org.bukkit.Material.WOOD_SPADE属性的典型用法代码示例。如果您正苦于以下问题:Java Material.WOOD_SPADE属性的具体用法?Java Material.WOOD_SPADE怎么用?Java Material.WOOD_SPADE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.WOOD_SPADE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAttack
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
if(event.isCancelled()) return;
if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
{
Player player = (Player)event.getDamager();
ItemStack item = player.getItemInHand();
if(item.getType() == Material.WOOD_SPADE)
{
item.setDurability((short)(item.getDurability() - 2));
}
}
}
示例2: onCraftItem
private void onCraftItem(Recipe recipe, CraftingInventory inventory)
{
if (recipe.getResult().getType() == Material.WOOD_SWORD)
inventory.setResult(new ItemStack(this.getMaterial(Material.WOOD_SWORD)));
else if (recipe.getResult().getType() == Material.WOOD_PICKAXE)
inventory.setResult(new ItemStack(this.getMaterial(Material.WOOD_PICKAXE)));
else if (recipe.getResult().getType() == Material.WOOD_AXE)
inventory.setResult(new ItemStack(this.getMaterial(Material.WOOD_AXE)));
else if (recipe.getResult().getType() == Material.WOOD_SPADE)
inventory.setResult(new ItemStack(this.getMaterial(Material.WOOD_SPADE)));
}
示例3: isTool
static boolean isTool(ItemStack item) {
if (item == null) return false;
final Material material = item.getType();
// shears
if (material == Material.SHEARS) return true;
// wood tools
if (material == Material.WOOD_SWORD || material == Material.WOOD_AXE || material == Material.WOOD_HOE || material == Material.WOOD_PICKAXE || material == Material.WOOD_SPADE) {
return true;
}
// stone tools
if (material == Material.STONE_SWORD || material == Material.STONE_AXE || material == Material.STONE_HOE || material == Material.STONE_PICKAXE || material == Material.STONE_SPADE) {
return true;
}
// iron tools
if (material == Material.IRON_SWORD || material == Material.IRON_AXE || material == Material.IRON_HOE || material == Material.IRON_PICKAXE || material == Material.IRON_SPADE) {
return true;
}
// gold tools
if (material == Material.GOLD_SWORD || material == Material.GOLD_AXE || material == Material.GOLD_HOE || material == Material.GOLD_PICKAXE || material == Material.GOLD_SPADE) {
return true;
}
// diamond tools
if (material == Material.DIAMOND_SWORD || material == Material.DIAMOND_AXE || material == Material.DIAMOND_HOE || material == Material.DIAMOND_PICKAXE || material == Material.DIAMOND_SPADE) {
return true;
}
return false;
}
示例4: onInventoryClick
@SuppressWarnings("deprecation")
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
if(event.getInventory().getTitle() != Survival.Words.get("Firestriker"))
return;
final Player player = (Player) event.getWhoClicked();
switch(event.getRawSlot())
{
case 1:
event.setCancelled(true);
player.closeInventory();
break;
case 2:
event.setCancelled(true);
if(event.getClick() == ClickType.LEFT)
{
if(event.getCursor() == null || event.getCursor().getType() == Material.AIR)
{
if(event.getInventory().getItem(2) == null || event.getInventory().getItem(2).getType() == Material.AIR)
{
if(event.getInventory().getItem(1) != null && event.getInventory().getItem(1).getType() == Material.WOOD_SPADE)
{
if(smeltCheck(event.getInventory(), event.getInventory().getItem(0)))
{
event.setCancelled(true);
Random randBurn = new Random();
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ITEM_FLINTANDSTEEL_USE, 1.0F, randBurn.nextFloat() * 0.4F + 0.8F);
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_GENERIC_BURN, 1.0F, randBurn.nextFloat() * 0.4F + 0.8F);
ItemStack i_smelt = event.getInventory().getItem(0);
i_smelt.setAmount(i_smelt.getAmount() - 1);
event.getInventory().setItem(0, i_smelt);
ItemStack i_firecracker = event.getInventory().getItem(1);
i_firecracker.setDurability((short)(i_firecracker.getDurability() + 7));
if(i_firecracker.getDurability() >= 56)
{
Random rand = new Random();
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
event.getInventory().setItem(1, null);
}
}
}
}
else
{
event.setCursor(event.getInventory().getItem(2));
event.getInventory().setItem(2, null);
}
}
else
event.setCancelled(true);
}
else
event.setCancelled(true);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, new Runnable()
{
public void run()
{
player.updateInventory();
}
}, 1L);
break;
}
}
示例5: onInventoryClick
@EventHandler
public void onInventoryClick(InventoryClickEvent e)
{
Inventory inv = e.getInventory();
if(inv instanceof AnvilInventory)
{
AnvilInventory anvil = (AnvilInventory)inv;
InventoryView view = e.getView();
int rawSlot = e.getRawSlot();
// compare raw slot to the inventory view to make sure we are in the upper inventory
if(rawSlot == view.convertSlot(rawSlot))
{
// 2 = result slot
if(rawSlot == 2)
{
// item in the left slot
ItemStack item = anvil.getContents()[0];
if(item != null)
{
if
(
item.getType() == Material.GOLD_AXE
|| item.getType() == Material.GOLD_PICKAXE
|| item.getType() == Material.GOLD_SPADE
|| item.getType() == Material.GOLD_HOE
|| item.getType() == Material.GOLD_SWORD
|| item.getType() == Material.WOOD_AXE
|| item.getType() == Material.WOOD_PICKAXE
|| item.getType() == Material.WOOD_SPADE
|| item.getType() == Material.WOOD_HOE
|| item.getType() == Material.WOOD_SWORD
)
{
e.setCancelled(true);
e.getWhoClicked().closeInventory();
e.getWhoClicked().sendMessage(ChatColor.RED + Survival.Words.get("You cannot rename or repair ") + item.getItemMeta().getDisplayName() + ChatColor.RED + Survival.Words.get("period"));
}
}
}
}
}
}