diff options
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Kit.java | 38 | ||||
-rw-r--r-- | Essentials/src/config.yml | 7 |
2 files changed, 37 insertions, 8 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Kit.java b/Essentials/src/com/earth2me/essentials/Kit.java index cf39997ea..9f7bb5a5d 100644 --- a/Essentials/src/com/earth2me/essentials/Kit.java +++ b/Essentials/src/com/earth2me/essentials/Kit.java @@ -2,11 +2,13 @@ package com.earth2me.essentials; import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n.capitalCase; +import com.earth2me.essentials.commands.Commandenchant; import com.earth2me.essentials.commands.NoChargeException; import com.earth2me.essentials.craftbukkit.InventoryWorkaround; import java.util.*; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; @@ -86,14 +88,40 @@ public class Kit boolean spew = false; for (String d : items) { - final String[] parts = d.split("[^0-9]+", 3); - final int id = Material.getMaterial(Integer.parseInt(parts[0])).getId(); - final int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1; - final short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0; + final String[] parts = d.split(" "); + final String[] item = parts[0].split("[:+',;.]", 2); + final int id = Material.getMaterial(Integer.parseInt(item[0])).getId(); + final short data = item.length > 1 ? Short.parseShort(item[1]) : 0; + final int amount = parts.length > 1 ? Integer.parseInt(parts[1]) : 1; + + final ItemStack stack = new ItemStack(id, amount, data); + if (parts.length > 2) + { + for (int i = 2; i < parts.length; i++) + { + final String[] split = parts[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); + } + } + final Map<Integer, ItemStack> overfilled; if (user.isAuthorized("essentials.oversizedstacks")) { - overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), new ItemStack(id, amount, data)); + overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack); } else { diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index ef2485ae8..5462b6c12 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -168,19 +168,20 @@ player-commands: # Note: All items MUST be followed by a quantity! # All kit names should be lower case, and will be treated as lower in permissions/costs. +# Syntax: - itemID[:DataValue] Amount [Enchantment:Level].. # Times are measured in seconds. kits: dtools: delay: 10 items: - - 277 1 + - 277 1 efficiency:1 - 278 1 - - 279 1 + - 279:780 1 tools: delay: 10 items: - 272 1 - - 273 1 + - 273 1 - 274 1 - 275 1 |