User:TLULbot/Source/Main.java

/* * tLULbot - Java bot for editing the RuneScape Wiki * Copyright (c) 2009-2010 The last username left and others. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see &lt;http://www.gnu.org/licenses/&gt;. * * This program was based on AmauriceBot, created by Maurice Abraham. * * Contributors: * Maurice Abraham * The last username left *--*/

package tLULbot_v3;

import java.io.IOException; import java.util.List;

import jBot.*; import jBot.Core.*;

/** * Main class of TLULbot. Sets up the bot. * @author The last username left */ public abstract class Main {   public static void main(String[] args) throws IOException, jBotException {       Core.addTask(new CharmLogCreator); //Add tasks Core.addTask(new CharmChecker); Core.addTask(new SetStatus.Online); Core.addTask(new SetStatus.Vacation); Core.addTask(new SetStatus.Offline); Core.addTask(new SourceMgr); Core.addTask(new SourceMgrJBot); Core.addTask(new SourceMgrBETA); Printer p = new Printer{ //Define basic printer public void errString(String str) {               System.err.println(str); }           public void outString(String str) {               System.out.println(str); }           public void setProg(int prog) //Unimplemented {           }            public void setProgString(String str) //Unimplemented {           }        };        WikiSession w = new WikiSession(p); //Define WikiSession List&lt;Core.Task&gt; tasks = Core.getTasks; for (Core.Task t : tasks) t.setWikiSession(w); //Set the WikiSession for each task if (args.length == 0) {           new GUI(w); return; }       String username = "", password = ""; for (String arg : args) {           if (arg.compareTo("-gui") == 0) new GUI(w); else if (arg.substring(0, 3).compareTo("-u=") == 0) username = arg.substring(3); else if (arg.substring(0, 3).compareTo("-p=") == 0) password = arg.substring(3); else if (arg.compareTo("-login") == 0) w.login(username, password); else try {               Core.getTaskRunnable(arg).run; }           catch(jBotException e) { } //Not a command name }   } }