mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-10-01 17:17:27 +02: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._;
|
||||||
import static com.earth2me.essentials.I18n.capitalCase;
|
import static com.earth2me.essentials.I18n.capitalCase;
|
||||||
|
import com.earth2me.essentials.commands.Commandenchant;
|
||||||
import com.earth2me.essentials.commands.NoChargeException;
|
import com.earth2me.essentials.commands.NoChargeException;
|
||||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
@ -86,14 +88,40 @@ public class Kit
|
|||||||
boolean spew = false;
|
boolean spew = false;
|
||||||
for (String d : items)
|
for (String d : items)
|
||||||
{
|
{
|
||||||
final String[] parts = d.split("[^0-9]+", 3);
|
final String[] parts = d.split(" ");
|
||||||
final int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
|
final String[] item = parts[0].split("[:+',;.]", 2);
|
||||||
final int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
|
final int id = Material.getMaterial(Integer.parseInt(item[0])).getId();
|
||||||
final short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
|
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;
|
final Map<Integer, ItemStack> overfilled;
|
||||||
if (user.isAuthorized("essentials.oversizedstacks"))
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -168,19 +168,20 @@ player-commands:
|
|||||||
|
|
||||||
# Note: All items MUST be followed by a quantity!
|
# 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.
|
# 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.
|
# Times are measured in seconds.
|
||||||
kits:
|
kits:
|
||||||
dtools:
|
dtools:
|
||||||
delay: 10
|
delay: 10
|
||||||
items:
|
items:
|
||||||
- 277 1
|
- 277 1 efficiency:1
|
||||||
- 278 1
|
- 278 1
|
||||||
- 279 1
|
- 279:780 1
|
||||||
tools:
|
tools:
|
||||||
delay: 10
|
delay: 10
|
||||||
items:
|
items:
|
||||||
- 272 1
|
- 272 1
|
||||||
- 273 1
|
- 273 1
|
||||||
- 274 1
|
- 274 1
|
||||||
- 275 1
|
- 275 1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user