package com.colt.HeadRegen;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.java.JavaPlugin;

public class HeadRegen extends JavaPlugin {
	
	public void onEnable() {
		saveConfig();
	}
	
	public void onDisable() {
		skulls.clear();
		lore.clear();
	}
	
	List<String> lore = new ArrayList<String>();
	ArrayList<ItemStack> skulls = new ArrayList<ItemStack>();
	
	@EventHandler
	public void click(PlayerInteractEvent e) {
	Player p = e.getPlayer();
    	if(!p.hasPermission("headregen.use")) {
    		String msg = ChatColor.translateAlternateColorCodes('&', getConfig().getString("noperms"));
    		p.sendMessage(msg);
    	} else {
		if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK) || e.getAction().equals(Action.RIGHT_CLICK_AIR)) {
			if(skulls.contains(e.getItem())) {
				Inventory inv = p.getInventory();		
				inv.removeItem(e.getItem());
				skulls.remove(e.getItem());
				p.setHealth(p.getHealth() + getConfig().getDouble("Hearts"));
			}
		}
    	}
	}
	
    @EventHandler
    public void kill(PlayerDeathEvent e) {
    	Player p = (Player)e.getEntity();
    	if(p.hasPermission("headregen.use")) {
    	lore.clear();
    	lore.add(ChatColor.AQUA + "Right Click for a +" + ChatColor.GREEN + "" + getConfig().getDouble("Hearts") + "" + ChatColor.AQUA + " Heart Regen!");
    	ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
    	SkullMeta meta = (SkullMeta)skull.getItemMeta();
    	meta.setOwner(p.getName());
    	meta.setDisplayName(p.getName());
    	meta.setLore(lore);
    	skull.setItemMeta(meta);
    	skulls.add(skull);
    	p.getWorld().dropItemNaturally(p.getLocation(), skull);
    }
    }
}

@@ -1602,16 +1602,148 @@
 );%0A    %09
+List%3CString%3E worlds = getConfig().getStringList(%22worlds%22);%0A    %09for(String w : worlds) %7B%0A    %09%09if(p.getWorld().equals(w)) %7B%09%0A    %09%09%09
 if(p.has
@@ -1774,24 +1774,27 @@
 e%22)) %7B%0A    %09
+%09%09%09
 lore.clear()
@@ -1800,16 +1800,19 @@
 );%0A    %09
+%09%09%09
 lore.add
@@ -1955,16 +1955,19 @@
 );%0A    %09
+%09%09%09
 ItemStac
@@ -2056,16 +2056,19 @@
 );%0A    %09
+%09%09%09
 SkullMet
@@ -2105,32 +2105,35 @@
 temMeta();%0A    %09
+%09%09%09
 meta.setOwner(p.
@@ -2141,32 +2141,35 @@
 etName());%0A    %09
+%09%09%09
 meta.setDisplayN
@@ -2191,16 +2191,19 @@
 );%0A    %09
+%09%09%09
 meta.set
@@ -2215,24 +2215,27 @@
 lore);%0A    %09
+%09%09%09
 skull.setIte
@@ -2252,16 +2252,19 @@
 );%0A    %09
+%09%09%09
 skulls.a
@@ -2279,16 +2279,19 @@
 );%0A    %09
+%09%09%09
 p.getWor
@@ -2342,16 +2342,34 @@
 l);%0A    
+%09%09%09%7D%0A    %09%09%7D%0A    %09
 %7D%0A    %7D%0A

Update HeadRegen.java