All pastes #614218 Raw Edit

Something

public java v1 · immutable
·published 2007-07-11 12:54 UTC
rendered paste body
    public void init() {        sessions = new ArrayList<GMSession>();        commands = new ArrayList<Command>();        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() );            }        }    }