Skip to content

Commit

Permalink
Corrected the file paths for getting the plugins jar to be compatible…
Browse files Browse the repository at this point in the history
… with any operating system
  • Loading branch information
Taiterio authored and Taiterio committed May 17, 2015
1 parent 469dd60 commit 6b89761
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CustomEnchantments
main: com.taiter.ce.Main
version: 2.3
version: 2.3a

softdepend: [WorldGuard, WorldEdit, Vault]

Expand Down
13 changes: 11 additions & 2 deletions src/com/taiter/ce/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -500,14 +500,23 @@ public static void makeLists(boolean finalize, boolean printSuccess) {

//--------------Dynamic enchantment class loading-------------------------------
try {
JarFile jar = new JarFile(plugin.getDataFolder().getParent() + "\\CustomEnchantments.jar");
JarFile jar = new JarFile(plugin.getDataFolder().getParent() + File.separator + "CustomEnchantments.jar");
Enumeration<JarEntry> entries = jar.entries();

while (entries.hasMoreElements()) {
String entryName = entries.nextElement().getName();
if(!entryName.contains("$") && entryName.contains("Enchantments") && !entryName.contains("CEnchantment"))
try {
enchantments.add((CEnchantment) classLoader.loadClass(entryName.replace(".class", "").replaceAll("/", ".")).getDeclaredConstructor(Application.class).newInstance(Application.valueOf(entryName.split("/")[4].toUpperCase())));
Application app = null;
String className = entryName.replace(".class", "");
if(entryName.contains("/")) {
app = Application.valueOf(entryName.split("/")[4].toUpperCase());
className = className.replaceAll("/", ".");
} else if(entryName.contains("\\")) {
app = Application.valueOf(entryName.split("\\")[4].toUpperCase());
className = className.replaceAll("\\", ".");
}
enchantments.add((CEnchantment) classLoader.loadClass(className).getDeclaredConstructor(Application.class).newInstance(app));
} catch(ClassNotFoundException e) {} //Checked exception, should never be thrown
}

Expand Down

0 comments on commit 6b89761

Please sign in to comment.