示例#1
0
  public void giveItems(int itemId, long count, Element element, int power) {
    Player player = getPlayer();
    if (player == null) {
      return;
    }

    if (count <= 0) {
      count = 1;
    }

    // Get template of item
    ItemTemplate template = ItemHolder.getInstance().getTemplate(itemId);
    if (template == null) {
      return;
    }

    for (int i = 0; i < count; i++) {
      ItemInstance item = ItemFunctions.createItem(itemId);

      if (element != Element.NONE) {
        item.setAttributeElement(element, power);
      }

      // Add items to player's inventory
      player.getInventory().addItem(item);
    }

    player.sendPacket(SystemMessage2.obtainItems(template.getItemId(), count, 0));
    player.sendChanges();
  }
示例#2
0
  /**
   * Добавить предмет игроку
   *
   * @param itemId
   * @param count
   * @param rate - учет квестовых рейтов
   */
  public void giveItems(int itemId, long count, boolean rate) {
    Player player = getPlayer();
    if (player == null) {
      return;
    }

    if (count <= 0) {
      count = 1;
    }

    if (rate) {
      count = (long) (count * getRateQuestsReward());
    }

    ItemFunctions.addItem(player, itemId, count, true);
    player.sendChanges();
  }