Don't fatal error if someone's using a dumb jar system
This commit is contained in:
@@ -24,9 +24,6 @@ public class WatcherSanitizer {
|
||||
public static void checkPreLoaded() throws NoSuchFieldException, IllegalAccessException {
|
||||
JavaPluginLoader javaLoader = (JavaPluginLoader) LibsDisguises.getInstance().getPluginLoader();
|
||||
|
||||
Field cM = JavaPluginLoader.class.getDeclaredField("classes");
|
||||
cM.setAccessible(true);
|
||||
Map<String, Class<?>> classes = (Map<String, Class<?>>) cM.get(javaLoader);
|
||||
Field lM = JavaPluginLoader.class.getDeclaredField("loaders");
|
||||
lM.setAccessible(true);
|
||||
List loaders = (List) lM.get(javaLoader);
|
||||
@@ -38,15 +35,9 @@ public class WatcherSanitizer {
|
||||
|
||||
for (Object loader : loaders) {
|
||||
Map<String, Class<?>> lClasses = (Map<String, Class<?>>) lF.get(loader);
|
||||
PluginDescriptionFile desc = (PluginDescriptionFile) dF.get(loader);
|
||||
|
||||
for (Class c : lClasses.values()) {
|
||||
if (!c.getName().startsWith("me.libraryaddict.disguise.disguisetypes.watchers.") &&
|
||||
!c.getName().equals("me.libraryaddict.disguise.disguisetypes.FlagWatcher")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginDescriptionFile desc = (PluginDescriptionFile) dF.get(loader);
|
||||
|
||||
if (hasWatcher(lClasses)) {
|
||||
LibsDisguises.getInstance().getLogger().severe(desc.getFullName() +
|
||||
" has been a naughty plugin, they're declaring access to the disguise watchers before Lib's " +
|
||||
"Disguises can properly load them! They should add 'LibsDisguises' to the 'depend' section of" +
|
||||
@@ -54,6 +45,29 @@ public class WatcherSanitizer {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Field cM = JavaPluginLoader.class.getDeclaredField("classes");
|
||||
cM.setAccessible(true);
|
||||
Map<String, Class<?>> classes = (Map<String, Class<?>>) cM.get(javaLoader);
|
||||
|
||||
if (hasWatcher(classes)) {
|
||||
LibsDisguises.getInstance().getLogger()
|
||||
.severe("Somehow the main server has a Watcher instance! Hopefully there was a plugin mentioned " +
|
||||
"above! This is a bug!");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasWatcher(Map<String, Class<?>> classes) {
|
||||
for (Class c : classes.values()) {
|
||||
if (!c.getName().startsWith("me.libraryaddict.disguise.disguisetypes.watchers.") &&
|
||||
!c.getName().equals("me.libraryaddict.disguise.disguisetypes.FlagWatcher")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
|
Reference in New Issue
Block a user