mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-10-15 21:16:00 +00:00
Improve kit matching, and add enchantments.
Enchanted kit example in config.yml
This commit is contained in:
parent
3c9057f68e
commit
c5eb1bb105
|
@ -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
|
||||
{
|
||||
|
|
|
@ -168,14 +168,15 @@ 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:
|
||||
|
|
Loading…
Reference in a new issue