当前位置: 首页>>代码示例>>Java>>正文


Java InventoryView.countSlots方法代码示例

本文整理汇总了Java中org.bukkit.inventory.InventoryView.countSlots方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryView.countSlots方法的具体用法?Java InventoryView.countSlots怎么用?Java InventoryView.countSlots使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.inventory.InventoryView的用法示例。


在下文中一共展示了InventoryView.countSlots方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildWindowClickPacket

import org.bukkit.inventory.InventoryView; //导入方法依赖的package包/类
public Object buildWindowClickPacket(Player p, ItemTransaction storage) {
    if (!supported) {
        return null;
    }
    InventoryView inv = p.getOpenInventory();
    short slotId = storage.getSlotId();
    if (slotId > inv.countSlots()) {
        return null; // wrong container open?
    }
    ItemStack itemstack = inv.getItem(slotId);
    if (itemstack == null) {
        return null;
    }
    Object packet = null;
    try {
        packet = windowClickPacketClass.newInstance();
        Object nmsItem = nmsItemMethod.invoke(null, itemstack);
        ReflectionUtil.set(packet, "a", (int) storage.getWindowId());
        ReflectionUtil.set(packet, "slot", (int) slotId);
        ReflectionUtil.set(packet, "button", 0); // shift + left mouse click
        ReflectionUtil.set(packet, "d", storage.getActionId());
        ReflectionUtil.set(packet, "item", nmsItem);
        int protocolId = ProtocolRegistry.SERVER_PROTOCOL;
        if (protocolId == ProtocolVersion.v1_8.getId()) {
            ReflectionUtil.set(packet, "shift", 1);
        } else if (protocolId >= ProtocolVersion.v1_9.getId()) { // 1.9+
            ReflectionUtil.set(packet, "shift", clickTypeEnum);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return packet;
}
 
开发者ID:MylesIsCool,项目名称:ViaVersion,代码行数:34,代码来源:BukkitInventoryQuickMoveProvider.java

示例2: getSlotType

import org.bukkit.inventory.InventoryView; //导入方法依赖的package包/类
public static SlotType getSlotType(InventoryView inventory, int slot) {
    SlotType type = SlotType.CONTAINER;
    if (inventory == null) return type; // Cauldron - modded inventories with no Bukkit wrapper
    if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
        switch(inventory.getType()) {
        case FURNACE:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else if(slot == 1) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BREWING:
            if (slot == 3) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case ENCHANTING:
            type = SlotType.CRAFTING;
            break;
        case WORKBENCH:
        case CRAFTING:
            if (slot == 0) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case MERCHANT:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BEACON:
            type = SlotType.CRAFTING;
            break;
        case ANVIL:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        default:
            // Nothing to do, it's a CONTAINER slot
        }
    } else {
        if (slot == -999) {
            type = SlotType.OUTSIDE;
        } else if (inventory.getType() == InventoryType.CRAFTING) {
            if (slot < 9) {
            type = SlotType.ARMOR;
            } else if (slot > 35) {
                type = SlotType.QUICKBAR;
            }
        } else if (slot >= (inventory.countSlots() - 9)) {
            type = SlotType.QUICKBAR;
        }
    }
    return type;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:68,代码来源:CraftInventoryView.java

示例3: getSlotType

import org.bukkit.inventory.InventoryView; //导入方法依赖的package包/类
public static SlotType getSlotType(InventoryView inventory, int slot) {
    SlotType type = SlotType.CONTAINER;
    if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
        switch(inventory.getType()) {
        case FURNACE:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else if(slot == 1) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BREWING:
            if (slot == 3) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case ENCHANTING:
            type = SlotType.CRAFTING;
            break;
        case WORKBENCH:
        case CRAFTING:
            if (slot == 0) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case MERCHANT:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BEACON:
            type = SlotType.CRAFTING;
            break;
        case ANVIL:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        default:
            // Nothing to do, it's a CONTAINER slot
        }
    } else {
        if (slot == -999) {
            type = SlotType.OUTSIDE;
        } else if (inventory.getType() == InventoryType.CRAFTING) {
            if (slot < 9) {
                type = SlotType.ARMOR;
            } else if (slot > 35) {
                type = SlotType.QUICKBAR;
            }
        } else if (slot >= (inventory.countSlots() - 9)) {
            type = SlotType.QUICKBAR;
        }
    }
    return type;
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:67,代码来源:CraftInventoryView.java


注:本文中的org.bukkit.inventory.InventoryView.countSlots方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。