本文整理匯總了Java中org.bukkit.inventory.PlayerInventory.getItemInHand方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerInventory.getItemInHand方法的具體用法?Java PlayerInventory.getItemInHand怎麽用?Java PlayerInventory.getItemInHand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.inventory.PlayerInventory
的用法示例。
在下文中一共展示了PlayerInventory.getItemInHand方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onInteract
import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onInteract(PlayerInteractEvent clickEvent) {
Player player = clickEvent.getPlayer();
PlayerInventory inventory = player.getInventory();
ItemStack mainHandItem;
if (mainHandSupported) {
mainHandItem = inventory.getItemInMainHand();
} else {
mainHandItem = inventory.getItemInHand();
}
if (isOurGraph(mainHandItem)) {
inventory.setItemInMainHand(new ItemStack(Material.AIR));
}
}
示例2: check
import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public boolean check(String playerID) {
PlayerInventory inv = PlayerConverter.getPlayer(playerID).getInventory();
ItemStack item = null;
try {
item = (!offhand) ? inv.getItemInMainHand() : inv.getItemInOffHand();
} catch (LinkageError e) {
item = inv.getItemInHand();
}
if (questItem.compare(item)) {
return true;
}
return false;
}