本文整理汇总了Java中org.bukkit.event.inventory.InventoryClickEvent.setCursor方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryClickEvent.setCursor方法的具体用法?Java InventoryClickEvent.setCursor怎么用?Java InventoryClickEvent.setCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.inventory.InventoryClickEvent
的用法示例。
在下文中一共展示了InventoryClickEvent.setCursor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@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;
}
}