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


Java InventoryTransactionResult.Type方法代码示例

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


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

示例1: execute

import org.spongepowered.api.item.inventory.transaction.InventoryTransactionResult; //导入方法依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if(commandContext.getOne("type").isPresent() && commandSource instanceof Player) {
        String type = commandContext.<String>getOne("type").get();
        Player player = (Player) commandSource;
        VirtualCrate virtualCrate = HuskyCrates.instance.getCrateUtilities().getVirtualCrate(type);
        if (virtualCrate == null) {
            commandSource.sendMessage(Text.of("Invalid crate id: " + type + ". Please check your config."));
            return CommandResult.empty();
        }



        ItemStack keyItemStack = virtualCrate.getCrateWand();
        InventoryTransactionResult.Type mainInventory = player.getInventory().offer(keyItemStack.copy()).getType();
        if (!mainInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
            InventoryTransactionResult.Type enderInventory = player.getEnderChestInventory().offer(keyItemStack.copy()).getType();
            if(!enderInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
                commandSource.sendMessage(Text.of("Couldn't give wand to " + player.getName() + " because of a full inventory and enderchest"));
                HuskyCrates.instance.logger.info("Couldn't give wand to " + player.getName() + " because of a full inventory and enderchest");
            }else{
                player.sendMessage(Text.of("You have been given a ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName) ," wand, but it has been placed in your Ender Chest."));
            }
        }
    }else{
        commandSource.sendMessage(Text.of("Usage: /crate wand <id>"));
    }
    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:29,代码来源:Wand.java

示例2: execute

import org.spongepowered.api.item.inventory.transaction.InventoryTransactionResult; //导入方法依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if(commandContext.getOne("type").isPresent()) {
        String type = commandContext.<String>getOne("type").get();
        Optional<Player> player = commandContext.getOne("player");
        VirtualCrate virtualCrate = HuskyCrates.instance.getCrateUtilities().getVirtualCrate(type);
        int quantity = commandContext.getOne("quantity").isPresent() ? commandContext.<Integer>getOne("quantity").get() : 1;
        if (virtualCrate == null) {
            commandSource.sendMessage(Text.of("Invalid crate id: " + type + ". Please check your config."));
            return CommandResult.empty();
        }

        if (!player.isPresent()) {
            commandSource.sendMessage(Text.of("You need to be in game or specify a player for this command to work."));
            return CommandResult.empty();
        }
        ItemStack keyItemStack = virtualCrate.getCrateKey(quantity);
        InventoryTransactionResult.Type mainInventory = player.get().getInventory().offer(keyItemStack.copy()).getType();
        if (!mainInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
            InventoryTransactionResult.Type enderInventory = player.get().getEnderChestInventory().offer(keyItemStack.copy()).getType();
            if (!enderInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
                commandSource.sendMessage(Text.of("Couldn't give key to " + player.get().getName() + " because of a full inventory and enderchest"));
                HuskyCrates.instance.logger.info("Couldn't give key to " + player.get().getName() + " because of a full inventory and enderchest");
            } else {
                if (player.isPresent()) {
                    player.get().sendMessage(Text.of("You have been given 1 or more ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName), " key(s), but some have been placed in your Ender Chest."));
                } else {
                    commandSource.sendMessage(Text.of("You have been given 1 or more ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName), " key(s), but some have been placed in your Ender Chest."));
                }
            }
        }
    }else{
        commandSource.sendMessage(Text.of("Usage: /crate key <id> [player] [count]"));
    }
    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:36,代码来源:Key.java

示例3: execute

import org.spongepowered.api.item.inventory.transaction.InventoryTransactionResult; //导入方法依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if(commandContext.getOne("type").isPresent()) {
        String type = commandContext.<String>getOne("type").get();
        Optional<Player> player = commandContext.getOne("player");
        VirtualCrate virtualCrate = HuskyCrates.instance.getCrateUtilities().getVirtualCrate(type);
        int quantity = commandContext.getOne("quantity").isPresent() ? commandContext.<Integer>getOne("quantity").get() : 1;
        if (virtualCrate == null) {
            commandSource.sendMessage(Text.of("Invalid crate id: " + type + ". Please check your config."));
            return CommandResult.empty();
        }


        if (!player.isPresent()) {
            commandSource.sendMessage(Text.of("You need to either specify a player or be in game"));
            return CommandResult.empty();
        }

        ItemStack chestItemStack = virtualCrate.getCrateItem(quantity);
        InventoryTransactionResult.Type mainInventory = player.get().getInventory().offer(chestItemStack.copy()).getType();
        if (!mainInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
            InventoryTransactionResult.Type enderInventory = player.get().getEnderChestInventory().offer(chestItemStack.copy()).getType();
            if(!enderInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
                commandSource.sendMessage(Text.of("Couldn't give chest to " + player.get().getName() + " because of a full inventory and enderchest"));
                HuskyCrates.instance.logger.info("Couldn't give chest to " + player.get().getName() + " because of a full inventory and enderchest");
            }else{
                if(player.isPresent()) {
                    player.get().sendMessage(Text.of("You have been given 1 or more ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName) ," crate(s), but some have been placed in your Ender Chest."));
                }else{
                    commandSource.sendMessage(Text.of("You have been given 1 or more ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName) ," crate(s), but some have been placed in your Ender Chest."));
                }
            }
        }
    }else{
        commandSource.sendMessage(Text.of("Usage: /crate chest <id> [player]"));
    }

    return CommandResult.success();

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

示例4: execute

import org.spongepowered.api.item.inventory.transaction.InventoryTransactionResult; //导入方法依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if(commandContext.getOne("type").isPresent()) {
        String type = commandContext.<String>getOne("type").get();
        VirtualCrate virtualCrate = HuskyCrates.instance.getCrateUtilities().getVirtualCrate(type);
        int quantity = commandContext.getOne("quantity").isPresent() ? commandContext.<Integer>getOne("quantity").get() : 1;
        if (virtualCrate == null) {
            commandSource.sendMessage(Text.of("Invalid crate id: " + type + ". Please check your config."));
            return CommandResult.empty();
        }


        for(Player player : Sponge.getServer().getOnlinePlayers()) {
            ItemStack keyItemStack = virtualCrate.getCrateKey(quantity);
            InventoryTransactionResult.Type mainInventory = player.getInventory().offer(keyItemStack.copy()).getType();
            if (!mainInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
                InventoryTransactionResult.Type enderInventory = player.getEnderChestInventory().offer(keyItemStack.copy()).getType();
                if (!enderInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
                    commandSource.sendMessage(Text.of("Couldn't give key to " + player.getName() + " because of a full inventory and enderchest"));
                    HuskyCrates.instance.logger.info("Couldn't give key to " + player.getName() + " because of a full inventory and enderchest");
                } else {
                    player.sendMessage(Text.of("You have been given 1 or more ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName), " key(s), but some have been placed in your Ender Chest."));
                }
            }
        }
    }else{
        commandSource.sendMessage(Text.of("Usage: /crate keyall <id> [count]"));
    }
    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:30,代码来源:KeyAll.java

示例5: PeekedOfferTransactionResult

import org.spongepowered.api.item.inventory.transaction.InventoryTransactionResult; //导入方法依赖的package包/类
/**
 * Constructs a new {@link PeekedOfferTransactionResult}.
 *
 * @param type The type of the transaction result
 * @param transactions The slot transactions that will occur
 * @param rejectedItem The rejected item stack, this can occur if the stack doesn't fit the inventory
 */
public PeekedOfferTransactionResult(InventoryTransactionResult.Type type, List<SlotTransaction> transactions,
        @Nullable ItemStack rejectedItem) {
    super(transactions);
    checkNotNull(type, "type");
    this.type = type;
    this.rejectedItem = rejectedItem;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:15,代码来源:PeekedOfferTransactionResult.java

示例6: PeekedSetTransactionResult

import org.spongepowered.api.item.inventory.transaction.InventoryTransactionResult; //导入方法依赖的package包/类
/**
 * Constructs a new {@link PeekedSetTransactionResult}.
 *
 * @param type The type of the transaction result
 * @param transactions The slot transactions that will occur
 * @param rejectedItem The rejected item stack, this can occur if the stack doesn't fit the inventory
 * @param replacedItem The replaced item stack
 */
public PeekedSetTransactionResult(InventoryTransactionResult.Type type, List<SlotTransaction> transactions,
        @Nullable ItemStack rejectedItem, @Nullable ItemStack replacedItem) {
    super(type, transactions, rejectedItem);
    this.replacedItem = replacedItem;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:14,代码来源:PeekedSetTransactionResult.java

示例7: getType

import org.spongepowered.api.item.inventory.transaction.InventoryTransactionResult; //导入方法依赖的package包/类
/**
 * Gets the {@link InventoryTransactionResult.Type}.
 *
 * @return The result type
 */
public InventoryTransactionResult.Type getType() {
    return this.type;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:PeekedOfferTransactionResult.java


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