return;
ChatColor fuelColor = findColor(is.getItemMeta().getDisplayName());
ItemStack tool = event.getResult();
ItemStack oldtool = event.getSource();
ItemMeta metaold;
if (oldtool.hasItemMeta())
metaold = oldtool.getItemMeta();
else
metaold = Bukkit.getItemFactory().getItemMeta(oldtool.getType());
if (!metaold.hasLore()) {
event.setCancelled(true);
event.setResult(oldtool);
return;
}
boolean namTest = false;
for (String n : metaold.getLore())
if (ChatColor.stripColor(n).equalsIgnoreCase("(Socket)")) {
namTest = true;
}
if (!namTest) {
event.setResult(event.getSource());
return;
}
tool.addUnsafeEnchantments(oldtool.getEnchantments());
ItemMeta meta = tool.getItemMeta();
if (fuel.equals(Material.SKULL_ITEM)) {
ChatColor color = ChatColor.WHITE;
if (metaold.hasDisplayName())
color = findColor(metaold.getDisplayName());
SkullMeta skull = (SkullMeta) is.getItemMeta();
String skullName = skull.getOwner();
if ((skullName == null) || (skullName.trim().length() < 1)) {
switch (is.getData().getData()) {
// TODO: Fix
case 4: {
skullName = "Creeper";
break;
}
case 3: {
skullName = "Steve";
break;
}
case 0: {
skullName = "Skeleton";
break;
}
case 1: {
skullName = "Wither";
break;
}
case 2: {
skullName = "Zombie";
break;
}
default: {
skullName = "";
break;
}
}
}
String old = null;
if (metaold.hasDisplayName())
old = metaold.getDisplayName();
if (old != null) {
if (old.contains("'")) {
old = old.split("'")[1].substring(2);
}
metaold.setDisplayName(color + skullName + "'s "
+ ChatColor.stripColor(old));
}
}
List<String> list = new ArrayList<String>();
for (String s : metaold.getLore()) {
list.add(s);
}
if (list.contains(fuelColor + "(Socket)")) {
if (plugin.getItemAPI().isArmor(tool.getType())
&& plugin.defenselore.size() > 0) {
list.remove(fuelColor + "(Socket)");
String effect = plugin.defenselore.get(plugin.getSingleRandom()
.nextInt(plugin.defenselore.size()));
String effectToRemove = null;
for (String s : list) {
String[] split = s.split(" ");
if (split.length <= 1)
continue;
String[] splitEffect = effect.split(" ");
if (splitEffect.length <= 1)
continue;
if (ChatColor.stripColor(split[1]).equals(splitEffect[1])) {
effectToRemove = s;
int level = getInt(s, 0) + getInt(effect, 0);
String levelString = (level > 0) ? "+"
+ String.valueOf(level) : String.valueOf(level);
String newEffect = levelString;
for (String s2 : splitEffect) {
if (s2.equals(splitEffect[0]))
continue;
newEffect = newEffect + " " + s2;
}
effect = newEffect;
}
}
if (effectToRemove != null)
list.remove(effectToRemove);
list.add(fuelColor + effect);
} else if (plugin.getItemAPI().isTool(tool.getType())
&& plugin.offenselore.size() > 0) {
list.remove(fuelColor + "(Socket)");
String effect = plugin.offenselore.get(plugin.getSingleRandom()
.nextInt(plugin.offenselore.size()));
String effectToRemove = null;
for (String s : list) {
String[] split = s.split(" ");
if (split.length <= 1)
continue;
String[] splitEffect = effect.split(" ");
if (splitEffect.length <= 1)
continue;
if (ChatColor.stripColor(split[1]).equals(splitEffect[1])) {
effectToRemove = s;
int level = getInt(s, 0) + getInt(effect, 0);
String levelString = (level > 0) ? "+"
+ String.valueOf(level) : String.valueOf(level);
String newEffect = levelString;
for (String s2 : splitEffect) {
if (s2.equals(splitEffect[0]))
continue;
newEffect = newEffect + " " + s2;
}
effect = newEffect;
}
}
if (effectToRemove != null)
list.remove(effectToRemove);
list.add(fuelColor + effect);
}
}
SocketEnhancementEvent see = new SocketEnhancementEvent(
event.getSource(), is, tool, ((Furnace) event.getBlock()
.getState()));
plugin.getServer().getPluginManager().callEvent(see);
meta.setDisplayName(metaold.getDisplayName());
meta.setLore(list);
tool.setItemMeta(meta);
tool.setDurability(oldtool.getDurability());
event.setResult(tool);
return;
}