Example #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.");
    }
  }
Example #2
0
 private boolean canGetItem(Player sender) {
   if (General.plugin.permissions.hasPermission(sender, "general.give.any")) return true;
   ConfigurationNode permissions = General.plugin.config.getNode("give");
   if (permissions == null) return true;
   List<String> groups = permissions.getKeys("groups");
   if (groups == null) return true;
   for (String group : groups) {
     List<Integer> items = permissions.getIntList("groups." + group, null);
     if (items.isEmpty()) continue;
     if (items.contains(item.getId())) {
       return General.plugin.permissions.hasPermission(sender, "general.give.group." + group);
     }
   }
   return permissions.getBoolean("others-for-all", true);
 }