本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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();
}