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


Java InventoryDimension类代码示例

本文整理汇总了Java中org.spongepowered.api.item.inventory.property.InventoryDimension的典型用法代码示例。如果您正苦于以下问题:Java InventoryDimension类的具体用法?Java InventoryDimension怎么用?Java InventoryDimension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InventoryDimension类属于org.spongepowered.api.item.inventory.property包,在下文中一共展示了InventoryDimension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: build

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
/**
 * Builds this PageBuilder to get a new {@link Page} object.
 *
 * @param id the ID of the new State (Page)
 * @return a new Page
 */
public Page build(@Nonnull final String id) {
    final int rows = (int) Math.ceil(((double) this.elements.size()) / 9d);
    return new Page(id,
            this.elements,
            (this.autoPaging ? InventoryDimension.of(9, rows + 1) : this.inventoryDimension != null ?
                    this.inventoryDimension : InventoryDimension.of(9, rows + 1)),
            this.title,
            this.emptyStack,
            this.updatable,
            this.updateTickRate,
            this.updaterConsumer,
            this.fillWhenEmpty,
            this.autoPaging,
            this.centered,
            rows,
            parent
    );
}
 
开发者ID:codeHusky,项目名称:HuskyUI-Plugin,代码行数:25,代码来源:Page.java

示例2: open

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
@Override
public void open(Player player, Manager manager) {
    PlayerOpenCrateEvent open_event = new PlayerOpenCrateEvent(player, manager);
    Sponge.getEventManager().post(open_event);
    if (open_event.isCancelled()) return;
    Inventory inventory = display_name.map(text -> Inventory.builder().of(InventoryArchetypes.CHEST).
            property(InventoryDimension.PROPERTY_NAME, new InventoryDimension(9, rows)).
            property(InventoryTitle.PROPERTY_NAME, new InventoryTitle(text)).
            build(GWMCrates.getInstance())).orElseGet(() -> Inventory.builder().of(InventoryArchetypes.CHEST).
            property(InventoryDimension.PROPERTY_NAME, new InventoryDimension(9, rows)).
            build(GWMCrates.getInstance()));
    OrderedInventory ordered = Utils.castToOrdered(inventory);
    int hidden_item_quantity = hidden_item.getQuantity();
    for (int i = 0; i < 9 * rows; i++) {
        int quantity = increase_hidden_item_quantity ? i + 1 : hidden_item_quantity;
        ItemStack copy = hidden_item.copy();
        copy.setQuantity(quantity);
        ordered.getSlot(new SlotIndex(i)).get().set(copy);
    }
    Container container = player.openInventory(inventory).get();
    getOpenSound().ifPresent(open_sound -> player.playSound(open_sound, player.getLocation().getPosition(), 1.));
    SECOND_GUI_INVENTORIES.put(container, new Pair<SecondOpenManager, Manager>(this, manager));
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:24,代码来源:SecondOpenManager.java

示例3: getInventory

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
@Override
public Inventory getInventory() {
    Inventory woop = Inventory.builder()
            .property(InventoryDimension.PROPERTY_NAME, InventoryDimension.of(9,1))
            .property(InventoryTitle.PROPERTY_NAME,InventoryTitle.of(Text.of(TextColors.DARK_RED,"INVALID CRATE TYPE!")))
            .listener(InteractInventoryEvent.class, evt ->{
                if(!(evt instanceof InteractInventoryEvent.Open) && !(evt instanceof  InteractInventoryEvent.Close)){
                    evt.setCancelled(true);
                }
                //System.out.println(evt.getClass());
            })
            .build(plugin);
    woop.offer(ItemStack.of(ItemTypes.BARRIER,256*2 + 64));
    for(Inventory e : woop.slots()){
        ItemStack b = e.peek().get();
        b.setQuantity(1);
        e.set(b);
    }
    return woop;
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:21,代码来源:NullCrateView.java

示例4: createInventory

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
public Inventory createInventory(Player player)
{
    UUID uuid = player.getUniqueId();
    if (!inventories.containsKey(uuid))
    {
        VirtualChestEventListener listener = new VirtualChestEventListener(player);
        Inventory chestInventory = Inventory.builder().of(InventoryArchetypes.CHEST).withCarrier(player)
                .property(InventoryTitle.PROPERTY_NAME, new InventoryTitle(this.title))
                .property(InventoryDimension.PROPERTY_NAME, new InventoryDimension(9, this.height))
                .listener(ClickInventoryEvent.class, listener::fireClickEvent)
                .listener(InteractInventoryEvent.Open.class, listener::fireOpenEvent)
                .listener(InteractInventoryEvent.Close.class, listener::fireCloseEvent)
                .build(this.plugin);
        inventories.put(uuid, chestInventory);
        return chestInventory;
    }
    return inventories.get(uuid);
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:19,代码来源:VirtualChestInventory.java

示例5: getInventory

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
public Inventory getInventory(Inventory.Builder ib, UUID player) {
	Inventory inv = ib
		.property("inventorydimension", new InventoryDimension(9, (int)Math.ceil((double)items.size()/9.0)*3-1))
		.build(VillagerShops.getInstance());
	
	//for some reason this class is no longer in the API, preventing any access i desire
	//the problem: inv is instance of CusotmInventory and thus can't be casted into GridInventory or similar
	CustomInventoryWrapper cinv = new CustomInventoryWrapper(inv);
	
	int row=0, col=0;
	for (int i = 0; i < items.size(); i++) {
		
		cinv.setItemStack(col, row,   items.get(i).getBuyDisplayItem(row*9+col, player));
		cinv.setItemStack(col, row+1, items.get(i).getSellDisplayItem((row+1)*9+col, player));
		
		if (++col>=9) { col=0; row+=3; }
	}
	
	return inv;
}
 
开发者ID:DosMike,项目名称:VillagerShops,代码行数:21,代码来源:InvPrep.java

示例6: create

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
@Override
public SimpleCustomInventory create(DataHolder dataHolder) {
    SimpleCustomInventory result = new SimpleCustomInventory(this, dataHolder);
    String typeId = getTypeId();
    InventoryArchetype archetype = InventoryArchetype.builder()
            .with(InventoryArchetypes.DOUBLE_CHEST)
            .property(new InventoryDimension(INVENTORY_SLOTS_WIDTH, getHeight()))
            .build(typeId, typeId);
    Inventory inventory = Inventory.builder()
            .of(archetype)
            .listener(InteractInventoryEvent.class, result)
            .build(CustomItemLibrary.getInstance());

    result.setInventory(inventory);
    populate(result);

    return result;
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:19,代码来源:SimpleCustomInventoryDefinition.java

示例7: getInventory

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的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

示例8: Page

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
/**
 * Constructs a Page.
 *
 * @param id the ID of the State this Page extends
 * @param elements the {@link ItemStack}s in use by this Page
 * @param inventoryDimension the virtual inventory this Page represents
 * @param title the name of the chest
 * @param emptyStack the ItemStack to be used if filling blank spaces
 * @param fillWhenEmpty whether or not to fill blank spaces
 * @param autoPaging whether or not to let HuskyUI handle paging
 * @param centered whether or not to center ItemStacks
 * @param rows the number of rows within the InventoryDimension
 */
public Page(@Nonnull final String id,
            @Nonnull final Map<Integer, Element> elements,
            @Nonnull final InventoryDimension inventoryDimension,
            @Nonnull final Text title,
            @Nonnull final ItemStack emptyStack,
            final boolean updatable,
            final int updateTickRate,
            final Consumer<Page> updateConsumer,
            final boolean fillWhenEmpty,
            final boolean autoPaging,
            final boolean centered,
            final int rows,
            final String parent) {
    super(id);
    this.elements = elements;
    this.inventoryDimension = inventoryDimension;
    this.title = title;
    this.emptyStack = emptyStack;
    this.fillWhenEmpty = fillWhenEmpty;
    this.autoPaging = autoPaging;
    this.centered = centered;
    this.rows = rows;
    this.updatable = updatable;
    this.updateTickRate = updateTickRate;
    this.updateConsumer = updateConsumer;
    cachedInventory = null;
    this.setParent(parent);
}
 
开发者ID:codeHusky,项目名称:HuskyUI-Plugin,代码行数:42,代码来源:Page.java

示例9: tryGetProperty

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
@Override
protected <T extends InventoryProperty<?, ?>> Optional<T> tryGetProperty(Class<T> property, @Nullable Object key) {
    if (property == InventoryDimension.class) {
        return Optional.of((T) new InventoryDimension(getDimensions()));
    }
    return super.tryGetProperty(property, key);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:AbstractInventory2D.java

示例10: tryGetProperties

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
@Override
protected <T extends InventoryProperty<?, ?>> List<T> tryGetProperties(Class<T> property) {
    final List<T> list = super.tryGetProperties(property);
    if (property == InventoryDimension.class) {
        list.add((T) new InventoryDimension(getDimensions()));
    }
    return list;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:AbstractInventory2D.java

示例11: BackpackHolder

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
public BackpackHolder(BackpackInventory backBackInventories, String title)
{
    this.backBackInventories = backBackInventories;
    this.inventory =
            Inventory.builder().of(CHEST)
            .property(InventoryDimension.PROPERTY_NAME, InventoryDimension.of(9, 6))
            .property(InventoryTitle.PROPERTY_NAME, InventoryTitle.of(Text.of(title)))
            .withCarrier(this)
            .build(backBackInventories.module.getPlugin());
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:11,代码来源:BackpackHolder.java

示例12: Backpack

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
public Backpack(Player player_args, Player player_cmd_src, int size, Boolean saveit, VirtualTool vt) {

        this.backpackfile_path = Paths.get(vt.getBackpackPath() + File.separator + player_args.getUniqueId().toString() + ".backpack");

        this.vt = vt;
        this.player_args = player_args;
        this.player_cmd_src = player_cmd_src;
        this.size = size;

        this.itemspos = new ArrayList<>(54);

        for (int y = 0; y <= (size - 1); y++) {
            for (int x = 0; x <= 8; x++) {
                itemspos.add(new SlotPos(x, y));
            }
        }

        this.items = new HashMap<String, String>();

        try {
            this.items = loadSlots(this.vt);
        } catch (Exception e) {
            e.printStackTrace();
        }


        if (!player_cmd_src.getUniqueId().equals(this.player_args.getUniqueId())) {
            this.backpacktitle_text = Text.of(this.player_args.getName() + "'s " + "Backpack");
            this.backpacktitle_str = this.player_args.getName() + "'s " + "Backpack";
        } else {
            this.backpacktitle_text = Text.of("Backpack");
            this.backpacktitle_str = "Backpack";
        }

        this.inventory = Inventory.builder()
                .of(InventoryArchetypes.DOUBLE_CHEST)
                .property(InventoryTitle.PROPERTY_NAME, InventoryTitle.of(Text.of(this.backpacktitle_text)))
                .property("inventorydimension", InventoryDimension.of(9, this.size))
                .listener(ClickInventoryEvent.class, (ClickInventoryEvent event) -> {
                    if (saveit) {
                        this.savebackpack(this.player_args, this.loadStacks(this.player_args, this.inventory), this.vt);
                    } else {
                        event.setCancelled(true);
                    }
                })
                .listener(InteractInventoryEvent.Close.class, event -> {
                    if (saveit) {
                        Tools.unlockbackpack(this.player_args, false, this.vt);
                    }
                })
                .build(VirtualTool.getInstance());
        this.loadBackpack(this.player_args, this.vt);
    }
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:54,代码来源:Backpack.java

示例13: RPGui

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
public RPGui(String name, Player player, Region region, int MaxSlot){
	this.name = name;
	this.player = player;
	this.region = region;
	if (MaxSlot <= 9){
		this.size = 9;
		this.guiItens = new ItemStack[this.size];
	} else
	if (MaxSlot >= 10 && MaxSlot <= 18){
		this.size = 18;
		this.guiItens = new ItemStack[this.size];
	} else
	if (MaxSlot >= 19 && MaxSlot <= 27){
		this.size = 27;
		this.guiItens = new ItemStack[this.size];
	}
	if (MaxSlot >= 28 && MaxSlot <= 36){
		this.size = 36;
		this.guiItens = new ItemStack[this.size];
	}
	if (MaxSlot >= 37 && MaxSlot <= 45){
		this.size = 45;
		this.guiItens = new ItemStack[this.size];
	}
	if (MaxSlot >= 46 && MaxSlot <= 54){
		this.size = 54;
		this.guiItens = new ItemStack[this.size];
	}

	for (String flag:region.flags.keySet()){
		if (!(region.flags.get(flag) instanceof Boolean)){
			continue;
		}
		if (RedProtect.get().ph.hasFlagPerm(player, flag) && RedProtect.get().cfgs.isFlagEnabled(flag) && RPUtil.testRegistry(ItemType.class, RedProtect.get().cfgs.getGuiFlagString(flag,"material").toPlain())){
			if (flag.equals("pvp") && !RedProtect.get().cfgs.getStringList("flags-configuration.enabled-flags").contains("pvp")){
   				continue;
			}

			int i = RedProtect.get().cfgs.getGuiSlot(flag);
			
			this.guiItens[i] = ItemStack.of((ItemType)RPUtil.getRegistryFor(ItemType.class,RedProtect.get().cfgs.getGuiFlagString(flag,"material").toPlain()), 1);

			this.guiItens[i].offer(Keys.DISPLAY_NAME, RedProtect.get().cfgs.getGuiFlagString(flag,"name"));
							
			this.guiItens[i].offer(Keys.ITEM_LORE, Arrays.asList(
					Text.of(RedProtect.get().cfgs.getGuiString("value"),RedProtect.get().cfgs.getGuiString(region.flags.get(flag).toString())),
					RPUtil.toText("&0"+flag),
					RedProtect.get().cfgs.getGuiFlagString(flag,"description"),
					RedProtect.get().cfgs.getGuiFlagString(flag,"description1"),
					RedProtect.get().cfgs.getGuiFlagString(flag,"description2")));
											
			if (!this.region.getFlagBool(flag)){
				this.guiItens[i].remove(Keys.ITEM_ENCHANTMENTS);
			} else {
				this.guiItens[i] = RedProtect.get().getPVHelper().offerEnchantment(this.guiItens[i]);
			}
			this.guiItens[i].offer(Keys.HIDE_ENCHANTMENTS, true);
			this.guiItens[i].offer(Keys.HIDE_ATTRIBUTES, true);				
		}
	}
			
	this.inv = Inventory.builder().of(InventoryArchetypes.DOUBLE_CHEST)
			.property(InventoryDimension.PROPERTY_NAME, new InventoryDimension(9, this.size/9))
			.property(InventoryTitle.PROPERTY_NAME, InventoryTitle.of(RPUtil.toText(this.name)))
			.build(RedProtect.get().container);

       for (int slotc=0; slotc < this.size; slotc++){
		if (this.guiItens[slotc] == null){
			this.guiItens[slotc] = RedProtect.get().cfgs.getGuiSeparator();
		}			
		int line = 0;
		int slot = slotc;
		if (slotc > 8){
               line = slotc/9;
			slot = slotc-(line*9);
		}			
		this.inv.query(SlotPos.of(slot,line)).set(this.guiItens[slotc]);
	}

	RedProtect.get().game.getEventManager().registerListeners(RedProtect.get().container, this);
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:82,代码来源:RPGui.java

示例14: getInventoryDimension

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
/**
 * Gets the virtual inventory this Page represents.
 *
 * @return the virtual inventory this Page represents
 */
@Nonnull
public InventoryDimension getInventoryDimension() {
    return this.inventoryDimension;
}
 
开发者ID:codeHusky,项目名称:HuskyUI-Plugin,代码行数:10,代码来源:Page.java

示例15: setInventoryDimension

import org.spongepowered.api.item.inventory.property.InventoryDimension; //导入依赖的package包/类
/**
 * Sets the {@link InventoryDimension} to be used by this Page.
 *
 * @param inventoryDimension the InventoryDimension to be used
 * @return this PageBuilder
 */
@Nonnull
public PageBuilder setInventoryDimension(@Nonnull final InventoryDimension inventoryDimension) {
    this.inventoryDimension = inventoryDimension;
    return this;
}
 
开发者ID:codeHusky,项目名称:HuskyUI-Plugin,代码行数:12,代码来源:Page.java


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