Commits

Jonathan K committed 974ab0c

Moved all item ID's over to the new Materials system. Fixed a couple bugs. Updated Updater code and class to comply with new curse T&C's. Added config option and system for server list.

Comments (0)

Files changed (42)

.DS_Store

Binary file modified.

godPowers/.DS_Store

Binary file modified.

godPowers/.classpath

 <classpath>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-	<classpathentry kind="lib" path="/Volumes/JK&apos;S HDD 4/bukkit/bukkit api/Permissions.jar"/>
-	<classpathentry kind="lib" path="/Volumes/JK&apos;S HDD 4/bukkit/server/craftbukkit-1.6.2-R0.1.jar"/>
-	<classpathentry kind="lib" path="/Volumes/JK&apos;S HDD 4/bukkit/bukkit api/bukkit-1.6.1-R0.1.jar"/>
+	<classpathentry kind="lib" path="/Volumes/JK&apos;S HDD/bukkit/bukkit api/bukkit-1.6.4-R0.1-20131015.092215-9.jar"/>
+	<classpathentry kind="lib" path="/Volumes/JK&apos;S HDD/bukkit/server/craftbukkit-1.6.4-R0.1-20131015.235042-14.jar"/>
+	<classpathentry kind="lib" path="/Volumes/JK&apos;S HDD/bukkit/bukkit api/Permissions.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

godPowers/bin/com/FriedTaco/taco/godPowers/DemiGodCommand.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/DieCommand.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/DupeCommand.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/FireworkEffectPlayer.class

Binary file added.

godPowers/bin/com/FriedTaco/taco/godPowers/FusRoDAH.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/GodPowersCommand.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/HealCommand.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/InfernoCommand.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/Jesus$Raft.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/Jesus$RaftPiece.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/Jesus.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/MaimCommand.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/PlutusCommand.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/PropertiesFile.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/SlayCommand$1.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/SlayCommand.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/Updater$UpdateResult.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/Updater$UpdateRunnable.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/Updater$UpdateType.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/Updater.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/godModeCommand.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/godPowers$1.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/godPowers.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/godPowersEntityListener.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/godPowersPlayerListener$1.class

Binary file modified.

godPowers/bin/com/FriedTaco/taco/godPowers/godPowersPlayerListener$2$1.class

Binary file added.

godPowers/bin/com/FriedTaco/taco/godPowers/godPowersPlayerListener$2.class

Binary file added.

godPowers/bin/com/FriedTaco/taco/godPowers/godPowersPlayerListener.class

Binary file modified.

godPowers/plugin.yml

 name: godPowers
 main: com.FriedTaco.taco.godPowers.godPowers
-version: 3.1
+version: 3.3
 author: Swift
 commands:
     godmode:

godPowers/src/com/FriedTaco/taco/godPowers/DupeCommand.java

 package com.FriedTaco.taco.godPowers;
 
-
-//import org.bukkit.World;
 import org.bukkit.ChatColor;
+import org.bukkit.Material;
 import org.bukkit.command.Command;
 import org.bukkit.command.CommandExecutor;
 import org.bukkit.command.CommandSender;
     		{
     			if(split.length == 0){
     				int amount = 64;
-    				if(player.getItemInHand().getTypeId() != 0){
+    				if(player.getItemInHand().getType() != Material.AIR){
     					player.sendMessage(ChatColor.BLUE + "The gods have decided to multiply your items.");    	
     				Inventory inv = player.getInventory();
     				ItemStack item = player.getItemInHand();
     				newitem.setItemMeta(item.getItemMeta());
     				newitem.addEnchantments(item.getEnchantments());
     				newitem.setType(item.getType());
-    				newitem.setTypeId(item.getTypeId());  		
+    				newitem.setType(item.getType());  		
     				inv.addItem(newitem);
     				}else{
     					player.sendMessage(ChatColor.DARK_RED + "The gods cannot multiply nothing.");	
     				}
     			}else if(split.length == 1){
-    				if(player.getItemInHand().getTypeId() != 0){
+    				if(player.getItemInHand().getType() != Material.AIR){
     					player.sendMessage(ChatColor.BLUE + "The gods have decided to multiply your items.");    	
     				int amount = Integer.parseInt(split[0]);
     				if(amount == 0){
     				newitem.setItemMeta(item.getItemMeta());
     				newitem.addEnchantments(item.getEnchantments());
     				newitem.setType(item.getType());
-    				newitem.setTypeId(item.getTypeId());  		
+    				newitem.setType(item.getType());  		
     				inv.addItem(newitem);
     				}else{
     					player.sendMessage(ChatColor.DARK_RED + "The gods cannot multiply nothing.");	

godPowers/src/com/FriedTaco/taco/godPowers/FireworkEffectPlayer.java

+package com.FriedTaco.taco.godPowers;
+
+import java.lang.reflect.Method;
+
+import org.bukkit.FireworkEffect;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.entity.Firework;
+import org.bukkit.inventory.meta.FireworkMeta;
+
+public class FireworkEffectPlayer {
+    
+    /*
+     * Example use:
+     * 
+     * public class FireWorkPlugin implements Listener {
+     * 
+     * FireworkEffectPlayer fplayer = new FireworkEffectPlayer();
+     * 
+     * @EventHandler
+     * public void onPlayerLogin(PlayerLoginEvent event) {
+     *   fplayer.playFirework(event.getPlayer().getWorld(), event.getPlayer.getLocation(), Util.getRandomFireworkEffect());
+     * }
+     * 
+     * }
+     */
+    
+    // internal references, performance improvements
+    private Method world_getHandle = null;
+    private Method nms_world_broadcastEntityEffect = null;
+    private Method firework_getHandle = null;
+    
+    /**
+     * Play a pretty firework at the location with the FireworkEffect when called
+     * @param world
+     * @param loc
+     * @param fe
+     * @throws Exception
+     */
+    public void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
+        // Bukkity load (CraftFirework)
+        Firework fw = (Firework) world.spawn(loc, Firework.class);
+        // the net.minecraft.server.World
+        Object nms_world = null;
+        Object nms_firework = null;
+        /*
+         * The reflection part, this gives us access to funky ways of messing around with things
+         */
+        if(world_getHandle == null) {
+            // get the methods of the craftbukkit objects
+            world_getHandle = getMethod(world.getClass(), "getHandle");
+            firework_getHandle = getMethod(fw.getClass(), "getHandle");
+        }
+        // invoke with no arguments
+        nms_world = world_getHandle.invoke(world, (Object[]) null);
+        nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
+        // null checks are fast, so having this seperate is ok
+        if(nms_world_broadcastEntityEffect == null) {
+            // get the method of the nms_world
+            nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect");
+        }
+        /*
+         * Now we mess with the metadata, allowing nice clean spawning of a pretty firework (look, pretty lights!)
+         */
+        // metadata load
+        FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
+        // clear existing
+        data.clearEffects();
+        // power of one
+        data.setPower(1);
+        // add the effect
+        data.addEffect(fe);
+        // set the meta
+        fw.setFireworkMeta(data);
+        /*
+         * Finally, we broadcast the entity effect then kill our fireworks object
+         */
+        // invoke with arguments
+        nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {nms_firework, (byte) 17});
+        // remove from the game
+        fw.remove();
+    }
+    
+    /**
+     * Internal method, used as shorthand to grab our method in a nice friendly manner
+     * @param cl
+     * @param method
+     * @return Method (or null)
+     */
+    private static Method getMethod(Class<?> cl, String method) {
+        for(Method m : cl.getMethods()) {
+            if(m.getName().equals(method)) {
+                return m;
+            }
+        }
+        return null;
+    }
+
+}

godPowers/src/com/FriedTaco/taco/godPowers/FusRoDAH.java

 package com.FriedTaco.taco.godPowers;
 
 import org.bukkit.ChatColor;
+import org.bukkit.Material;
 import org.bukkit.command.Command;
 import org.bukkit.command.CommandExecutor;
 import org.bukkit.command.CommandSender;
     			else
     			{
     				ItemStack i = player.getItemInHand();
-    				if(i != null && i.getTypeId() != 0)
+    				if(i != null && i.getType() != Material.AIR)
     				{
     					player.sendMessage(ChatColor.DARK_RED + "Fus ro DAH!!");
     					i.addUnsafeEnchantment(Enchantment.KNOCKBACK, 10);

godPowers/src/com/FriedTaco/taco/godPowers/GodPowersCommand.java

 				player.sendMessage(ChatColor.DARK_AQUA+"Useful Links:");	
 				player.sendMessage(ChatColor.GOLD+"- "+ChatColor.GREEN+"#godpowers @ irc.esper.net"+ChatColor.GOLD+" IRC Chat");	
 				player.sendMessage(ChatColor.GOLD+"- "+ChatColor.GREEN+"bit.ly/GodPowers"+ChatColor.GOLD+" Bukkit Plugin Page");
+				player.sendMessage(ChatColor.GOLD+"- "+ChatColor.GREEN+"jfkingsley.co.uk/godpowers"+ChatColor.GOLD+" Server list");
 				player.sendMessage(ChatColor.DARK_AQUA+"Donation Info:");	
 				player.sendMessage(ChatColor.GOLD+"- "+ChatColor.GREEN+"goldgamermc@gmail.com"+ChatColor.GOLD+" Paypal");	
 				}else if(args.length == 1){
 		    		}
 				}
 				if(args[0].equalsIgnoreCase("update")){
-					Updater updater = new Updater(plugin, "godpowers", plugin.file, Updater.UpdateType.NO_DOWNLOAD, false);	
+					Updater updater = new Updater(plugin, 33866, plugin.file, Updater.UpdateType.NO_DOWNLOAD, false);
 					if(updater.getResult().equals(Updater.UpdateResult.NO_UPDATE)){
 						player.sendMessage(ChatColor.GREEN+"godPowers: "+ChatColor.GOLD+"There is currently no updates available.");		
 					}else if(updater.getResult().equals(Updater.UpdateResult.UPDATE_AVAILABLE)){
 						player.sendMessage(ChatColor.GREEN+"godPowers: "+ChatColor.GOLD+"There is currently an update available, downloading now...");	
-						@SuppressWarnings("unused")
-						Updater updater2 = new Updater(plugin, "godpowers", plugin.file, Updater.UpdateType.DEFAULT, true);	
+						new Updater(plugin, 33866, plugin.file, Updater.UpdateType.NO_VERSION_CHECK, true);
 					}
 				}
 				if(args[0].equalsIgnoreCase("credits")){

godPowers/src/com/FriedTaco/taco/godPowers/Jesus.java

 package com.FriedTaco.taco.godPowers;
 
 import java.util.Hashtable;
+
+import org.bukkit.Material;
 import org.bukkit.block.Block;
 import org.bukkit.entity.Player;
 
 		for(int i = 0; i < raft.length; i++)
 		{
 			Block block = player.getWorld().getBlockAt(((int) player.getLocation().getX() + raft[i].x), ((int) player.getLocation().getY() + raft[i].y), ((int) player.getLocation().getZ() + raft[i].z));
-			if(block.getTypeId() == 8 || block.getTypeId() == 9) 
+			if(block.getType() == Material.WATER) 
 			{
 				raftX[i] = (int) player.getLocation().getX()+raft[i].x;
 				raftY[i] = (int) player.getLocation().getY()+raft[i].y;
 				raftZ[i] = (int) player.getLocation().getZ()+raft[i].z;
 				raft[i].made = true;
-				block.setTypeId(79);
+				block.setType(Material.ICE);
 			} 
-			else if(block.getTypeId() == 10 || block.getTypeId() == 11)
+			else if(block.getType() == Material.LAVA)
 			{
 				raftX[i] = (int) player.getLocation().getX()+raft[i].x;
 				raftY[i] = (int) player.getLocation().getY()+raft[i].y;
 				raftZ[i] = (int) player.getLocation().getZ()+raft[i].z;
 				raft[i].made = true;
-				block.setTypeId(49);
+				block.setType(Material.OBSIDIAN);
 			}
 			else 
 			{
 			}
 		}
 	}
-	void destroyJesusRaft(Player player)
-	{
-		for(int i = 0; i < raft.length; i++)
-		{
+	void destroyJesusRaft(Player player){
+		for(int i = 0; i < raft.length; i++){
 			Block block = player.getWorld().getBlockAt(((int)raftX[i]), ((int)raftY[i]), ((int)raftZ[i]));
-			if(block.getTypeId() == 79)
-			{
-				block.setTypeId(8);
-			}
-			else if(block.getTypeId() == 49)
-			{
-				block.setTypeId(10);
+			if(block.getType() == Material.ICE){
+				block.setType(Material.WATER);
+			}else if(block.getType() == Material.OBSIDIAN){
+				block.setType(Material.LAVA);
 			}
-			if (raft[i].made)
-			{
+			if (raft[i].made){
 				raft[i].made = false;
 			}
 		}

godPowers/src/com/FriedTaco/taco/godPowers/PlutusCommand.java

 package com.FriedTaco.taco.godPowers;
 
 import java.util.ArrayList;
+
 import org.bukkit.ChatColor;
+import org.bukkit.Material;
 import org.bukkit.command.Command;
 import org.bukkit.command.CommandExecutor;
 import org.bukkit.command.CommandSender;
     			}
     			else
     			{
-    				int poss[] = {256,257,258,269,270,271,273,274,275,277,278,279,284,285,286};
-    				ArrayList<Integer> possible = new ArrayList<Integer>();
-    				for(int i=0;i<poss.length;i++)
-    					possible.add(poss[i]);
+    				Material poss[] = {Material.IRON_SPADE,Material.IRON_PICKAXE,Material.IRON_AXE,Material.WOOD_SPADE,Material.WOOD_PICKAXE,Material.WOOD_AXE,Material.STONE_SPADE,Material.STONE_PICKAXE,Material.STONE_AXE,Material.DIAMOND_SPADE,Material.DIAMOND_PICKAXE,Material.DIAMOND_AXE,Material.GOLD_SPADE,Material.GOLD_PICKAXE,Material.GOLD_AXE};
+    				ArrayList<Material> possible = new ArrayList<Material>();
+    				for(int i=0;i<poss.length;i++)possible.add(poss[i]);
     				ItemStack i = player.getItemInHand();
-    				if(i != null && possible.contains(Integer.valueOf(i.getTypeId())))
+    				if(i != null && possible.contains(i.getType()))
     				{
     					player.sendMessage(ChatColor.GOLD + "You suddenly feel as if earthly riches will come easily to you.");
     					i.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 25);

godPowers/src/com/FriedTaco/taco/godPowers/SlayCommand.java

 package com.FriedTaco.taco.godPowers;
 
-//import org.bukkit.World;
 import org.bukkit.ChatColor;
 import org.bukkit.Location;
+import org.bukkit.Material;
 import org.bukkit.World;
 import org.bukkit.command.Command;
 import org.bukkit.command.CommandExecutor;
 					{
 						int x = -4;
 						Location arrows = new Location(world, targetPlayer.getLocation().getX()+x, targetPlayer.getLocation().getY()+1, targetPlayer.getLocation().getZ()+x);
-						while(arrows.getBlock().getTypeId() != 0)
+						while(arrows.getBlock().getType() != Material.AIR)
 						{
 								arrows = new Location(world, targetPlayer.getLocation().getX()+x, targetPlayer.getLocation().getY()+1, targetPlayer.getLocation().getZ()+x);
-								if(arrows.getBlock().getTypeId() == 0)
+								if(arrows.getBlock().getType() == Material.AIR)
 									break;
 								else if(x > 4)
 									break;

godPowers/src/com/FriedTaco/taco/godPowers/Updater.java

 package com.FriedTaco.taco.godPowers;
+/*
+ * Updater for Bukkit.
+ *
+ * This class provides the means to safely and easily update a plugin, or check to see if it is updated using dev.bukkit.org
+ */
 
 import java.io.*;
-import java.lang.Runnable;
-import java.lang.Thread;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.Enumeration;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.events.XMLEvent;
+
 import org.bukkit.configuration.file.YamlConfiguration;
 import org.bukkit.plugin.Plugin;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
 
 /**
  * Check dev.bukkit.org to find updates for a given plugin, and download the updates if needed.
- * <p>
+ * <p/>
  * <b>VERY, VERY IMPORTANT</b>: Because there are no standards for adding auto-update toggles in your plugin's config, this system provides NO CHECK WITH YOUR CONFIG to make sure the user has allowed auto-updating.
  * <br>
  * It is a <b>BUKKIT POLICY</b> that you include a boolean value in your config that prevents the auto-updater from running <b>AT ALL</b>.
  * <br>
  * If you fail to include this option in your config, your plugin will be <b>REJECTED</b> when you attempt to submit it to dev.bukkit.org.
- * <p>
+ * <p/>
  * An example of a good configuration option would be something similar to 'auto-update: true' - if this value is set to false you may NOT run the auto-updater.
  * <br>
  * If you are unsure about these rules, please read the plugin submission guidelines: http://goo.gl/8iU5l
  *
- * @author H31IX
+ * @author Gravity
+ * @version 2.0
  */
 
-public class Updater
-{
+public class Updater {
+
     private Plugin plugin;
     private UpdateType type;
-    private String versionTitle;
+    private String versionName;
     private String versionLink;
-    private long totalSize; // Holds the total size of the file
-    //private double downloadedSize; TODO: Holds the number of bytes downloaded
-    private int sizeLine; // Used for detecting file size
-    private int multiplier; // Used for determining when to broadcast download updates
+    private String versionType;
+    private String versionGameVersion;
+
     private boolean announce; // Whether to announce file downloads
+
     private URL url; // Connecting to RSS
     private File file; // The plugin's file
     private Thread thread; // Updater thread
-    private static final String DBOUrl = "http://dev.bukkit.org/server-mods/"; // Slugs will be appended to this to get to the project's RSS feed
-    private String [] noUpdateTag = {"-DEV","-PRE","-SNAPSHOT"}; // If the version number contains one of these, don't update.
+
+    private int id = -1; // Project's Curse ID
+    private String apiKey = null; // BukkitDev ServerMods API key
+    private static final String TITLE_VALUE = "name"; // Gets remote file's title
+    private static final String LINK_VALUE = "downloadUrl"; // Gets remote file's download link
+    private static final String TYPE_VALUE = "releaseType"; // Gets remote file's release type
+    private static final String VERSION_VALUE = "gameVersion"; // Gets remote file's build version
+    private static final String QUERY = "/servermods/files?projectIds="; // Path to GET
+    private static final String HOST = "https://api.curseforge.com"; // Slugs will be appended to this to get to the project's RSS feed
+
+    private static final String[] NO_UPDATE_TAG = { "-DEV", "-PRE", "-SNAPSHOT" }; // If the version number contains one of these, don't update.
     private static final int BYTE_SIZE = 1024; // Used for downloading files
-    private String updateFolder = YamlConfiguration.loadConfiguration(new File("bukkit.yml")).getString("settings.update-folder"); // The folder that downloads will be placed in
+    private YamlConfiguration config; // Config file
+    private String updateFolder;// The folder that downloads will be placed in
     private Updater.UpdateResult result = Updater.UpdateResult.SUCCESS; // Used for determining the outcome of the update process
-    // Strings for reading RSS
-    private static final String TITLE = "title";
-    private static final String LINK = "link";
-    private static final String ITEM = "item";
 
     /**
      * Gives the dev the result of the update process. Can be obtained by called getResult().
      */
-    public enum UpdateResult
-    {
+    public enum UpdateResult {
         /**
          * The updater found an update, and has readied it to be loaded the next time the server restarts/reloads.
          */
          */
         NO_UPDATE,
         /**
+         * The server administrator has disabled the updating system
+         */
+        DISABLED,
+        /**
          * The updater found an update, but was unable to download it.
          */
         FAIL_DOWNLOAD,
          */
         FAIL_NOVERSION,
         /**
-         * The slug provided by the plugin running the updater was invalid and doesn't exist on DBO.
+         * The id provided by the plugin running the updater was invalid and doesn't exist on DBO.
          */
-        FAIL_BADSLUG,
+        FAIL_BADID,
+        /**
+         * The server administrator has improperly configured their API key in the configuration
+         */
+        FAIL_APIKEY,
         /**
          * The updater found an update, but because of the UpdateType being set to NO_DOWNLOAD, it wasn't downloaded.
          */
     /**
      * Allows the dev to specify the type of update that will be run.
      */
-    public enum UpdateType
-    {
+    public enum UpdateType {
         /**
          * Run a version check, and then if the file is out of date, download the newest version.
          */
     /**
      * Initialize the updater
      *
-     * @param plugin
-     *            The plugin that is checking for an update.
-     * @param slug
-     *            The dev.bukkit.org slug of the project (http://dev.bukkit.org/server-mods/SLUG_IS_HERE)
-     * @param file
-     *            The file that the plugin is running from, get this by doing this.getFile() from within your main class.
-     * @param type
-     *            Specify the type of update this will be. See {@link UpdateType}
-     * @param announce
-     *            True if the program should announce the progress of new updates in console
+     * @param plugin   The plugin that is checking for an update.
+     * @param id       The dev.bukkit.org id of the project
+     * @param file     The file that the plugin is running from, get this by doing this.getFile() from within your main class.
+     * @param type     Specify the type of update this will be. See {@link UpdateType}
+     * @param announce True if the program should announce the progress of new updates in console
      */
-    public Updater(Plugin plugin, String slug, File file, UpdateType type, boolean announce)
-    {
+    public Updater(Plugin plugin, int id, File file, UpdateType type, boolean announce) {
         this.plugin = plugin;
         this.type = type;
         this.announce = announce;
         this.file = file;
-        try
-        {
-            // Obtain the results of the project's file feed
-            url = new URL(DBOUrl + slug + "/files.rss");
+        this.id = id;
+        this.updateFolder = plugin.getServer().getUpdateFolder();
+
+        final File pluginFile = plugin.getDataFolder().getParentFile();
+        final File updaterFile = new File(pluginFile, "Updater");
+        final File updaterConfigFile = new File(updaterFile, "config.yml");
+
+        if (!updaterFile.exists()) {
+            updaterFile.mkdir();
+        }
+        if (!updaterConfigFile.exists()) {
+            try {
+                updaterConfigFile.createNewFile();
+            } catch (final IOException e) {
+                plugin.getLogger().severe("The updater could not create a configuration in " + updaterFile.getAbsolutePath());
+                e.printStackTrace();
+            }
+        }
+        this.config = YamlConfiguration.loadConfiguration(updaterConfigFile);
+
+        this.config.options().header("This configuration file affects all plugins using the Updater system (version 2+ - http://forums.bukkit.org/threads/96681/ )" + '\n'
+                + "If you wish to use your API key, read http://wiki.bukkit.org/ServerMods_API and place it below." + '\n'
+                + "Some updating systems will not adhere to the disabled value, but these may be turned off in their plugin's configuration.");
+        this.config.addDefault("api-key", "PUT_API_KEY_HERE");
+        this.config.addDefault("disable", false);
+
+        if (this.config.get("api-key", null) == null) {
+            this.config.options().copyDefaults(true);
+            try {
+                this.config.save(updaterConfigFile);
+            } catch (final IOException e) {
+                plugin.getLogger().severe("The updater could not save the configuration in " + updaterFile.getAbsolutePath());
+                e.printStackTrace();
+            }
+        }
+
+        if (this.config.getBoolean("disable")) {
+            this.result = UpdateResult.DISABLED;
+            return;
         }
-        catch (MalformedURLException ex)
-        {
-            // Invalid slug
-            plugin.getLogger().warning("The author of this plugin (" + plugin.getDescription().getAuthors().get(0) + ") has misconfigured their Auto Update system");
-            plugin.getLogger().warning("The project slug given ('" + slug + "') is invalid. Please nag the author about this.");
-            result = Updater.UpdateResult.FAIL_BADSLUG; // Bad slug! Bad!
+
+        String key = this.config.getString("api-key");
+        if (key.equalsIgnoreCase("PUT_API_KEY_HERE") || key.equals("")) {
+            key = null;
+        }
+
+        this.apiKey = key;
+
+        try {
+            this.url = new URL(Updater.HOST + Updater.QUERY + id);
+        } catch (final MalformedURLException e) {
+            plugin.getLogger().severe("The project ID provided for updating, " + id + " is invalid.");
+            this.result = UpdateResult.FAIL_BADID;
+            e.printStackTrace();
         }
-        thread = new Thread(new UpdateRunnable());
-        thread.start();
+
+        this.thread = new Thread(new UpdateRunnable());
+        this.thread.start();
     }
 
     /**
      * Get the result of the update process.
      */
-    public Updater.UpdateResult getResult()
-    {
-        waitForThread();
-        return result;
+    public Updater.UpdateResult getResult() {
+        this.waitForThread();
+        return this.result;
+    }
+
+    /**
+     * Get the latest version's release type (release, beta, or alpha).
+     */
+    public String getLatestType() {
+        this.waitForThread();
+        return this.versionType;
+    }
+
+    /**
+     * Get the latest version's game version.
+     */
+    public String getLatestGameVersion() {
+        this.waitForThread();
+        return this.versionGameVersion;
     }
 
     /**
-     * Get the total bytes of the file (can only be used after running a version check or a normal run).
+     * Get the latest version's name.
      */
-    public long getFileSize()
-    {
-        waitForThread();
-        return totalSize;
+    public String getLatestName() {
+        this.waitForThread();
+        return this.versionName;
     }
 
     /**
-     * Get the version string latest file avaliable online.
+     * Get the latest version's file link.
      */
-    public String getLatestVersionString()
-    {
-        waitForThread();
-        return versionTitle;
+    public String getLatestFileLink() {
+        this.waitForThread();
+        return this.versionLink;
     }
 
     /**
      * As the result of Updater output depends on the thread's completion, it is necessary to wait for the thread to finish
-     * before alloowing anyone to check the result.
+     * before allowing anyone to check the result.
      */
-    public void waitForThread() {
-        if(thread.isAlive()) {
+    private void waitForThread() {
+        if ((this.thread != null) && this.thread.isAlive()) {
             try {
-                thread.join();
-            } catch (InterruptedException e) {
+                this.thread.join();
+            } catch (final InterruptedException e) {
                 e.printStackTrace();
             }
         }
     /**
      * Save an update from dev.bukkit.org into the server's update folder.
      */
-    private void saveFile(File folder, String file, String u)
-    {
-        if(!folder.exists())
-        {
+    private void saveFile(File folder, String file, String u) {
+        if (!folder.exists()) {
             folder.mkdir();
         }
         BufferedInputStream in = null;
         FileOutputStream fout = null;
-        try
-        {
+        try {
             // Download the file
-            URL url = new URL(u);
-            int fileLength = url.openConnection().getContentLength();
+            final URL url = new URL(u);
+            final int fileLength = url.openConnection().getContentLength();
             in = new BufferedInputStream(url.openStream());
             fout = new FileOutputStream(folder.getAbsolutePath() + "/" + file);
 
-            byte[] data = new byte[BYTE_SIZE];
+            final byte[] data = new byte[Updater.BYTE_SIZE];
             int count;
-            if(announce) plugin.getLogger().info("About to download a new update: " + versionTitle);
+            if (this.announce) {
+                this.plugin.getLogger().info("About to download a new update: " + this.versionName);
+            }
             long downloaded = 0;
-            while ((count = in.read(data, 0, BYTE_SIZE)) != -1)
-            {
+            while ((count = in.read(data, 0, Updater.BYTE_SIZE)) != -1) {
                 downloaded += count;
                 fout.write(data, 0, count);
-                int percent = (int) (downloaded * 100 / fileLength);
-                if(announce & (percent % 10 == 0))
-                {
-                    plugin.getLogger().info("Downloading update: " + percent + "% of " + fileLength + " bytes.");
+                final int percent = (int) ((downloaded * 100) / fileLength);
+                if (this.announce && ((percent % 10) == 0)) {
+                    this.plugin.getLogger().info("Downloading update: " + percent + "% of " + fileLength + " bytes.");
                 }
             }
             //Just a quick check to make sure we didn't leave any files from last time...
-            for(File xFile : new File("plugins/" + updateFolder).listFiles())
-            {
-                if(xFile.getName().endsWith(".zip"))
-                {
+            for (final File xFile : new File(this.plugin.getDataFolder().getParent(), this.updateFolder).listFiles()) {
+                if (xFile.getName().endsWith(".zip")) {
                     xFile.delete();
                 }
             }
             // Check to see if it's a zip file, if it is, unzip it.
-            File dFile = new File(folder.getAbsolutePath() + "/" + file);
-            if(dFile.getName().endsWith(".zip"))
-            {
+            final File dFile = new File(folder.getAbsolutePath() + "/" + file);
+            if (dFile.getName().endsWith(".zip")) {
                 // Unzip
-                unzip(dFile.getCanonicalPath());
+                this.unzip(dFile.getCanonicalPath());
             }
-            if(announce) plugin.getLogger().info("Finished updating.");
-        }
-        catch (Exception ex)
-        {
-            plugin.getLogger().warning("The auto-updater tried to download a new update, but was unsuccessful.");
-            result = Updater.UpdateResult.FAIL_DOWNLOAD;
-        }
-        finally
-        {
-            try
-            {
-                if (in != null)
-                {
+            if (this.announce) {
+                this.plugin.getLogger().info("Finished updating.");
+            }
+        } catch (final Exception ex) {
+            this.plugin.getLogger().warning("The auto-updater tried to download a new update, but was unsuccessful.");
+            this.result = Updater.UpdateResult.FAIL_DOWNLOAD;
+        } finally {
+            try {
+                if (in != null) {
                     in.close();
                 }
-                if (fout != null)
-                {
+                if (fout != null) {
                     fout.close();
                 }
-            }
-            catch (Exception ex)
-            {
+            } catch (final Exception ex) {
             }
         }
     }
 
     /**
-     * Part of Zip-File-Extractor, modified by H31IX for use with Bukkit
+     * Part of Zip-File-Extractor, modified by Gravity for use with Bukkit
      */
-    private void unzip(String file)
-    {
-        try
-        {
-            File fSourceZip = new File(file);
-            String zipPath = file.substring(0, file.length()-4);
+    private void unzip(String file) {
+        try {
+            final File fSourceZip = new File(file);
+            final String zipPath = file.substring(0, file.length() - 4);
             ZipFile zipFile = new ZipFile(fSourceZip);
             Enumeration<? extends ZipEntry> e = zipFile.entries();
-            while(e.hasMoreElements())
-            {
-                ZipEntry entry = (ZipEntry)e.nextElement();
-                File destinationFilePath = new File(zipPath,entry.getName());
+            while (e.hasMoreElements()) {
+                ZipEntry entry = e.nextElement();
+                File destinationFilePath = new File(zipPath, entry.getName());
                 destinationFilePath.getParentFile().mkdirs();
-                if(entry.isDirectory())
-                {
+                if (entry.isDirectory()) {
                     continue;
-                }
-                else
-                {
-                    BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry));
+                } else {
+                    final BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry));
                     int b;
-                    byte buffer[] = new byte[BYTE_SIZE];
-                    FileOutputStream fos = new FileOutputStream(destinationFilePath);
-                    BufferedOutputStream bos = new BufferedOutputStream(fos, BYTE_SIZE);
-                    while((b = bis.read(buffer, 0, BYTE_SIZE)) != -1)
-                    {
+                    final byte buffer[] = new byte[Updater.BYTE_SIZE];
+                    final FileOutputStream fos = new FileOutputStream(destinationFilePath);
+                    final BufferedOutputStream bos = new BufferedOutputStream(fos, Updater.BYTE_SIZE);
+                    while ((b = bis.read(buffer, 0, Updater.BYTE_SIZE)) != -1) {
                         bos.write(buffer, 0, b);
                     }
                     bos.flush();
                     bos.close();
                     bis.close();
-                    String name = destinationFilePath.getName();
-                    if(name.endsWith(".jar") && pluginFile(name))
-                    {
-                        destinationFilePath.renameTo(new File("plugins/" + updateFolder + "/" + name));
+                    final String name = destinationFilePath.getName();
+                    if (name.endsWith(".jar") && this.pluginFile(name)) {
+                        destinationFilePath.renameTo(new File(this.plugin.getDataFolder().getParent(), this.updateFolder + "/" + name));
                     }
                 }
                 entry = null;
             e = null;
             zipFile.close();
             zipFile = null;
+
             // Move any plugin data folders that were included to the right place, Bukkit won't do this for us.
-            for(File dFile : new File(zipPath).listFiles())
-            {
-                if(dFile.isDirectory())
-                {
-                    if(pluginFile(dFile.getName()))
-                    {
-                        File oFile = new File("plugins/" + dFile.getName()); // Get current dir
-                        File [] contents = oFile.listFiles(); // List of existing files in the current dir
-                        for(File cFile : dFile.listFiles()) // Loop through all the files in the new dir
+            for (final File dFile : new File(zipPath).listFiles()) {
+                if (dFile.isDirectory()) {
+                    if (this.pluginFile(dFile.getName())) {
+                        final File oFile = new File(this.plugin.getDataFolder().getParent(), dFile.getName()); // Get current dir
+                        final File[] contents = oFile.listFiles(); // List of existing files in the current dir
+                        for (final File cFile : dFile.listFiles()) // Loop through all the files in the new dir
                         {
                             boolean found = false;
-                            for(File xFile : contents) // Loop through contents to see if it exists
+                            for (final File xFile : contents) // Loop through contents to see if it exists
                             {
-                                if(xFile.getName().equals(cFile.getName()))
-                                {
+                                if (xFile.getName().equals(cFile.getName())) {
                                     found = true;
                                     break;
                                 }
                             }
-                            if(!found)
-                            {
+                            if (!found) {
                                 // Move the new file into the current dir
                                 cFile.renameTo(new File(oFile.getCanonicalFile() + "/" + cFile.getName()));
-                            }
-                            else
-                            {
+                            } else {
                                 // This file already exists, so we don't need it anymore.
                                 cFile.delete();
                             }
             }
             new File(zipPath).delete();
             fSourceZip.delete();
-        }
-        catch(IOException ex)
-        {
+        } catch (final IOException ex) {
+            this.plugin.getLogger().warning("The auto-updater tried to unzip a new update file, but was unsuccessful.");
+            this.result = Updater.UpdateResult.FAIL_DOWNLOAD;
             ex.printStackTrace();
-            plugin.getLogger().warning("The auto-updater tried to unzip a new update file, but was unsuccessful.");
-            result = Updater.UpdateResult.FAIL_DOWNLOAD;
         }
         new File(file).delete();
     }
     /**
      * Check if the name of a jar is one of the plugins currently installed, used for extracting the correct files out of a zip.
      */
-    public boolean pluginFile(String name)
-    {
-        for(File file : new File("plugins").listFiles())
-        {
-            if(file.getName().equals(name))
-            {
+    private boolean pluginFile(String name) {
+        for (final File file : new File("plugins").listFiles()) {
+            if (file.getName().equals(name)) {
                 return true;
             }
         }
     }
 
     /**
-     * Obtain the direct download file url from the file's page.
-     */
-    private String getFile(String link)
-    {
-        String download = null;
-        try
-        {
-            // Open a connection to the page
-            URL url = new URL(link);
-            URLConnection urlConn = url.openConnection();
-            InputStreamReader inStream = new InputStreamReader(urlConn.getInputStream());
-            BufferedReader buff = new BufferedReader(inStream);
-
-            int counter = 0;
-            String line;
-            while((line = buff.readLine()) != null)
-            {
-                counter++;
-                // Search for the download link
-                if(line.contains("<li class=\"user-action user-action-download\">"))
-                {
-                    // Get the raw link
-                    download = line.split("<a href=\"")[1].split("\">Download</a>")[0];
-                }
-                // Search for size
-                else if (line.contains("<dt>Size</dt>"))
-                {
-                    sizeLine = counter+1;
-                }
-                else if(counter == sizeLine)
-                {
-                    String size = line.replaceAll("<dd>", "").replaceAll("</dd>", "");
-                    multiplier = size.contains("MiB") ? 1048576 : 1024;
-                    size = size.replace(" KiB", "").replace(" MiB", "");
-                    totalSize = (long)(Double.parseDouble(size)*multiplier);
-                }
-            }
-            urlConn = null;
-            inStream = null;
-            buff.close();
-            buff = null;
-        }
-        catch (Exception ex)
-        {
-            ex.printStackTrace();
-            plugin.getLogger().warning("The auto-updater tried to contact dev.bukkit.org, but was unsuccessful.");
-            result = Updater.UpdateResult.FAIL_DBO;
-            return null;
-        }
-        return download;
-    }
-
-    /**
      * Check to see if the program should continue by evaluation whether the plugin is already updated, or shouldn't be updated
      */
-    private boolean versionCheck(String title)
-    {
-        if(type != UpdateType.NO_VERSION_CHECK)
-        {
-            String version = plugin.getDescription().getVersion();
-            if(title.split("v").length == 2)
-            {
-                String remoteVersion = title.split("v")[1].split(" ")[0]; // Get the newest file's version number
-                int remVer = -1,curVer=0;
-                try
-                {
-                    remVer = calVer(remoteVersion);
-                    curVer = calVer(version);
-                }
-                catch(NumberFormatException nfe)
-                {
-                    remVer=-1;
-                }
-                if(hasTag(version)||version.equalsIgnoreCase(remoteVersion)||curVer>=remVer)
-                {
+    private boolean versionCheck(String title) {
+        if (this.type != UpdateType.NO_VERSION_CHECK) {
+            final String version = this.plugin.getDescription().getVersion();
+            if (title.split(" v").length == 2) {
+                final String remoteVersion = title.split(" v")[1].split(" ")[0]; // Get the newest file's version number
+
+                if (this.hasTag(version) || version.equalsIgnoreCase(remoteVersion)) {
                     // We already have the latest version, or this build is tagged for no-update
-                    result = Updater.UpdateResult.NO_UPDATE;
+                    this.result = Updater.UpdateResult.NO_UPDATE;
                     return false;
                 }
-            }
-            else
-            {
+            } else {
                 // The file's name did not contain the string 'vVersion'
-                plugin.getLogger().warning("The author of this plugin (" + plugin.getDescription().getAuthors().get(0) + ") has misconfigured their Auto Update system");
-                plugin.getLogger().warning("Files uploaded to BukkitDev should contain the version number, seperated from the name by a 'v', such as PluginName v1.0");
-                plugin.getLogger().warning("Please notify the author of this error.");
-                result = Updater.UpdateResult.FAIL_NOVERSION;
+                final String authorInfo = this.plugin.getDescription().getAuthors().size() == 0 ? "" : " (" + this.plugin.getDescription().getAuthors().get(0) + ")";
+                this.plugin.getLogger().warning("The author of this plugin" + authorInfo + " has misconfigured their Auto Update system");
+                this.plugin.getLogger().warning("File versions should follow the format 'PluginName vVERSION'");
+                this.plugin.getLogger().warning("Please notify the author of this error.");
+                this.result = Updater.UpdateResult.FAIL_NOVERSION;
                 return false;
             }
         }
         return true;
     }
-    /**
-     * Used to calculate the version string as an Integer
-     */
-    private Integer calVer(String s) throws NumberFormatException
-    {
-        if(s.contains("."))
-        {
-            StringBuilder sb = new StringBuilder();
-            for (int i = 0; i <s.length(); i++)
-            {
-                Character c = s.charAt(i);
-                if (Character.isLetterOrDigit(c))
-                {
-                    sb.append(c);
-                }
-            }
-            return Integer.parseInt(sb.toString());
-        }
-        return Integer.parseInt(s);
-    }
+
     /**
      * Evaluate whether the version number is marked showing that it should not be updated by this program
      */
-    private boolean hasTag(String version)
-    {
-        for(String string : noUpdateTag)
-        {
-            if(version.contains(string))
-            {
+    private boolean hasTag(String version) {
+        for (final String string : Updater.NO_UPDATE_TAG) {
+            if (version.contains(string)) {
                 return true;
             }
         }
         return false;
     }
 
-    /**
-     * Part of RSS Reader by Vogella, modified by H31IX for use with Bukkit
-     */
-    private boolean readFeed()
-    {
-        try
-        {
-            // Set header values intial to the empty string
-            String title = "";
-            String link = "";
-            // First create a new XMLInputFactory
-            XMLInputFactory inputFactory = XMLInputFactory.newInstance();
-            // Setup a new eventReader
-            InputStream in = read();
-            if(in != null)
-            {
-                XMLEventReader eventReader = inputFactory.createXMLEventReader(in);
-                // Read the XML document
-                while (eventReader.hasNext())
-                {
-                    XMLEvent event = eventReader.nextEvent();
-                    if (event.isStartElement())
-                    {
-                        if (event.asStartElement().getName().getLocalPart().equals(TITLE))
-                        {
-                            event = eventReader.nextEvent();
-                            title = event.asCharacters().getData();
-                            continue;
-                        }
-                        if (event.asStartElement().getName().getLocalPart().equals(LINK))
-                        {
-                            event = eventReader.nextEvent();
-                            link = event.asCharacters().getData();
-                            continue;
-                        }
-                    }
-                    else if (event.isEndElement())
-                    {
-                        if (event.asEndElement().getName().getLocalPart().equals(ITEM))
-                        {
-                            // Store the title and link of the first entry we get - the first file on the list is all we need
-                            versionTitle = title;
-                            versionLink = link;
-                            // All done, we don't need to know about older files.
-                            break;
-                        }
-                    }
-                }
-                return true;
+    private boolean read() {
+        try {
+            final URLConnection conn = this.url.openConnection();
+            conn.setConnectTimeout(5000);
+
+            if (this.apiKey != null) {
+                conn.addRequestProperty("X-API-Key", this.apiKey);
             }
-            else
-            {
+            conn.addRequestProperty("User-Agent", "Updater (by Gravity)");
+
+            conn.setDoOutput(true);
+
+            final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+            final String response = reader.readLine();
+
+            final JSONArray array = (JSONArray) JSONValue.parse(response);
+
+            if (array.size() == 0) {
+                this.plugin.getLogger().warning("The updater could not find any files for the project id " + this.id);
+                this.result = UpdateResult.FAIL_BADID;
                 return false;
             }
-        }
-        catch (XMLStreamException e)
-        {
-            plugin.getLogger().warning("Could not reach dev.bukkit.org for update checking. Is it offline?");
-            return false;
-        }
-    }
 
-    /**
-     * Open the RSS feed
-     */
-    private InputStream read()
-    {
-        try
-        {
-            return url.openStream();
-        }
-        catch (IOException e)
-        {
-            plugin.getLogger().warning("Could not reach BukkitDev file stream for update checking. Is dev.bukkit.org offline?");
-            return null;
+            this.versionName = (String) ((JSONObject) array.get(array.size() - 1)).get(Updater.TITLE_VALUE);
+            this.versionLink = (String) ((JSONObject) array.get(array.size() - 1)).get(Updater.LINK_VALUE);
+            this.versionType = (String) ((JSONObject) array.get(array.size() - 1)).get(Updater.TYPE_VALUE);
+            this.versionGameVersion = (String) ((JSONObject) array.get(array.size() - 1)).get(Updater.VERSION_VALUE);
+
+            return true;
+        } catch (final IOException e) {
+            if (e.getMessage().contains("HTTP response code: 403")) {
+                this.plugin.getLogger().warning("dev.bukkit.org rejected the API key provided in plugins/Updater/config.yml");
+                this.plugin.getLogger().warning("Please double-check your configuration to ensure it is correct.");
+                this.result = UpdateResult.FAIL_APIKEY;
+            } else {
+                this.plugin.getLogger().warning("The updater could not contact dev.bukkit.org for updating.");
+                this.plugin.getLogger().warning("If you have not recently modified your configuration and this is the first time you are seeing this message, the site may be experiencing temporary downtime.");
+                this.result = UpdateResult.FAIL_DBO;
+            }
+            e.printStackTrace();
+            return false;
         }
     }
 
     private class UpdateRunnable implements Runnable {
 
+        @Override
         public void run() {
-            if(url != null)
-            {
+            if (Updater.this.url != null) {
                 // Obtain the results of the project's file feed
-                if(readFeed())
-                {
-                    if(versionCheck(versionTitle))
-                    {
-                        String fileLink = getFile(versionLink);
-                        if(fileLink != null && type != UpdateType.NO_DOWNLOAD)
-                        {
-                            String name = file.getName();
+                if (Updater.this.read()) {
+                    if (Updater.this.versionCheck(Updater.this.versionName)) {
+                        if ((Updater.this.versionLink != null) && (Updater.this.type != UpdateType.NO_DOWNLOAD)) {
+                            String name = Updater.this.file.getName();
                             // If it's a zip file, it shouldn't be downloaded as the plugin's name
-                            if(fileLink.endsWith(".zip"))
-                            {
-                                String [] split = fileLink.split("/");
-                                name = split[split.length-1];
+                            if (Updater.this.versionLink.endsWith(".zip")) {
+                                final String[] split = Updater.this.versionLink.split("/");
+                                name = split[split.length - 1];
                             }
-                            saveFile(new File("plugins/" + updateFolder), name, fileLink);
-                        }
-                        else
-                        {
-                            result = UpdateResult.UPDATE_AVAILABLE;
+                            Updater.this.saveFile(new File(Updater.this.plugin.getDataFolder().getParent(), Updater.this.updateFolder), name, Updater.this.versionLink);
+                        } else {
+                            Updater.this.result = UpdateResult.UPDATE_AVAILABLE;
                         }
                     }
                 }
             }
         }
     }
-}
+}

godPowers/src/com/FriedTaco/taco/godPowers/godPowers.java

 import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.net.MalformedURLException;
+import java.net.HttpURLConnection;
 import java.net.URL;
+import java.net.URLEncoder;
 import java.util.logging.Logger;
 import java.util.ArrayList;
 import java.util.HashMap;
-
 import org.bukkit.ChatColor;
 import org.bukkit.Location;
+import org.bukkit.Material;
 import org.bukkit.World;
+import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
 import org.bukkit.enchantments.Enchantment;
 import org.bukkit.entity.Arrow;
 import org.bukkit.entity.Entity;
 import org.bukkit.entity.Player;
-import org.bukkit.event.player.PlayerLoginEvent;
 import org.bukkit.inventory.ItemStack;
 import org.bukkit.plugin.PluginDescriptionFile;
 import org.bukkit.plugin.java.JavaPlugin;
 import org.bukkit.plugin.PluginManager;
 import org.bukkit.scheduler.BukkitTask;
 import org.bukkit.util.Vector;
-
 import com.FriedTaco.taco.godPowers.Metrics.Plotter;
+import com.FriedTaco.taco.godPowers.Updater.UpdateResult;
 
 
 
 		public ArrayList<String> isVulcan = new ArrayList<String>();
 		public ArrayList<String> DemiGod = new ArrayList<String>();
 		public ArrayList<String> hades = new ArrayList<String>();
-		public ArrayList<Integer> shovelDrops = new ArrayList<Integer>();
-		public ArrayList<Integer> pickDrops = new ArrayList<Integer>();
-		public ArrayList<Integer> axeDrops = new ArrayList<Integer>();
+		public ArrayList<Material> shovelDrops = new ArrayList<Material>();
+		public ArrayList<Material> pickDrops = new ArrayList<Material>();
+		public ArrayList<Material> axeDrops = new ArrayList<Material>();
 		public HashMap<String,String> list = new HashMap<String,String>();
 		public double DemiModifier = 0;
 		public boolean godModeOnLogin = true;
 		public boolean godTools = true;
-		public boolean autoUpdate = true;
+		public boolean autoUpdate = false;
 		public boolean checkUpdate = true;
+		public boolean uploadToList = true;
 		public int medusaFreezeTime = 10;
 		public File file;
 		 public void loadConfig(){
 	            	this.getConfig().set("AutoUpdateEnabled", false);
 	            if(!this.getConfig().contains("CheckUpdateEnabled"))
 	            	this.getConfig().set("CheckUpdateEnabled", true);
+	            if(!this.getConfig().contains("UploadToServerList"))
+	            	this.getConfig().set("UploadToServerList", true);
 	            if(!this.getConfig().contains("MedusaFreezeTime"))
 	            	this.getConfig().set("MedusaFreezeTime", 10);
 	            checkUpdate = this.getConfig().getBoolean("CheckUpdateEnabled",false);
 	            autoUpdate = this.getConfig().getBoolean("AutoUpdateEnabled",false);
+	            uploadToList = this.getConfig().getBoolean("UploadToServerList",true);
 	            title = this.getConfig().getString("GodModeTitle", "");
 	            godModeOnLogin = this.getConfig().getBoolean("GodModeOnLogin", true);
 	            DemiModifier= this.getConfig().getDouble("DemiGodDamageModifier", 0.2);
 	            medusaFreezeTime = this.getConfig().getInt("MedusaFreezeTime",10); 
 	            this.saveConfig();
 			 } catch(Exception e){
-				 
+			e.printStackTrace();	 
 			 }
 	        }
 	    
 	    		System.out.println("[GodPowers] Failed to send stats to MCStats/Metrics :-(");
 	    	    // Failed to submit the stats :-(
 	    	}
-	    	if(autoUpdate == true){
-	    		@SuppressWarnings("unused")
-				Updater updater = new Updater(this, "godpowers", this.getFile(), Updater.UpdateType.DEFAULT, false);	
-	    	}
 	    	if(checkUpdate == true){
-	    		String str2 = null;
-		    	try {
-		    	    // Create a URL for the desired page
-		    	    URL url = new URL("https://dl.dropboxusercontent.com/s/6vds499fw62s84u/godPowersVersion.txt?token_hash=AAHXoUyvrsAvKT4hZVQ6zqdnQPJ-1Jn_sLQkJ9rDlwr-NQ&dl=1");
-		    	    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
-		    	    String str;
-		    	    while ((str = in.readLine()) != null) {
-		    	        str2 = str;
-		    	    }
-		    	    in.close();
-		    	} catch (MalformedURLException e) {
-		    		System.out.println("[GodPowers] Failed to check version.");	
-		    	} catch (IOException e) {
-		    		System.out.println("[GodPowers] Failed to check version.");	
-		    	}
-		    	if(str2 != null){
-		    	if(Double.valueOf(this.getDescription().getVersion()) < Double.parseDouble(str2)){
-		    	this.getServer().broadcastMessage(ChatColor.RED+"[godPowers] There is an updated version of godPowers available: http://bit.ly/GodPowers");	
-		    	}
+	    		Updater updater = new Updater(this, 33866, this.getFile(), Updater.UpdateType.NO_DOWNLOAD, false); // Start Updater but just do a version check
+	    		if(updater.getResult() == UpdateResult.UPDATE_AVAILABLE){
+	    		this.getServer().broadcastMessage(ChatColor.RED+"[GodPowers] An update is available: "+updater.getLatestName()+", a "+updater.getLatestType()+" for "+updater.getLatestGameVersion()+" available at "+updater.getLatestFileLink());
+	    		if(autoUpdate == true){
+		    		new Updater(this, 33866, this.getFile(), Updater.UpdateType.NO_VERSION_CHECK, true);
+		    		this.getServer().broadcastMessage(ChatColor.RED+"[GodPowers] An update is available: "+updater.getLatestName()+", downloading and updating automatically..");
 		    	}
+	    		}
 	    	}
+	      if(uploadToList){
+     	   String ip = null;
+     	   try{
+     	   URL whatismyip = new URL("http://checkip.amazonaws.com");
+     	   BufferedReader in = new BufferedReader(new InputStreamReader(
+     	                   whatismyip.openStream()));
+     	   ip = in.readLine(); //you get the IP as a String
+     	   }catch(Exception e){
+     		   e.printStackTrace();
+     	   }
+	    	try{
+	    	String data = ((CraftServer)this.getServer()).toString();
+	    	data = data.substring(12, data.length()-1);
+	    	data = data.split(",")[2].substring(17);      
+			String url = "http://jfkingsley.co.uk/godPowers.php?IP="+URLEncoder.encode(ip,"UTF-8")+"&MOTD="+URLEncoder.encode(getServer().getMotd(),"UTF-8")+"&VERSION="+URLEncoder.encode(data,"UTF-8");
+			URL obj = new URL(url);
+			HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+			con.setRequestMethod("GET");
+			con.setRequestProperty("User-Agent", "Mozilla/5.0");
+			int responseCode = con.getResponseCode();
+			System.out.println("Response Code from server list: " + responseCode);
+			BufferedReader in = new BufferedReader(
+			        new InputStreamReader(con.getInputStream()));
+			String inputLine;
+			StringBuffer response = new StringBuffer();
+			while ((inputLine = in.readLine()) != null) {
+				response.append(inputLine);
+			}
+			in.close();
+			System.out.println("Response: "+response);
+	        }catch(Exception e){
+			e.printStackTrace();	
+			}
+	      }
 	    	String message = "[GodPowers] Successfully registered command ";
 	    	String error = "[GodPowers] ERROR another plugin has already taken the command ";
 	    	try{
 	    	} catch(Exception e) {
 	    		System.out.println(error + "poseidon.");
 	    	}
-	       
 
 	        PluginManager pm = getServer().getPluginManager();
 	        pm.registerEvents(new godPowersEntityListener(this), this);
 	    }
 	    public void populateLists()
 	    {
-	    	shovelDrops.add(2);
-	    	shovelDrops.add(3);
-	    	shovelDrops.add(12);
-	    	shovelDrops.add(13);
-	    	shovelDrops.add(82);
-	    	pickDrops.add(1);
-	    	pickDrops.add(4);
-	    	pickDrops.add(14);
-	    	pickDrops.add(15);
-	    	pickDrops.add(16);
-	    	pickDrops.add(21);
-	    	pickDrops.add(22);
-	    	pickDrops.add(24);
-	    	pickDrops.add(41);
-	    	pickDrops.add(42);
-	    	pickDrops.add(43);
-	    	pickDrops.add(44);
-	    	pickDrops.add(45);
-	    	pickDrops.add(48);
-	    	pickDrops.add(49);
-	    	pickDrops.add(56);
-	    	pickDrops.add(57);
-	    	axeDrops.add(5);
-	    	axeDrops.add(17);
+	    	shovelDrops.add(Material.GRASS);
+	    	shovelDrops.add(Material.DIRT);
+	    	shovelDrops.add(Material.SAND);
+	    	shovelDrops.add(Material.GRAVEL);
+	    	shovelDrops.add(Material.CLAY);
+	    	pickDrops.add(Material.STONE);
+	    	pickDrops.add(Material.COBBLESTONE);
+	    	pickDrops.add(Material.GOLD_ORE);
+	    	pickDrops.add(Material.IRON_ORE);
+	    	pickDrops.add(Material.COAL_ORE);
+	    	pickDrops.add(Material.LAPIS_ORE);
+	    	pickDrops.add(Material.LAPIS_BLOCK);
+	    	pickDrops.add(Material.SANDSTONE);
+	    	pickDrops.add(Material.GOLD_BLOCK);
+	    	pickDrops.add(Material.IRON_BLOCK);
+	    	pickDrops.add(Material.DOUBLE_STEP);
+	    	pickDrops.add(Material.STEP);
+	    	pickDrops.add(Material.BRICK);
+	    	pickDrops.add(Material.MOSSY_COBBLESTONE);
+	    	pickDrops.add(Material.OBSIDIAN);
+	    	pickDrops.add(Material.DIAMOND_ORE);
+	    	pickDrops.add(Material.DIAMOND_BLOCK);
+	    	axeDrops.add(Material.WOOD);
+	    	axeDrops.add(Material.LOG);
 	    	
 	    }
 	    public boolean isDebugging(final Player player) {
 				Location position = new Location(player.getWorld(), player.getLocation().getX(),player.getLocation().getY(), player.getLocation().getZ());
 					for(int x=0; x<item.length; x++)
 					{
-						if(item[x] != null && item[x].getTypeId() != 0)
+						if(item[x] != null && item[x].getType() != Material.AIR)
 						{
 							player.getWorld().dropItemNaturally(position,item[x]);
 						}
 					}
 			}
 		}
-
-		public void recordEvent(PlayerLoginEvent event) {
-			
-		}
 		public void arrowSlay(Location arrows, World world, Player player)
 	    {
 					arrows = new Location(world, player.getLocation().getX()+2, player.getLocation().getY()+1, player.getLocation().getZ()+2);
 			{
 				if(i!=null)
 				{
-					switch(i.getTypeId())
+					switch(i.getType())
 					{
-					case 256:
+					case IRON_SPADE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
+						i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 257:
+					case IRON_PICKAXE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
+						i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 258:
+					case IRON_AXE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 261:
+					case BOW:
 						i.addEnchantment(Enchantment.ARROW_DAMAGE, 5);
 						i.addEnchantment(Enchantment.ARROW_FIRE, 1);
 						i.addEnchantment(Enchantment.ARROW_KNOCKBACK, 2);
 						i.addEnchantment(Enchantment.ARROW_INFINITE, 1);
 						break;
-					case 267:
+					case IRON_SWORD:
 						i.addEnchantment(Enchantment.DAMAGE_ALL, 5);
 						i.addEnchantment(Enchantment.DAMAGE_ARTHROPODS, 5);
 						i.addEnchantment(Enchantment.DAMAGE_UNDEAD, 5);
 						i.addEnchantment(Enchantment.KNOCKBACK, 2);
 						i.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
 						break;
-					case 268:
+					case WOOD_SWORD:
 						i.addEnchantment(Enchantment.DAMAGE_ALL, 5);
 						i.addEnchantment(Enchantment.DAMAGE_ARTHROPODS, 5);
 						i.addEnchantment(Enchantment.DAMAGE_UNDEAD, 5);
 						i.addEnchantment(Enchantment.KNOCKBACK, 2);
 						i.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
 						break;
-					case 269:
+					case WOOD_SPADE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
+						i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 270:
+					case WOOD_PICKAXE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 271:
+					case WOOD_AXE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 272:
+					case STONE_SWORD:
 						i.addEnchantment(Enchantment.DAMAGE_ALL, 5);
 						i.addEnchantment(Enchantment.DAMAGE_ARTHROPODS, 5);
 						i.addEnchantment(Enchantment.DAMAGE_UNDEAD, 5);
 						i.addEnchantment(Enchantment.KNOCKBACK, 2);
 						i.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
 						break;
-					case 273:
+					case STONE_SPADE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
+						i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 274:
+					case STONE_PICKAXE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
 						i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 275:
+					case STONE_AXE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 276:
+					case DIAMOND_SWORD:
 						i.addEnchantment(Enchantment.DAMAGE_ALL, 5);
 						i.addEnchantment(Enchantment.DAMAGE_ARTHROPODS, 5);
 						i.addEnchantment(Enchantment.DAMAGE_UNDEAD, 5);
 						i.addEnchantment(Enchantment.KNOCKBACK, 2);
 						i.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
 						break;
-					case 277:
+					case DIAMOND_SPADE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
+						i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 278:
+					case DIAMOND_PICKAXE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
+						i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 279:
+					case DIAMOND_AXE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 283:
+					case GOLD_SWORD:
 						i.addEnchantment(Enchantment.DAMAGE_ALL, 5);
 						i.addEnchantment(Enchantment.DAMAGE_ARTHROPODS, 5);
 						i.addEnchantment(Enchantment.DAMAGE_UNDEAD, 5);
 						i.addEnchantment(Enchantment.KNOCKBACK, 2);
 						i.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
 						break;
-					case 284:
+					case GOLD_SPADE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
+						i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 285:
+					case GOLD_PICKAXE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
+						i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 286:
+					case GOLD_AXE:
 						i.addEnchantment(Enchantment.DIG_SPEED, 5);
 						i.addEnchantment(Enchantment.DURABILITY, 3);
-						//i.addEnchantment(Enchantment.SILK_TOUCH, 1);
 						i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
 						break;
-					case 298:
-						i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
-						i.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
-						i.addEnchantment(Enchantment.OXYGEN, 3);
-						i.addEnchantment(Enchantment.WATER_WORKER, 1);
-						i.addEnchantment(Enchantment.THORNS, 3);
-						break;
-					case 299:
-						i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
-						i.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
-						i.addEnchantment(Enchantment.THORNS, 3);
-						break;
-					case 300:
-						i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
-						i.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
-						i.addEnchantment(Enchantment.THORNS, 3);
-						break;
-					case 301:
-						i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
-						i.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FALL, 4);
-						i.addEnchantment(Enchantment.THORNS, 3);
-						break;
-					case 302:
-						i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
-						i.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
-						i.addEnchantment(Enchantment.OXYGEN, 3);
-						i.addEnchantment(Enchantment.WATER_WORKER, 1);
-						i.addEnchantment(Enchantment.THORNS, 3);
-						break;
-					case 303:
-						i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
-						i.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
-						i.addEnchantment(Enchantment.THORNS, 3);
-						break;
-					case 304:
-						i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
-						i.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
-						i.addEnchantment(Enchantment.THORNS, 3);
-						break;
-					case 305:
-						i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
-						i.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FALL, 4);
-						i.addEnchantment(Enchantment.THORNS, 3);
-						break;
-					case 306:
-						i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
-						i.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
-						i.addEnchantment(Enchantment.OXYGEN, 3);
-						i.addEnchantment(Enchantment.WATER_WORKER, 1);
-						i.addEnchantment(Enchantment.THORNS, 3);
-						break;
-					case 307:
-						i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
-						i.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
-						i.addEnchantment(Enchantment.THORNS, 3);
-						break;
-					case 308:
-						i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
-						i.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
-						i.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
-						i.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);