From 26899369ec21fee0cbec75adc3f4d9b97cf74241 Mon Sep 17 00:00:00 2001 From: Dani Date: Mon, 27 Apr 2015 05:39:15 +0700 Subject: [PATCH] Ignore error for non module class. --- src/main/java/me/blackvein/quests/Quests.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/blackvein/quests/Quests.java b/src/main/java/me/blackvein/quests/Quests.java index 32c26e39c..307a79f3a 100644 --- a/src/main/java/me/blackvein/quests/Quests.java +++ b/src/main/java/me/blackvein/quests/Quests.java @@ -625,7 +625,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, URL[] urls = {new URL("jar:file:" + jar.getPath() + "!/")}; ClassLoader cl = URLClassLoader.newInstance(urls, getClassLoader()); - + + int count = 0; + while (e.hasMoreElements()) { JarEntry je = (JarEntry) e.nextElement(); @@ -645,6 +647,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, customRequirements.add(requirement); String name = requirement.getName() == null ? "[" + jar.getName() + "]" : requirement.getName(); String author = requirement.getAuthor() == null ? "[Unknown]" : requirement.getAuthor(); + count++; getLogger().info("Loaded Module: " + name + " by " + author); } else if (CustomReward.class.isAssignableFrom(c)) { @@ -655,6 +658,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, customRewards.add(reward); String name = reward.getName() == null ? "[" + jar.getName() + "]" : reward.getName(); String author = reward.getAuthor() == null ? "[Unknown]" : reward.getAuthor(); + count++; getLogger().info("Loaded Module: " + name + " by " + author); } else if (CustomObjective.class.isAssignableFrom(c)) { @@ -665,13 +669,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, customObjectives.add(objective); String name = objective.getName() == null ? "[" + jar.getName() + "]" : objective.getName(); String author = objective.getAuthor() == null ? "[Unknown]" : objective.getAuthor(); + count++; getLogger().info("Loaded Module: " + name + " by " + author); - } else { - getLogger().severe("Error: Unable to load module from file: " + jar.getName() + ", jar file is not a valid module!"); } } + if(count == 0) { + getLogger().severe("Error: Unable to load module from file: " + jar.getName() + ", jar file is not a valid module!"); + } + } catch (Exception e) { getLogger().severe("Error: Unable to load module from file: " + jar.getName()); if (debug) {