mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-06 20:43:11 +00:00
Added enchantment to /give and /item
Updated plugin.yml
This commit is contained in:
parent
b8f9a4b96f
commit
098072517a
5 changed files with 85 additions and 18 deletions
|
@ -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"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue