Package org.bukkit.inventory

Examples of org.bukkit.inventory.PlayerInventory


        data.instantBowInteract = 0;
        data.instantEatInteract = 0;
        data.instantEatFood = null;
       
        // Illegal enchantments hotfix check.
        final PlayerInventory inv = player.getInventory();
        Items.checkIllegalEnchantments(player, inv.getItem(event.getNewSlot()));
        Items.checkIllegalEnchantments(player, inv.getItem(event.getPreviousSlot()));
    }
View Full Code Here


     * Check if a player might return some damage due to the "thorns" enchantment.
     * @param player
     * @return
     */
    public static final boolean hasThorns(final Player player){
      final PlayerInventory inv = player.getInventory();
      final ItemStack[] contents = inv.getArmorContents();
      for (int i = 0; i < contents.length; i++){
        final ItemStack stack = contents[i];
        if (stack != null && stack.getEnchantmentLevel(Enchantment.THORNS) > 0){
          return true;
        }
View Full Code Here

    private void dropItems(Player player)
    {
        if (plugin.getSettingsManager().isDropOnHome())
        {
            PlayerInventory inv = player.getInventory();
            ItemStack[] contents = inv.getContents();

            for (ItemStack item : contents)
            {
                if (item == null)
                {
                    continue;
                }

                List<Integer> itemsList = plugin.getSettingsManager().getItemsList();

                if (itemsList.contains(item.getTypeId()))
                {
                    player.getWorld().dropItemNaturally(player.getLocation(), item);
                    inv.remove(item);
                }
            }
        }
        else if (plugin.getSettingsManager().isKeepOnHome())
        {
            try
            {
                PlayerInventory inv = player.getInventory();
                ItemStack[] contents = inv.getContents().clone();

                for (ItemStack item : contents)
                {
                    if (item == null)
                    {
                        continue;
                    }

                    List<Integer> itemsList = plugin.getSettingsManager().getItemsList();

                    if (!itemsList.contains(item.getTypeId()))
                    {
                        player.getWorld().dropItemNaturally(player.getLocation(), item);
                        inv.remove(item);
                    }
                }
            }
            catch (Exception ex)
            {
View Full Code Here

    super();
  }

  public boolean consumeItem(Player player, int itemID, Hashtable<String, String> messages) {
   
    PlayerInventory inventory = player.getInventory();
    boolean itemConsumed = false;
   
   
    int idx = inventory.first(itemID);
   
    if (idx >= 0) {
      ItemStack toConsume = inventory.getItem(idx);
      int amt = toConsume.getAmount();
      if (amt > 0) {
        itemConsumed = true;
        amt--;
        if (amt <= 0) {
          inventory.clear(idx);
        } else {
          toConsume.setAmount(amt);
        }
        DigSettings.setHadItem(player,itemID,true);
      }
View Full Code Here

  }

  // On récupère le contenu de l'inventaire de "joueur"

  ecrire("Recup de l'inventaire");
  PlayerInventory inventaire = joueur.getInventory();

  ecrire("recuperation de la liste");
  ItemStack matos[] = inventaire.getContents();


  ecrire("boucles sur l'inventaire");
  for (int i = 0; i < matos.length; i++)
  {
     
      ecrire("r�cup�ration du type");
      Material huhu = inventaire.getItem(i).getType();

      ecrire("eliminiation du vide");
      if ( ! huhu.name().contains("AIR") )
      {
    ecrire("stockage des donnees");
View Full Code Here

        if (skillLevel < minimumRepairableLevel) {
            player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", minimumRepairableLevel, StringUtils.getPrettyItemString(item.getType())));
            return;
        }

        PlayerInventory inventory = player.getInventory();

        Material repairMaterial = repairable.getRepairMaterial();
        byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
        ItemStack toRemove = new MaterialData(repairMaterial, repairMaterialMetadata).toItemStack(1);

        short startDurability = item.getDurability();

        // Do not repair if at full durability
        if (startDurability <= 0) {
            player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
            return;
        }

        // Check if they have the proper material to repair with
        if (!inventory.contains(repairMaterial)) {
            String prettyName = repairable.getRepairMaterialPrettyName() == null ? StringUtils.getPrettyItemString(repairMaterial) : repairable.getRepairMaterialPrettyName();
            String message = LocaleLoader.getString("Skills.NeedMore", prettyName);

            if (repairMaterialMetadata != (byte) -1 && !inventory.containsAtLeast(toRemove, 1)) {
                message += ":" + repairMaterialMetadata;
            }

            player.sendMessage(message);
            return;
        }

        // Do not repair stacked items
        if (item.getAmount() != 1) {
            player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems"));
            return;
        }

        // Clear ability buffs before trying to repair.
        SkillUtils.removeAbilityBuff(item);

        // Lets get down to business,
        // To defeat, the huns.
        int baseRepairAmount = repairable.getBaseRepairDurability(); // Did they send me daughters?
        short newDurability = repairCalculate(startDurability, baseRepairAmount); // When I asked for sons?

        // Call event
        if (EventUtils.callRepairCheckEvent(player, (short) (startDurability - newDurability), toRemove, item).isCancelled()) {
            return;
        }

        // Handle the enchants
        if (ArcaneForging.arcaneForgingEnchantLoss) {
            addEnchants(item);
        }

        // Remove the item
        if (repairMaterialMetadata == -1) {
            toRemove = inventory.getItem(inventory.first(repairMaterial)).clone();
            toRemove.setAmount(1);
        }

        inventory.removeItem(toRemove);

        // Give out XP like candy
        applyXpGain((float) ((getPercentageRepaired(startDurability, newDurability, repairable.getMaximumDurability()) * repairable.getXpMultiplier()) * ExperienceConfig.getInstance().getRepairXPBase() * ExperienceConfig.getInstance().getRepairXP(repairable.getRepairMaterialType())), XPGainReason.PVE);

        // BWONG BWONG BWONG
View Full Code Here

        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);
    }
View Full Code Here

     * @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;
View Full Code Here

     * @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);
    }
View Full Code Here

     * @param itemId
     * @param amount
     * @return true / false
     */
    public static boolean has(Player player, int itemId, int amount) {
  PlayerInventory inventory = player.getInventory();
  ItemStack[] items = inventory.getContents();
  int total = 0;

  for (ItemStack item : items) {
      if ((item != null) && (item.getTypeId() == itemId) && (item.getAmount() > 0)) {
    total += item.getAmount();
View Full Code Here

TOP

Related Classes of org.bukkit.inventory.PlayerInventory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.