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


Java Inventory.peek方法代码示例

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


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

示例1: serializeInventory

import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static List<DataView> serializeInventory(Inventory inventory) {
	DataContainer container;
	List<DataView> slots = new LinkedList<>();

	int i = 0;
	Optional<ItemStack> stack;

	for (Inventory inv : inventory.slots()) {
		stack = inv.peek();

		if (stack.isPresent()) {
			container = new org.spongepowered.api.data.MemoryDataContainer();

			container.set(SLOT, i);
			container.set(STACK, serializeItemStack(stack.get()));

			slots.add(container);
		}

		i++;
	}

	return slots;
}
 
开发者ID:AuraDevelopmentTeam,项目名称:InvSync,代码行数:26,代码来源:InventorySerializer.java

示例2: getState

import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
@Override
    public PlayerState getState() {
        Player player = getPlayer().orElseThrow(IllegalStateException::new);
        ImmutableList.Builder<WarItem> builder = ImmutableList.builder();
        for (Inventory inventory : player.getInventory().slots()) {
            Optional<ItemStack> peek = inventory.peek();
            if (peek.isPresent()) {
                builder.add(plugin.getWarItem(peek.get()));
            }
        }
        int gameMode = 0;
        GameMode gameMode1 = player.getGameModeData().getValue(Keys.GAME_MODE).orElseThrow(IllegalStateException::new).get();
        if (gameMode1 == GameModes.CREATIVE)
            gameMode = WarGameMode.CREATIVE;
//        return new PlayerState(gameMode, (WarItem[]) builder.build().toArray(),
//                null, null, null, null,
//                player.getHealthData().getValue(Keys.HEALTH).orElseThrow(IllegalStateException::new).get(),
//                player.getS);
        throw new UnsupportedOperationException("Not implemented yet");
    }
 
开发者ID:cmastudios,项目名称:war-sponge,代码行数:21,代码来源:SpongeWarPlayer.java

示例3: getTemplate

import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
static public Optional<ItemStack> getTemplate(Inventory inventory, ItemStack needle) {
	for (Inventory item : inventory.slots()) {
		if (item.peek().isPresent()) {
			if (equalTo(item.peek().get(), needle))
				return item.peek();
		}
	}
	return Optional.empty();
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:10,代码来源:Shop.java

示例4: freeSlots

import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
public static int freeSlots(Iterable<Inventory> slots) {
	int count = 0;
	for (Inventory i : slots) {
		Optional<ItemStack> ois = i.peek();
		if (!ois.isPresent() || ois.get().getItem() == ItemTypes.NONE) {
			count++;
		}
	}
	return count;
}
 
开发者ID:KaiKikuchi,项目名称:BetterKits,代码行数:11,代码来源:Utils.java

示例5: usedSlots

import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
public static int usedSlots(Iterable<Inventory> slots) {
	int count = 0;
	for (Inventory i : slots) {
		Optional<ItemStack> ois = i.peek();
		if (ois.isPresent() && ois.get().getItem() != ItemTypes.NONE) {
			count++;
		}
	}
	return count;
}
 
开发者ID:KaiKikuchi,项目名称:BetterKits,代码行数:11,代码来源:Utils.java

示例6: getEquipped

import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
@Override
default Optional<ItemStack> getEquipped(EquipmentType type) {
    checkNotNull(type, "type");
    final Inventory inventory = getInventory().query(Holder.EQUIPMENT_INVENTORY_OPERATION);
    if (inventory instanceof EmptyInventory) {
        return Optional.empty();
    }
    return inventory.peek();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:10,代码来源:AbstractEquipable.java


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