@UnsafeMethod public synchronized void enablePlugin(Plugin plugin) { if (!CommonPlugin.class.isAssignableFrom(plugin.getClass())) { throw new IllegalArgumentException( "Cannot enable plugin with this PluginLoader as it is of the wrong type!"); } if (!plugin.isEnabled()) { CommonPlugin cp = (CommonPlugin) plugin; String name = cp.getDescription().getName(); if (!loaders.containsKey(name)) { loaders.put(name, (CommonClassLoader) cp.getClassLoader()); } try { cp.setEnabled(true); cp.onEnable(); } catch (Throwable e) { engine .getLogger() .log( Level.SEVERE, "An error occured when enabling '" + plugin.getDescription().getFullName() + "': " + e.getMessage(), e); } engine.getEventManager().callEvent(new PluginEnableEvent(cp)); } }