當前位置: 首頁>>代碼示例>>Java>>正文


Java InventoryType.SlotType方法代碼示例

本文整理匯總了Java中org.bukkit.event.inventory.InventoryType.SlotType方法的典型用法代碼示例。如果您正苦於以下問題:Java InventoryType.SlotType方法的具體用法?Java InventoryType.SlotType怎麽用?Java InventoryType.SlotType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.inventory.InventoryType的用法示例。


在下文中一共展示了InventoryType.SlotType方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateClick

import org.bukkit.event.inventory.InventoryType; //導入方法依賴的package包/類
/**
 * Check
 *
 * @return Click is valid
 */
private boolean validateClick(Player player, PlayerWrapper playerWrapper, Slot slot,
                              ActionType actionType, ItemStack currentItem, InventoryType.SlotType slotType) {
    if (playerWrapper != null) {
        if (player != playerWrapper.getPlayer()) {
            return false;
        }

        if (!PlayerUtils.checkLevel(player, slot.getRequiredLevel())) {
            PlayerUtils.sendMessage(player, RPGInventory.getLanguage().getMessage("error.level", slot.getRequiredLevel()));
            return false;
        }

        if (!slot.isFree() && !playerWrapper.isBuyedSlot(slot.getName()) && !InventoryManager.buySlot(player, playerWrapper, slot)) {
            return false;
        }
    }

    return !((actionType == ActionType.GET && slot.getSlotType() != Slot.SlotType.ACTION
            || actionType == ActionType.DROP) && slot.isCup(currentItem) && slotType != InventoryType.SlotType.QUICKBAR);
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:26,代碼來源:InventoryListener.java

示例2: windowClicked

import org.bukkit.event.inventory.InventoryType; //導入方法依賴的package包/類
/**
 * Called when an open window is clicked.
 */
default boolean windowClicked(InventoryView window,
                              Inventory inventory,
                              ClickType clickType,
                              InventoryType.SlotType slotType,
                              int slotIndex,
                              @Nullable ItemStack item) {
    return false;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:12,代碼來源:WindowListener.java

示例3: getSlotType

import org.bukkit.event.inventory.InventoryType; //導入方法依賴的package包/類
@Contract(pure = true)
public static InventoryType.SlotType getSlotType(InventoryType.SlotType slotType, int rawSlot) {
    if (rawSlot > 80) {
        return InventoryType.SlotType.QUICKBAR;
    }

    return slotType;
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:9,代碼來源:InventoryUtils.java

示例4: getSlot

import org.bukkit.event.inventory.InventoryType; //導入方法依賴的package包/類
@Nullable
public Slot getSlot(int slotId, InventoryType.SlotType slotType) {
    for (Slot slot : this.slots) {
        if (slotType == InventoryType.SlotType.QUICKBAR) {
            if ((slot.isQuick() || slot.getSlotType() == Slot.SlotType.SHIELD) && slot.getQuickSlot() == slotId) {
                return slot;
            }
        } else if (slot.containsSlot(slotId)) {
            return slot;
        }
    }

    return null;
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:15,代碼來源:SlotManager.java

示例5: updateShieldSlot

import org.bukkit.event.inventory.InventoryType; //導入方法依賴的package包/類
public static void updateShieldSlot(@NotNull Player player, @NotNull Inventory inventory, @NotNull Slot slot, int slotId,
                                    InventoryType.SlotType slotType, InventoryAction action,
                                    ItemStack currentItem, ItemStack cursor) {
    ActionType actionType = ActionType.getTypeOfAction(action);
    if (actionType == ActionType.GET) {
        if (slot.isCup(currentItem)) {
            return;
        }

        if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
            inventory.setItem(slot.getSlotId(), slot.getCup());
        } else {
            player.getEquipment().setItemInOffHand(new ItemStack(Material.AIR));
        }
    } else if (actionType == ActionType.SET) {
        if (slot.isCup(currentItem)) {
            currentItem = null;
            action = InventoryAction.PLACE_ALL;
        }

        if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
            inventory.setItem(slot.getSlotId(), cursor);
        } else {
            player.getEquipment().setItemInOffHand(cursor);
        }
    }

    InventoryManager.updateInventory(player, inventory, slotId, slotType, action, currentItem, cursor);
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:30,代碼來源:InventoryManager.java

示例6: updateQuickSlot

import org.bukkit.event.inventory.InventoryType; //導入方法依賴的package包/類
public static void updateQuickSlot(@NotNull Player player, @NotNull Inventory inventory, @NotNull Slot slot, int slotId,
                                   InventoryType.SlotType slotType, InventoryAction action,
                                   ItemStack currentItem, ItemStack cursor) {
    ActionType actionType = ActionType.getTypeOfAction(action);
    if (actionType == ActionType.GET) {
        if (slot.isCup(currentItem)) {
            return;
        }

        if (player.getInventory().getHeldItemSlot() == slot.getQuickSlot()) {
            InventoryUtils.heldFreeSlot(player, slot.getQuickSlot(), InventoryUtils.SearchType.NEXT);
        }

        if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
            inventory.setItem(slot.getSlotId(), slot.getCup());
        } else {
            player.getInventory().setItem(slot.getQuickSlot(), slot.getCup());
        }

        action = InventoryAction.SWAP_WITH_CURSOR;
        cursor = slot.getCup();
    } else if (actionType == ActionType.SET) {
        if (slot.isCup(currentItem)) {
            currentItem = null;
            action = InventoryAction.PLACE_ALL;
        }

        if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
            inventory.setItem(slot.getSlotId(), cursor);
        } else {
            player.getInventory().setItem(slot.getQuickSlot(), cursor);
        }
    }

    InventoryManager.updateInventory(player, inventory, slotId, slotType, action, currentItem, cursor);
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:37,代碼來源:InventoryManager.java

示例7: windowClicked

import org.bukkit.event.inventory.InventoryType; //導入方法依賴的package包/類
@Override
public boolean windowClicked(InventoryView window, Inventory inventory, ClickType clickType, InventoryType.SlotType slotType, int slotIndex, @Nullable ItemStack item) {
    return true;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:5,代碼來源:NavigatorInterface.java

示例8: updateInventory

import org.bukkit.event.inventory.InventoryType; //導入方法依賴的package包/類
private static void updateInventory(
        @NotNull Player player,
        @NotNull Inventory inventory,
        int slot,
        InventoryType.SlotType slotType,
        InventoryAction action,
        ItemStack currentItem,
        ItemStack cursorItem
) {
    if (ActionType.getTypeOfAction(action) == ActionType.DROP) {
        return;
    }

    if (action == InventoryAction.PLACE_ALL) {
        if (ItemUtils.isEmpty(currentItem)) {
            currentItem = cursorItem.clone();
        } else {
            currentItem.setAmount(currentItem.getAmount() + cursorItem.getAmount());
        }

        cursorItem = null;
    } else if (action == InventoryAction.PLACE_ONE) {
        if (ItemUtils.isEmpty(currentItem)) {
            currentItem = cursorItem.clone();
            currentItem.setAmount(1);
            cursorItem.setAmount(cursorItem.getAmount() - 1);
        } else if (currentItem.getMaxStackSize() < currentItem.getAmount() + 1) {
            currentItem.setAmount(currentItem.getAmount() + 1);
            cursorItem.setAmount(cursorItem.getAmount() - 1);
        }
    } else if (action == InventoryAction.PLACE_SOME) {
        cursorItem.setAmount(currentItem.getMaxStackSize() - currentItem.getAmount());
        currentItem.setAmount(currentItem.getMaxStackSize());
    } else if (action == InventoryAction.SWAP_WITH_CURSOR) {
        ItemStack tempItem = cursorItem.clone();
        cursorItem = currentItem.clone();
        currentItem = tempItem;
    } else if (action == InventoryAction.PICKUP_ALL) {
        cursorItem = currentItem.clone();
        currentItem = null;
    } else if (action == InventoryAction.PICKUP_HALF) {
        ItemStack item = currentItem.clone();
        if (currentItem.getAmount() % 2 == 0) {
            item.setAmount(item.getAmount() / 2);
            currentItem = item.clone();
            cursorItem = item.clone();
        } else {
            currentItem = item.clone();
            currentItem.setAmount(item.getAmount() / 2);
            cursorItem = item.clone();
            cursorItem.setAmount(item.getAmount() / 2 + 1);
        }
    } else if (action == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
        player.getInventory().addItem(currentItem);
        currentItem = null;
    }

    if (slotType == InventoryType.SlotType.QUICKBAR) {
        if (slot < 9) { // Exclude shield
            player.getInventory().setItem(slot, currentItem);
        }
    } else {
        inventory.setItem(slot, currentItem);
    }

    player.setItemOnCursor(cursorItem);
    player.updateInventory();
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:69,代碼來源:InventoryManager.java

示例9: getSlotType

import org.bukkit.event.inventory.InventoryType; //導入方法依賴的package包/類
@Override
public InventoryType.SlotType getSlotType() {
    return delegate.getSlotType();
}
 
開發者ID:EntryPointKR,項目名稱:MCLibrary,代碼行數:5,代碼來源:GUIClickEvent.java


注:本文中的org.bukkit.event.inventory.InventoryType.SlotType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。