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


Java PlayerInventory.removeItem方法代码示例

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


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

示例1: processGreenTerra

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
 * Process the Green Terra ability.
 *
 * @param blockState The {@link BlockState} to check ability activation for
 * @return true if the ability was successful, false otherwise
 */
public boolean processGreenTerra(BlockState blockState) {
    Player player = getPlayer();

    if (!Permissions.greenThumbBlock(player, blockState.getType())) {
        return false;
    }

    PlayerInventory playerInventory = player.getInventory();
    ItemStack seed = new ItemStack(Material.SEEDS);

    if (!playerInventory.containsAtLeast(seed, 1)) {
        player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore"));
        return false;
    }

    playerInventory.removeItem(seed);
    player.updateInventory(); // Needed until replacement available

    return Herbalism.convertGreenTerraBlocks(blockState);
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:27,代码来源:HerbalismManager.java

示例2: processShroomThumb

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
 * Process the Shroom Thumb ability.
 *
 * @param blockState The {@link BlockState} to check ability activation for
 * @return true if the ability was successful, false otherwise
 */
public boolean processShroomThumb(BlockState blockState) {
    Player player = getPlayer();
    PlayerInventory playerInventory = player.getInventory();

    if (!playerInventory.contains(Material.BROWN_MUSHROOM)) {
        player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)));
        return false;
    }

    if (!playerInventory.contains(Material.RED_MUSHROOM)) {
        player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)));
        return false;
    }

    playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM));
    playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
    player.updateInventory();

    if (!SkillUtils.activationSuccessful(SecondaryAbility.SHROOM_THUMB, getPlayer(), getSkillLevel(), activationChance)) {
        player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail"));
        return false;
    }

    return Herbalism.convertShroomThumb(blockState);
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:32,代码来源:HerbalismManager.java

示例3: onClickOnObsidian

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onClickOnObsidian(final PlayerInteractEvent event) {
    if (!plugin.isSkyWorld(event.getPlayer().getWorld())) {
        return;
    }
    long now = System.currentTimeMillis();
    Player player = event.getPlayer();
    PlayerInventory inventory = player != null ? player.getInventory() : null;
    Block block = event.getClickedBlock();
    Long lastClick = obsidianClick.get(player.getUniqueId());
    if (lastClick != null && (lastClick + OBSIDIAN_SPAM) >= now) {
        plugin.notifyPlayer(player, tr("\u00a74You can only convert obsidian once every 10 seconds"));
        return;
    }
    if (Settings.extras_obsidianToLava && plugin.playerIsOnIsland(player)
            && plugin.isSkyWorld(player.getWorld())
            && event.getAction() == Action.RIGHT_CLICK_BLOCK
            && player.getItemInHand() != null
            && player.getItemInHand().getType() == Material.BUCKET
            && block != null
            && block.getType() == Material.OBSIDIAN
            && !testForObsidian(block)) {
        if (inventory.firstEmpty() != -1) {
            obsidianClick.put(player.getUniqueId(), now);
            player.sendMessage(tr("\u00a7eChanging your obsidian back into lava. Be careful!"));
            inventory.removeItem(new ItemStack(Material.BUCKET, 1));
            inventory.addItem(new ItemStack(Material.LAVA_BUCKET, 1));
            player.updateInventory();
            block.setType(Material.AIR);
            event.setCancelled(true); // Don't execute the click anymore (since that would re-place the lava).
        } else {
            player.sendMessage(tr("\u00a7eYour inventory must have another empty space!"));
        }
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:36,代码来源:PlayerEvents.java

示例4: processGreenThumbPlants

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
 * Process the Green Thumb ability for plants.
 *
 * @param blockState The {@link BlockState} to check ability activation for
 * @param greenTerra boolean to determine if greenTerra is active or not
 */
private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) {
    Player player = getPlayer();
    PlayerInventory playerInventory = player.getInventory();
    ItemStack seed = null;

    switch (blockState.getType()) {
        case CARROT:
            seed = new ItemStack(Material.CARROT_ITEM);
            break;

        case CROPS:
            seed = new ItemStack(Material.SEEDS);
            break;

        case NETHER_WARTS:
            seed = new ItemStack(Material.NETHER_STALK);
            break;

        case POTATO:
            seed = new ItemStack(Material.POTATO_ITEM);
            break;

        default:
            break;
    }

    if (!playerInventory.containsAtLeast(seed, 1)) {
        return;
    }

    if (!greenTerra && !SkillUtils.activationSuccessful(SecondaryAbility.GREEN_THUMB_PLANT, getPlayer(), getSkillLevel(), activationChance)) {
        return;
    }

    if (!handleBlockState(blockState, greenTerra)) {
        return;
    }

    playerInventory.removeItem(seed);
    player.updateInventory(); // Needed until replacement available
    new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0);
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:49,代码来源:HerbalismManager.java


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