--- miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/HoerupUtilsPlugin.java 2012/03/19 09:52:18 1754 +++ miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/HoerupUtilsPlugin.java 2012/03/21 17:04:29 1760 @@ -1,14 +1,14 @@ package dk.thoerup.bukkit.hoeruputils; +import java.lang.reflect.Method; + +import org.bukkit.configuration.Configuration; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; -import de.codeinfection.quickwango.ApiBukkit.ApiBukkit; -import de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiManager; import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands; import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener; -import dk.thoerup.bukkit.hoeruputils.web.StatusListener; public class HoerupUtilsPlugin extends JavaPlugin { @@ -74,14 +74,25 @@ //pm.registerEvent(Event.Type.CUSTOM_EVENT, new StatusListener(getServer(), logintimeHandler.getConfig(), home.getConfig() ), Priority.Normal, this); //pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this); - /*ApiBukkit api = (ApiBukkit) pm.getPlugin("ApiBukkit") ; - if ( api != null) { - StatusListener status = new StatusListener(this, getServer(), logintimeHandler.getConfig(), home.getConfig() ); - //api.setRequestController("webstatus", status ); - ApiManager.getInstance().registerController( status ); - } else { - System.out.println("Could not find ApiBukkit"); - }*/ + try { + try { + //først probes om klassen i det hele taget findes + Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); + + Classwebloader = Class.forName("dk.thoerup.bukkit.hoeruputils.web.WebLoader"); + Method load = webloader.getMethod("load", HoerupUtilsPlugin.class, Configuration.class, Configuration.class); + Object args[] = {this, logintimeHandler.getConfig(), home.getConfig() }; + load.invoke(null, args); + + getLogger().warning("ApiBukkit found, status listener registered"); + + } catch (ClassNotFoundException e) { + getLogger().warning("Could not find ApiBukkit - web status is disabled" ); + } + + } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException + getLogger().warning("Could not find ApiBukkit - web status is disabled (" + e.getClass().getName() + ":" + e.getMessage() + ")" ); + }