Added enchantment to /give and /item

Updated plugin.yml
This commit is contained in:
snowleo 2011-11-27 08:57:21 +01:00
parent b8f9a4b96f
commit 098072517a
5 changed files with 85 additions and 18 deletions

View file

@ -5,6 +5,7 @@ import com.earth2me.essentials.User;
import java.util.Locale;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@ -40,6 +41,29 @@ public class Commanditem extends EssentialsCommand
stack.setAmount(Integer.parseInt(args[1]));
}
if (args.length > 2)
{
for (int i = 2; i < args.length; i++)
{
final String[] split = args[i].split("[:+',;.]", 2);
if (split.length < 1)
{
continue;
}
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], user);
int level;
if (split.length > 1)
{
level = Integer.parseInt(split[1]);
}
else
{
level = enchantment.getMaxLevel();
}
stack.addEnchantment(enchantment, level);
}
}
if (stack.getType() == Material.AIR)
{
throw new Exception(_("cantSpawnItem", "Air"));