Java Code Examples for org.bukkit.event.inventory.InventoryType#getDefaultSize()

The following examples show how to use org.bukkit.event.inventory.InventoryType#getDefaultSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MenuLoader.java    From TrMenu with MIT License 5 votes vote down vote up
/**
 * 取得一个图标在形状中的位置
 *
 * @param type  容器类型
 * @param shape 布局
 * @param key   按钮字符
 * @return 槽位
 */
private static List<Integer> locateButton(List<String> shape, InventoryType type, char key) {
    shape = fixShape(shape);
    List<Integer> slots = Lists.newArrayList();
    if (shape == null || shape.isEmpty()) {
        return slots;
    }
    int length = 9;
    if (type != null) {
        try {
            if (type.getDefaultSize() == 9) {
                length = 3;
            }
        } catch (Throwable ignored) {
        }
    }
    for (int line = 1; line <= shape.size(); line++) {
        String l = shape.get(line - 1);
        for (int index = 1; index <= l.toCharArray().length; index++) {
            if (key == l.charAt(index - 1)) {
                int slot = length * (line - 1) + index - 1;
                slots.add(slot);
            }
        }
    }
    return slots;
}
 
Example 2
Source File: CraftInventoryCustom.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public MinecraftInventory(InventoryHolder owner, InventoryType type) {
    this(owner, type.getDefaultSize(), type.getDefaultTitle());
    this.type = type;
}
 
Example 3
Source File: CraftInventoryCustom.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public MinecraftInventory(InventoryHolder owner, InventoryType type, String title) {
    this(owner, type.getDefaultSize(), title);
    this.type = type;
}
 
Example 4
Source File: CraftInventoryCustom.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public MinecraftInventory(InventoryHolder owner, InventoryType type) {
    this(owner, type.getDefaultSize(), type.getDefaultTitle());
    this.type = type;
}
 
Example 5
Source File: CraftInventoryCustom.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public MinecraftInventory(InventoryHolder owner, InventoryType type, String title) {
    this(owner, type.getDefaultSize(), title);
    this.type = type;
}