From f6aa6f63acd38a5bacb1f623ef4d18cc72c4ae22 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 10 Apr 2013 10:35:35 +0200 Subject: [PATCH] Remove some unused zcore files. --- .../massivecraft/factions/zcore/MPlugin.java | 3 -- .../factions/zcore/util/ClassLoadHack.java | 51 ------------------- .../factions/zcore/util/LibLoader.java | 51 ------------------- .../factions/zcore/util/WorldUtil.java | 39 -------------- 4 files changed, 144 deletions(-) delete mode 100644 src/com/massivecraft/factions/zcore/util/ClassLoadHack.java delete mode 100644 src/com/massivecraft/factions/zcore/util/LibLoader.java delete mode 100644 src/com/massivecraft/factions/zcore/util/WorldUtil.java diff --git a/src/com/massivecraft/factions/zcore/MPlugin.java b/src/com/massivecraft/factions/zcore/MPlugin.java index f93ac411..cb03d725 100644 --- a/src/com/massivecraft/factions/zcore/MPlugin.java +++ b/src/com/massivecraft/factions/zcore/MPlugin.java @@ -8,7 +8,6 @@ import org.bukkit.plugin.java.JavaPlugin; import com.massivecraft.factions.zcore.persist.EM; import com.massivecraft.factions.zcore.persist.SaveTask; -import com.massivecraft.factions.zcore.util.LibLoader; import com.massivecraft.factions.zcore.util.PermUtil; import com.massivecraft.factions.zcore.util.Persist; import com.massivecraft.mcore.util.Txt; @@ -20,7 +19,6 @@ public abstract class MPlugin extends JavaPlugin { // Some utils public Persist persist; - public LibLoader lib; public PermUtil perm; // Persist related @@ -49,7 +47,6 @@ public abstract class MPlugin extends JavaPlugin // Create Utility Instances this.perm = new PermUtil(this); this.persist = new Persist(this); - this.lib = new LibLoader(this); // GSON 2.1 is now embedded in CraftBukkit, used by the auto-updater: https://github.com/Bukkit/CraftBukkit/commit/0ed1d1fdbb1e0bc09a70bc7bfdf40c1de8411665 // if ( ! lib.require("gson.jar", "http://search.maven.org/remotecontent?filepath=com/google/code/gson/gson/2.1/gson-2.1.jar")) return false; diff --git a/src/com/massivecraft/factions/zcore/util/ClassLoadHack.java b/src/com/massivecraft/factions/zcore/util/ClassLoadHack.java deleted file mode 100644 index d478cc5f..00000000 --- a/src/com/massivecraft/factions/zcore/util/ClassLoadHack.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.massivecraft.factions.zcore.util; - -import java.io.File; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; - -public class ClassLoadHack { - - private static URLClassLoader sysloader = (URLClassLoader)ClassLoader.getSystemClassLoader(); - - public static boolean load(String filename) - { - return load(new File(filename)); - } - - public static boolean load(File file) - { - try - { - return load(file.toURI().toURL()); - } - catch (MalformedURLException e) - { - return false; - } - } - - public static boolean load(URL url) - { - // If the file already is loaded we can skip it - for (URL otherUrl : sysloader.getURLs()) - { - if (otherUrl.sameFile(url)) return true; - } - - try - { - Method addURLMethod = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{ URL.class }); - addURLMethod.setAccessible(true); - addURLMethod.invoke(sysloader, new Object[]{ url }); - return true; - } - catch (Exception e) - { - return false; - } - } - -} \ No newline at end of file diff --git a/src/com/massivecraft/factions/zcore/util/LibLoader.java b/src/com/massivecraft/factions/zcore/util/LibLoader.java deleted file mode 100644 index ee7dba4f..00000000 --- a/src/com/massivecraft/factions/zcore/util/LibLoader.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.massivecraft.factions.zcore.util; - -import java.io.File; - -import com.massivecraft.factions.zcore.MPlugin; -import com.massivecraft.mcore.util.DiscUtil; - -public class LibLoader -{ - MPlugin p; - public LibLoader(MPlugin p) - { - this.p = p; - new File("./lib").mkdirs(); - } - - public boolean require(String filename, String url) - { - if ( ! include(filename, url)) - { - p.log("Failed to load the required library "+filename); - p.suicide(); - return false; - } - return true; - } - - public boolean include (String filename, String url) - { - File file = getFile(filename); - if ( ! file.exists()) - { - p.log("Downloading library "+filename); - if ( ! DiscUtil.downloadUrl(url, file)) - { - p.log("Failed to download "+filename); - return false; - } - } - - return ClassLoadHack.load(file); - } - - private static File getFile(String filename) - { - return new File("./lib/"+filename); - } -} - - - diff --git a/src/com/massivecraft/factions/zcore/util/WorldUtil.java b/src/com/massivecraft/factions/zcore/util/WorldUtil.java deleted file mode 100644 index 4e451cde..00000000 --- a/src/com/massivecraft/factions/zcore/util/WorldUtil.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.massivecraft.factions.zcore.util; - -import java.io.File; - -import org.bukkit.Bukkit; - -public class WorldUtil -{ - // Previously We had crappy support for multiworld management. - // This should however be handled by an external plugin! - /*public static boolean load(String name) { - if (isWorldLoaded(name)) { - return true; - } - - if ( ! doesWorldExist(name)) { - return false; - } - - Environment env = WorldEnv.get(name); - if (env == null) { - P.log(Level.WARNING, "Failed to load world. Environment was unknown."); - return false; - } - - P.p.getServer().createWorld(name, env); - return true; - }*/ - - public static boolean isWorldLoaded(String name) - { - return Bukkit.getServer().getWorld(name) != null; - } - - public static boolean doesWorldExist(String name) - { - return new File(name, "level.dat").exists(); - } -}