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


Java InventoryCapacity類代碼示例

本文整理匯總了Java中org.spongepowered.api.item.inventory.property.InventoryCapacity的典型用法代碼示例。如果您正苦於以下問題:Java InventoryCapacity類的具體用法?Java InventoryCapacity怎麽用?Java InventoryCapacity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


InventoryCapacity類屬於org.spongepowered.api.item.inventory.property包,在下文中一共展示了InventoryCapacity類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getInventory

import org.spongepowered.api.item.inventory.property.InventoryCapacity; //導入依賴的package包/類
public RepairBlockInventory getInventory(final Player player)
{
    if (player == null)
    {
        return null;
    }
    RepairBlockInventory inventory = this.inventoryMap.get(player.getName());
    if (inventory == null)
    {
        Inventory inv = Inventory.builder().of(InventoryArchetypes.CHEST)
                .property(InventoryDimension.PROPERTY_NAME, InventoryDimension.of(9,4))
                .property(InventoryCapacity.class.getSimpleName().toLowerCase(), InventoryCapacity.of(9*4))
                .property(InventoryTitle.PROPERTY_NAME, InventoryTitle.of(Text.of(getTitle())))
                .build(module.getPlugin());
        inventory = new RepairBlockInventory(inv, player);
        this.inventoryMap.put(player.getName(), inventory);
    }
    return inventory;
}
 
開發者ID:CubeEngine,項目名稱:modules-extra,代碼行數:20,代碼來源:RepairBlock.java

示例2: tryGetProperties

import org.spongepowered.api.item.inventory.property.InventoryCapacity; //導入依賴的package包/類
/**
 * Attempts to get all the {@link InventoryProperty}s of the given
 * type from this inventory.
 *
 * @param property The property type
 * @param <T> The property type
 * @return The properties
 */
protected <T extends InventoryProperty<?, ?>> List<T> tryGetProperties(Class<T> property) {
    final List<T> properties = new ArrayList<>();
    if (property == InventoryTitle.class) {
        properties.add((T) new InventoryTitle(TextTranslation.toText(getName())));
    } else if (property == InventoryCapacity.class) {
        properties.add((T) new InventoryCapacity(capacity()));
    }
    return properties;
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:18,代碼來源:AbstractInventory.java

示例3: parseInventory

import org.spongepowered.api.item.inventory.property.InventoryCapacity; //導入依賴的package包/類
private static Inventory parseInventory(ItemBank<ItemStack, Logger, Player, World> plugin, AccountPage<ItemStack> page, String ownerName, World world) {
    String name = ownerName + "'s Account for " + world.getName() + " - Page " + page.getPage();
    InventoryArchetype.Builder builder = InventoryArchetype.builder().property(new InventoryCapacity(54)).title(Text.of(name));
    for (int i = 0; i < 54; i++) {
        builder.with(InventoryArchetype.builder().from(InventoryArchetypes.SLOT).property(new SlotIndex(i)).build("minecraft:slot" + i, "Slot"));
    }

    Inventory inventory = Inventory.builder().of(builder.build(plugin.getId() + ":" + name.replace("\\s", "_").replace("'", "").replace("-", ""), name)).build(plugin);
    page.getSlots().values().forEach(slot -> setItem(inventory, slot.getSlot(), slot.getItemStack()));
    return inventory;
}
 
開發者ID:Musician101,項目名稱:ItemBank,代碼行數:12,代碼來源:SpongeInventoryHandler.java

示例4: tryGetProperty

import org.spongepowered.api.item.inventory.property.InventoryCapacity; //導入依賴的package包/類
/**
 * Attempts to get a {@link InventoryProperty} of the given
 * type and optional key from this inventory.
 *
 * @param property The property type
 * @param key The key
 * @param <T> The property type
 * @return The property
 */
protected <T extends InventoryProperty<?, ?>> Optional<T> tryGetProperty(Class<T> property, @Nullable Object key) {
    if (property == InventoryTitle.class) {
        return Optional.of((T) new InventoryTitle(TextTranslation.toText(getName())));
    } else if (property == InventoryCapacity.class) {
        return Optional.of((T) new InventoryCapacity(capacity()));
    }
    return Optional.empty();
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:18,代碼來源:AbstractInventory.java


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