mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-26 16:39:45 +00:00
[trunk] /unlimited: Only give out one item, if the inventory does not contain one.
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1111 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
bc243cb7df
commit
3f4df23144
1 changed files with 6 additions and 2 deletions
|
@ -1,10 +1,12 @@
|
||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
|
import com.earth2me.essentials.InventoryWorkaround;
|
||||||
import com.earth2me.essentials.ItemDb;
|
import com.earth2me.essentials.ItemDb;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class Commandunlimited extends EssentialsCommand
|
public class Commandunlimited extends EssentialsCommand
|
||||||
|
@ -22,7 +24,7 @@ public class Commandunlimited extends EssentialsCommand
|
||||||
user.sendMessage("§cUsage: /" + commandLabel + " [item] <player>");
|
user.sendMessage("§cUsage: /" + commandLabel + " [item] <player>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack stack = ItemDb.get(args[0]);
|
ItemStack stack = ItemDb.get(args[0], 1);
|
||||||
|
|
||||||
if(!user.isAuthorized("essentials.infinite.whitelist.override") &&
|
if(!user.isAuthorized("essentials.infinite.whitelist.override") &&
|
||||||
Essentials.getSettings().getUnlimitedWhitelist().contains(stack.getTypeId()))
|
Essentials.getSettings().getUnlimitedWhitelist().contains(stack.getTypeId()))
|
||||||
|
@ -51,7 +53,9 @@ public class Commandunlimited extends EssentialsCommand
|
||||||
user.sendMessage("§7Giving unlimited amount of " + itemName + " to " + user.getDisplayName() + ".");
|
user.sendMessage("§7Giving unlimited amount of " + itemName + " to " + user.getDisplayName() + ".");
|
||||||
}
|
}
|
||||||
target.sendMessage("§7Giving unlimited amount of " + itemName + " to " + user.getDisplayName() + ".");
|
target.sendMessage("§7Giving unlimited amount of " + itemName + " to " + user.getDisplayName() + ".");
|
||||||
target.getInventory().addItem(stack);
|
if (!InventoryWorkaround.containsItem((CraftInventory)target.getInventory(), true, stack)) {
|
||||||
|
target.getInventory().addItem(stack);
|
||||||
|
}
|
||||||
target.setUnlimited(stack, true);
|
target.setUnlimited(stack, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue