本文整理汇总了Java中org.bukkit.event.player.PlayerSwapHandItemsEvent.getMainHandItem方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerSwapHandItemsEvent.getMainHandItem方法的具体用法?Java PlayerSwapHandItemsEvent.getMainHandItem怎么用?Java PlayerSwapHandItemsEvent.getMainHandItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerSwapHandItemsEvent
的用法示例。
在下文中一共展示了PlayerSwapHandItemsEvent.getMainHandItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onHandSwap
import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入方法依赖的package包/类
@EventHandler
public void onHandSwap(PlayerSwapHandItemsEvent event) {
Player player = event.getPlayer();
Slot offHandSlot = SlotManager.instance().getShieldSlot();
Slot mainHandSlot = SlotManager.instance().getSlot(player.getInventory().getHeldItemSlot(), InventoryType.SlotType.QUICKBAR);
ItemStack newOffHandItem = event.getOffHandItem();
ItemStack newMainHandItem = event.getMainHandItem();
if (offHandSlot == null && mainHandSlot == null) {
return;
}
if (offHandSlot != null) {
if (!ItemUtils.isEmpty(newOffHandItem)
&& !InventoryManager.validateUpdate(player, ActionType.SET, offHandSlot, newOffHandItem)) {
event.setCancelled(true);
return;
}
}
if (mainHandSlot != null) {
if (!ItemUtils.isEmpty(newOffHandItem) && mainHandSlot.isCup(newOffHandItem)) {
event.setCancelled(true);
return;
}
if (!InventoryManager.validateUpdate(player, ActionType.SET, mainHandSlot, newMainHandItem)) {
event.setCancelled(true);
}
}
}
示例2: onItemSwap
import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemSwap(PlayerSwapHandItemsEvent event){
ItemStack main = event.getMainHandItem();
ItemStack off = event.getOffHandItem();
Account account = new Account(event.getPlayer());
ca.damocles.accountsystem.Character character = account.getLoadedCharacter();
if(main.equals(soulApple(character))){
event.setCancelled(true);
}
if(off.equals(soulApple(character))){
event.setCancelled(true);
}
return;
}