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


Java ItemTypes类代码示例

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


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

示例1: run

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
@Override
public void run() {
    if (!FIRST_GUI_CONTAINERS.containsKey(container)) {
        return;
    }
    for (int i = 10; i < 16; i++) {
        inventory.getSlot(new SlotIndex(i)).get().
                set(inventory.getSlot(new SlotIndex(i + 1)).get().peek().
                        orElse(ItemStack.of(ItemTypes.NONE, 1)));
    }
    if (index == drops.size()) {
        index = 0;
    }
    inventory.getSlot(new SlotIndex(16)).get().
            set(drops.get(index).getDropItem().orElse(ItemStack.of(ItemTypes.NONE, 1)));
    index++;
    Sponge.getScheduler().createTaskBuilder().delayTicks(scroll_delay).execute(this).submit(GWMCrates.getInstance());
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:19,代码来源:FirstGuiPreview.java

示例2: listRewards

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
public void listRewards(Player player, VirtualCrate vc){
    if(!vc.showRewardsOnLeft) return;
    /* Home */
    StateContainer test = new StateContainer();
    Page.PageBuilder rewards = Page.builder();
    rewards.setAutoPaging(true);
    rewards.setTitle(TextSerializers.FORMATTING_CODE.deserialize(vc.displayName + " Rewards"));
    rewards.setEmptyStack(ItemStack.builder()
            .itemType(ItemTypes.STAINED_GLASS_PANE)
            .add(Keys.DYE_COLOR, DyeColors.BLACK)
            .add(Keys.DISPLAY_NAME, Text.of(TextColors.DARK_GRAY, "HuskyCrates")).build());
    for(Object[] e : vc.getItemSet()){
        CrateReward rew = (CrateReward)e[1];
        ItemStack item = rew.getDisplayItem().copy();
        if(vc.showProbability) {
            ArrayList<Text> lore = (ArrayList<Text>) item.getOrElse(Keys.ITEM_LORE, new ArrayList<>());
            lore.add(Text.of());

            lore.add(Text.of(TextColors.GRAY, TextStyles.ITALIC, "Win Probability: " + BigDecimal.valueOf((rew.getChance() / vc.getMaxProb()) * 100d).setScale(1, RoundingMode.HALF_UP).toString() + "%"));
            item.offer(Keys.ITEM_LORE, lore);
        }
        rewards.addElement(new Element(item));
    }
    test.setInitialState(rewards.build("rewards"));
    test.launchFor(player);
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:27,代码来源:HuskyCrates.java

示例3: getCrateWand

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
/***
 * Retrieve the crate item
 * @since 1.2.1
 * @return the ItemStack with the keys.
 */
public ItemStack getCrateWand(){
    ItemStack key = ItemStack.builder()
            .itemType(ItemTypes.BLAZE_ROD)
            .add(Keys.DISPLAY_NAME, TextSerializers.FORMATTING_CODE.deserialize(displayName + " Wand")).build();
    ArrayList<Text> itemLore = new ArrayList<>();
    itemLore.add(Text.of(TextColors.WHITE, "A wand for a ", TextSerializers.FORMATTING_CODE.deserialize(displayName), TextColors.WHITE, "."));
    itemLore.add(Text.of(TextColors.DARK_GRAY, "HuskyCrates"));
    key.offer(Keys.ITEM_LORE, itemLore);
    if(keyDamage != null){
        key = ItemStack.builder().fromContainer(key.toContainer().set(DataQuery.of("UnsafeDamage"),keyDamage)).build();
    }

    return ItemStack.builder().fromContainer(key.toContainer().set(DataQuery.of("UnsafeData","crateID"),id)).build();//

}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:21,代码来源:VirtualCrate.java

示例4: getInventory

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

示例5: loadStacks

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
private Map<String, String> loadStacks(Player player, Inventory backpack) {
    for (SlotPos slotp : this.itemspos) {
        if (backpack.query(slotp).size() > 0) {
            if (!backpack.query(slotp).peek().get().getItem().equals(ItemTypes.NONE)) {
                try {
                    if (backpack.query(slotp).peek().isPresent()) {

                        this.items.put(slotp.getX() + "," + slotp.getY(), Tools.ItemStackToBase64(backpack.query(slotp).peek().get()));
                    }
                } catch (Exception e) {
                    VirtualTool.getInstance().getLogger().error("Failed to load a stack data from inventory for this user: " + player.getName() + " SlotPos: " + slotp.getX() + "X," + slotp.getY() + "Y");
                    e.printStackTrace();
                }
            } else {
                if (this.items.containsKey(slotp.getX() + "," + slotp.getY())) {
                    this.items.remove(slotp.getX() + "," + slotp.getY());
                }
            }
        } else {
            if (this.items.containsKey(slotp.getX() + "," + slotp.getY())) {
                this.items.remove(slotp.getX() + "," + slotp.getY());
            }
        }
    }
    return this.items;
}
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:27,代码来源:Backpack.java

示例6: performRemoval

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
private void performRemoval(LookupLine line) {
	World w = Sponge.getServer().getWorld(line.getWorld()).orElse(null);
	if (w == null) return;
	
	if (line.getTarget() instanceof ItemType) {
		
		Optional<TileEntity> te = w.getTileEntity(line.getPos());
		if (te.isPresent() && te.get() instanceof TileEntityCarrier) {
			TileEntityCarrier c = (TileEntityCarrier) te.get();
			Inventory i = c.getInventory();
			
			Inventory slot = i.query(new SlotIndex(line.getSlot()));
			slot.set(ItemStack.of(ItemTypes.NONE, 0));
		}
		
	} else if (line.getTarget() instanceof BlockType) {
		
		BlockState block = BlockState.builder().blockType(BlockTypes.AIR).build();
		w.setBlock(line.getPos(), block, Cause.source(container).build());
		
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:23,代码来源:RollbackManager.java

示例7: getAddTrailCommand

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
private static CommandSpec getAddTrailCommand() {
    return CommandSpec.builder()
        .permission("happytrails.command.add")
        .description(Text.of("Adds a new trail"))
        .executor((src, args) -> {
            if (!(src instanceof Player)) {
                return CommandResult.empty();
            }
            final Inventory creator = Inventory.builder()
                .of(InventoryArchetypes.CHEST)
                .property(InventoryTitle.PROPERTY_NAME, new InventoryTitle(Text.of(TextColors.AQUA, "Create a Trail")))
                .listener(ClickInventoryEvent.Primary.class, (event) -> {

                })
                .build(HappyTrails.getInstance());
            creator.offer(ItemStack.of(ItemTypes.FIREWORKS, 1));
            creator.offer(ItemStack.builder().fromBlockState(BlockTypes.REDSTONE_BLOCK.getDefaultState()).build());
            ((Player) src).openInventory(creator);
            return CommandResult.success();
        })
        .build();

}
 
开发者ID:gabizou,项目名称:HappyTrails,代码行数:24,代码来源:TrailCommands.java

示例8: of

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
/**
 * Gets a SkinRecord that has been assigned to this {@link ItemStack}.
 *
 * @param itemStack The {@link ItemStack} to get the {@link SkinRecord} of
 * @return The {@link SkinRecord}, if found, or {@link Optional#empty()} instead.
 */
public static Optional<SkinRecord> of(ItemStack itemStack) {
    if(itemStack.getItem() != ItemTypes.SKULL
            || itemStack.get(Keys.SKULL_TYPE).orElse(SkullTypes.SKELETON) != SkullTypes.PLAYER)
        return Optional.empty();

    return itemStack.get(Keys.REPRESENTED_PLAYER).flatMap(profile -> {
        Collection<ProfileProperty> properties = profile.getPropertyMap().get(PROPERTY_TEXTURES);

        if(properties.size() != 1)
            return Optional.empty();

        ProfileProperty property = properties.iterator().next();
        Optional<String> signature = property.getSignature();

        if(!signature.isPresent())
            return Optional.empty();

        return Optional.of(new SkinRecord(profile.getUniqueId(), property.getValue(), signature.get()));
    });
}
 
开发者ID:Limeth,项目名称:MineskinSponge,代码行数:27,代码来源:SkinRecord.java

示例9: onPlayerLeftClickProtect

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onPlayerLeftClickProtect(InteractBlockEvent.Primary.MainHand event, @First Player player)
{
	if (!player.gameMode().get().equals(GameModes.CREATIVE))
		return;

	Optional<Location<World>> optLoc = event.getTargetBlock().getLocation();
	if (!optLoc.isPresent())
		return;

	Optional<List<Shop>> shop = ShopsData.getShops(optLoc.get());
	if (shop.isPresent()) {
		Optional<ItemStack> optItem = player.getItemInHand(HandTypes.MAIN_HAND);

		if (!optItem.isPresent() || (!optItem.get().getItem().equals(ItemTypes.BEDROCK) && !optItem.get().getItem().equals(ItemTypes.REDSTONE) && !optItem.get().getItem().equals(ItemTypes.STICK))) {
			event.setCancelled(true);
		}
	}
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:20,代码来源:PlayerClickListener.java

示例10: onInteract

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onInteract(InteractBlockEvent event, @First Player player)
{
	if (!ConfigHandler.getNode("worlds").getNode(player.getWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.interact"))
	{
		return;
	}
	Optional<ItemStack> optItem = player.getItemInHand(HandTypes.MAIN_HAND);
	if (optItem.isPresent() && (ConfigHandler.isWhitelisted("use", optItem.get().getItem().getId()) || optItem.get().getItem().equals(ItemTypes.GOLDEN_AXE) && ConfigHandler.getNode("others", "enableGoldenAxe").getBoolean(true)))
		return;
	event.getTargetBlock().getLocation().ifPresent(loc -> {
		if (!DataHandler.getPerm("interact", player.getUniqueId(), loc))
		{
			event.setCancelled(true);
			if (loc.getBlockType() != BlockTypes.STANDING_SIGN && loc.getBlockType() != BlockTypes.WALL_SIGN)
				player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_INTERACT));
		}
	});
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:24,代码来源:InteractPermListener.java

示例11: commandBook

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
private CompletableFuture<Boolean> commandBook(EPlayer player) {
	// Si le joueur a bien un item dans la main
	if (player.getItemInMainHand().isPresent()) {
		ItemStack item = player.getItemInMainHand().get();
		if (item.getType().equals(ItemTypes.WRITTEN_BOOK) && item.get(Keys.BOOK_PAGES).isPresent()) {
			// Nouveau livre
			ItemStack book = ItemStack.of(ItemTypes.WRITABLE_BOOK, 1);
			
			// Ajoute les pages
			book.offer(Keys.BOOK_PAGES, item.get(Keys.BOOK_PAGES).get());
			
			// Remplace le livre
			player.setItemInMainHand(book);
			
			EEMessages.BOOK_WRITABLE.sendTo(player);
		} else {
			EEMessages.BOOK_NO_WRITTEN.sendTo(player);
		}
	// Le joueur a aucun item dans la main
	} else {
		EAMessages.EMPTY_ITEM_IN_HAND.sender()
			.prefix(EEMessages.PREFIX)
			.sendTo(player);
	}
	return CompletableFuture.completedFuture(true);
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:27,代码来源:EEBook.java

示例12: onClickInventory

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
@Listener
public void onClickInventory(final ClickInventoryEvent event, @First Player player) {
    //Make sure we have a transaction to validate
    if (event.getTransactions().size() <= 0) {
        return;
    }
    //Get the first transaction of this event
    final SlotTransaction slotTransaction = event.getTransactions().get(0);

    final Slot slot = slotTransaction.getSlot();

    //If the player is interacting with a TileEntityCarrier
    if (slot.parent() instanceof TileEntityCarrier) {
        //If the final item is NONE (or amount is less) person is trying to withdraw (so we care about it)
        if (slotTransaction.getFinal().getType() == ItemTypes.NONE || slotTransaction.getFinal().getCount() < slotTransaction.getOriginal().getCount()) {
            //Then check to see if there's a lock
            final Optional<Lock> lock = Latch.getLockManager().getLock(((TileEntityCarrier) slot.parent()).getLocation());

            //If there's a donation lock the player CANNOT access
            if (lock.isPresent() && lock.get().getLockType() == LockType.DONATION && !lock.get().canAccess(player.getUniqueId())) {
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:ichorpowered,项目名称:latch,代码行数:26,代码来源:InteractBlockListener.java

示例13: PipeBlock

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
public PipeBlock() {
    this.pane = ItemStack.of(ItemTypes.STAINED_GLASS_PANE, 1);
    Vector3d rotX = new Vector3d(90, 0, 0);
    Vector3d rotY = new Vector3d(0, 90, 0);
    this.entityStruct = new MultiEntityStructure.Builder()
            .define(Direction.DOWN.name(), EntityTypes.ARMOR_STAND,
                    armorStandOffset(true, Axis.Z, new Vector3f(0.5, 0.2, 0.5)),
                    ArmorStand.class, stand -> setupArmorStand(stand, rotX))
            .define(Direction.UP.name(), EntityTypes.ARMOR_STAND,
                    armorStandOffset(true, Axis.Z, new Vector3f(0.5, 0.7375, 0.5)),
                    ArmorStand.class, stand -> setupArmorStand(stand, rotX))
            .define(Direction.NORTH.name(), EntityTypes.ARMOR_STAND,
                    armorStandOffset(false, Axis.Z, new Vector3f(0.5, 0.2, 0.2)),
                    ArmorStand.class, stand -> setupArmorStand(stand, null))
            .define(Direction.SOUTH.name(), EntityTypes.ARMOR_STAND,
                    armorStandOffset(false, Axis.Z, new Vector3f(0.5, 0.2, 0.8)),
                    ArmorStand.class, stand -> setupArmorStand(stand, null))
            .define(Direction.EAST.name(), EntityTypes.ARMOR_STAND,
                    armorStandOffset(false, Axis.X, new Vector3f(0.8, 0.2, 0.5)),
                    ArmorStand.class, stand -> setupArmorStand(stand, rotY))
            .define(Direction.WEST.name(), EntityTypes.ARMOR_STAND,
                    armorStandOffset(false, Axis.X, new Vector3f(0.2, 0.2, 0.5)),
                    ArmorStand.class, stand -> setupArmorStand(stand, rotY))
            .build();
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:26,代码来源:PipeBlock.java

示例14: onStart

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
@Listener
public void onStart(GameInitializationEvent event) {
    this.logger.info("Test Recipes plugin enabled!");

    final GameRegistry gameRegistry = Sponge.getGame().getRegistry();
    gameRegistry.getCraftingRecipeRegistry().register(CraftingRecipe.shapedBuilder()
            .aisle("xy", "yx")
            .where('x', Ingredient.of(ItemTypes.APPLE))
            .where('y', Ingredient.of(ItemTypes.GOLD_NUGGET))
            .result(ItemStack.of(ItemTypes.GOLDEN_APPLE, 2))
            .build("golden_apples", this));
    gameRegistry.getSmeltingRecipeRegistry().register(SmeltingRecipe.builder()
            .ingredient(ItemTypes.GOLDEN_APPLE)
            .result(ItemStack.of(ItemTypes.GOLD_NUGGET, 1))
            .build());
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:17,代码来源:TestRecipesPlugin.java

示例15: itemStack

import org.spongepowered.api.item.ItemTypes; //导入依赖的package包/类
private LanternItemStack itemStack(@Nullable ItemType itemType) {
    if (itemType != null) {
        if (this.itemStack == null) {
            this.itemStack = new LanternItemStack(itemType);
        } else if (this.itemStack.getType() != itemType) {
            final LanternItemStack old = this.itemStack;
            this.itemStack = new LanternItemStack(itemType);
            this.itemStack.setQuantity(old.getQuantity());
            this.itemStack.copyFromNoEvents(old, MergeFunction.IGNORE_ALL);
        }
        this.itemTypeSet = true;
    } else if (this.itemStack == null) {
        this.itemStack = new LanternItemStack(ItemTypes.APPLE);
    }
    return this.itemStack;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:17,代码来源:LanternItemStackBuilder.java


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