public void init() { sessions = new ArrayList(); commands = new ArrayList(); load(); connection = new DatabaseConnection( config.getProperty( "sqlhost" ), config.getProperty( "sqldb" ), config.getProperty( "sqluser" ), config.getProperty( "sqlpass") ); channel = config.getProperty( "channel" ); String[] cmds = config.getProperty( "commands" ).split( ", " ); for ( String s : cmds ) { try { Class clazz = Class.forName( s ); if ( clazz.getSuperclass().equals( Command.class ) ) { Constructor constructor = clazz.getConstructor( DatabaseConnection.class, Bot.class ); Object obj = constructor.newInstance( connection, this ); commands.add( ( Command ) obj ); System.out.println( "[i] Command module \"" + s + "\" loaded." ); } else System.err.println( "[w] Supplied class \"" + s + "\" is not a child of Command. Ignored."); } catch ( Exception e ) { System.err.println("[e] Unable to load module: " + e.getMessage() ); } } String[] gmcmds = config.getProperty( "gmcommands" ).split( ", " ); for ( String s : gmcmds ) { try { Class clazz = Class.forName( s ); if ( clazz.getSuperclass().equals( GMCommand.class ) ) { Constructor constructor = clazz.getConstructor( DatabaseConnection.class, Bot.class ); Object obj = constructor.newInstance( connection, this ); gmcommands.add( ( GMCommand ) obj ); System.out.println( "[i] GM Command module \"" + s + "\" loaded." ); } else System.err.println( "[w] Supplied class \"" + s + "\" is not a child of GMCommand. Ignored." ); } catch ( Exception e ) { System.err.println( "[e] Unable to load gm module: " + e.getMessage() ); } } }