Skip to content

Commit

Permalink
Added more changes for multi-bot
Browse files Browse the repository at this point in the history
Not ready yet, but most stuff is in place
  • Loading branch information
GigiaJ committed Mar 17, 2022
1 parent baf32e4 commit 146aeed
Show file tree
Hide file tree
Showing 8 changed files with 338 additions and 58 deletions.
12 changes: 9 additions & 3 deletions src/main/java/rsb/botLauncher/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
public class Application {

static RuneLite[] bots = new RuneLite[]{};
static String[] programArgs = new String[]{};
final static OptionParser parser = new OptionParser();

/**
* Parses the command-line arguments and then passes the parsed arguments in the form of the parser, optionSpecs,
Expand All @@ -27,9 +29,9 @@ public class Application {
* @throws Throwable Any error that might be thrown
*/
public static void main(final String[] args) throws Throwable {
final OptionParser parser = new OptionParser();
ArgumentAcceptingOptionSpec<?>[] optionSpecs = RuneLite.handleParsing(parser);
OptionSet options = parser.parse(args);
programArgs = args;

checkForCacheAndLoad();

Expand Down Expand Up @@ -94,9 +96,13 @@ private static void checkForCacheAndLoad() throws IOException {

public static void setBot(int index) {
RuneLite bot = getBots()[index];
String[] args = new String[programArgs.length + 1];
System.arraycopy(programArgs, 0, args, 0, programArgs.length);
args[programArgs.length] = "--sub-bot";
ArgumentAcceptingOptionSpec<?>[] optionSpecs = RuneLite.handleParsing(parser);
OptionSet options = parser.parse(args);
try {
bot.init();
bot.bareStart();
bot.launch(parser, optionSpecs, options);
} catch (Throwable e) {
log.error("Error while starting bot", e);
}
Expand Down
Loading

0 comments on commit 146aeed

Please sign in to comment.