Пример #1
0
  private void doGive(boolean isGift) {
    if (amount == 0) { // give one stack
      amount = Items.maxStackSize(item.getId());
    }

    int slot = who.getInventory().firstEmpty();

    if (slot < 0) {
      who.getWorld().dropItem(who.getLocation(), item.getStack(amount));
    } else {
      who.getInventory().addItem(item.getStack(amount));
    }

    if (isGift) {
      Messaging.send(
          who,
          "&2Enjoy the gift! &f"
              + (amount < 0 ? "infinite" : amount)
              + "&2 of &f"
              + Items.name(item)
              + "&2!");
    } else {
      Messaging.send(
          who,
          "&2Enjoy! Giving &f"
              + (amount < 0 ? "infinite" : amount)
              + "&2 of &f"
              + Items.name(item)
              + "&2.");
    }
  }