mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-06 20:43:11 +00:00
Moving all files to trunk.
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@969 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
487577f2fa
commit
a3ebd254f2
221 changed files with 29722 additions and 0 deletions
|
@ -0,0 +1,45 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.ItemDb;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
public Commanditem()
|
||||
{
|
||||
super("item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
user.sendMessage("§cUsage: /" + commandLabel + " [item] <amount>");
|
||||
return;
|
||||
}
|
||||
String[] itemArgs = args[0].split("[^a-zA-Z0-9]");
|
||||
ItemStack stack = ItemDb.get(itemArgs[0]);
|
||||
|
||||
if(!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getTypeId()))
|
||||
{
|
||||
user.sendMessage(ChatColor.RED + "You are not allowed to spawn that item");
|
||||
return;
|
||||
}
|
||||
if (itemArgs.length > 1)
|
||||
stack.setDurability(Short.parseShort(itemArgs[1]));
|
||||
|
||||
if (args.length > 1)
|
||||
stack.setAmount(Integer.parseInt(args[1]));
|
||||
|
||||
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
|
||||
user.charge(this);
|
||||
user.sendMessage("§7Giving " + stack.getAmount() + " of " + itemName + " to " + user.getDisplayName() + ".");
|
||||
user.getInventory().addItem(stack);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue