Skip to content
This repository was archived by the owner on Feb 9, 2022. It is now read-only.

Commit 61f1362

Browse files
ExplvExplv
authored andcommitted
Add maven support
Add auto updater Automatically download latest OSBot version when running bots
1 parent 705dd48 commit 61f1362

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+487
-25
lines changed

pom.xml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.explv.explv_osbot_manager</groupId>
8+
<artifactId>explv_osbot_manager</artifactId>
9+
<version>8.3</version>
10+
<repositories>
11+
<repository>
12+
<id>local-repo</id>
13+
<url>file://${project.basedir}/local-repo</url>
14+
</repository>
15+
</repositories>
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.apache.httpcomponents</groupId>
19+
<artifactId>httpclient</artifactId>
20+
<version>4.5.6</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>com.googlecode.json-simple</groupId>
24+
<artifactId>json-simple</artifactId>
25+
<version>1.1.1</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.jsoup</groupId>
29+
<artifactId>jsoup</artifactId>
30+
<version>1.11.3</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.osbot</groupId>
34+
<artifactId>osbot</artifactId>
35+
<version>0</version>
36+
</dependency>
37+
</dependencies>
38+
<build>
39+
<plugins>
40+
<plugin>
41+
<groupId>com.googlecode.maven-download-plugin</groupId>
42+
<artifactId>download-maven-plugin</artifactId>
43+
<version>1.4.1</version>
44+
<executions>
45+
<execution>
46+
<id>download-osbot</id>
47+
<phase>initialize</phase>
48+
<goals>
49+
<goal>wget</goal>
50+
</goals>
51+
<configuration>
52+
<url>https://osbot.org/mvc/get</url>
53+
<unpack>false</unpack>
54+
<outputDirectory>${build.directory}/osbot/</outputDirectory>
55+
<outputFileName>osbot.jar</outputFileName>
56+
<overwrite>true</overwrite>
57+
<skipCache>true</skipCache>
58+
</configuration>
59+
</execution>
60+
</executions>
61+
</plugin>
62+
<plugin>
63+
<groupId>org.apache.maven.plugins</groupId>
64+
<artifactId>maven-install-plugin</artifactId>
65+
<version>2.5.2</version>
66+
<executions>
67+
<execution>
68+
<phase>initialize</phase>
69+
<goals>
70+
<goal>install-file</goal>
71+
</goals>
72+
<configuration>
73+
<file>${build.directory}/osbot/osbot.jar</file>
74+
<groupId>org.osbot</groupId>
75+
<artifactId>osbot</artifactId>
76+
<version>0</version>
77+
<packaging>jar</packaging>
78+
</configuration>
79+
</execution>
80+
</executions>
81+
</plugin>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-compiler-plugin</artifactId>
85+
<version>3.8.0</version>
86+
<configuration>
87+
<source>1.8</source>
88+
<target>1.8</target>
89+
</configuration>
90+
</plugin>
91+
<plugin>
92+
<artifactId>maven-assembly-plugin</artifactId>
93+
<configuration>
94+
<archive>
95+
<manifest>
96+
<mainClass>main.ExplvOSBotManager</mainClass>
97+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
98+
</manifest>
99+
</archive>
100+
<descriptorRefs>
101+
<descriptorRef>jar-with-dependencies</descriptorRef>
102+
</descriptorRefs>
103+
<appendAssemblyId>false</appendAssemblyId>
104+
</configuration>
105+
<executions>
106+
<execution>
107+
<id>make-assembly</id> <!-- this is used for inheritance merges -->
108+
<phase>package</phase> <!-- bind to the packaging phase -->
109+
<goals>
110+
<goal>single</goal>
111+
</goals>
112+
</execution>
113+
</executions>
114+
</plugin>
115+
</plugins>
116+
</build>
117+
</project>

osbot_manager/src/bot_parameters/account/Account.java renamed to src/main/java/bot_parameters/account/Account.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public abstract class Account implements Serializable {
1313

1414
protected SimpleStringProperty username, password;
1515

16+
public Account() {}
17+
1618
public Account(final String username, final String password) {
1719
this.username = new SimpleStringProperty(username);
1820
this.password = new SimpleStringProperty(password);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package bot_parameters.account;
2+
3+
import bot_parameters.interfaces.BotParameter;
4+
5+
public final class OSBotAccount extends Account implements BotParameter {
6+
7+
private static final long serialVersionUID = 3206668253057580659L;
8+
9+
private static final OSBotAccount instance = new OSBotAccount();
10+
11+
private OSBotAccount(){}
12+
13+
public static OSBotAccount getInstance() {
14+
return instance;
15+
}
16+
17+
@Override
18+
public final String[] toParameter() {
19+
return new String[]{ "-login", String.format("\"%s:%s\"", getUsername(), getPassword()) };
20+
}
21+
}
File renamed without changes.

osbot_manager/src/bot_parameters/configuration/Configuration.java renamed to src/main/java/bot_parameters/configuration/Configuration.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
import bot_parameters.account.OSBotAccount;
44
import bot_parameters.account.RunescapeAccount;
5-
import bot_parameters.bot.Bot;
65
import bot_parameters.interfaces.BotParameter;
76
import bot_parameters.interfaces.Copyable;
87
import bot_parameters.proxy.Proxy;
98
import bot_parameters.script.Script;
109
import exceptions.ClientOutOfDateException;
1110
import exceptions.IncorrectLoginException;
1211
import exceptions.MissingWebWalkDataException;
12+
import osbot_client.OSBotClient;
1313
import gui.dialogues.error_dialog.ExceptionDialog;
1414
import javafx.application.Platform;
1515
import javafx.beans.property.SimpleBooleanProperty;
@@ -19,12 +19,12 @@
1919
import javafx.beans.value.ChangeListener;
2020
import javafx.collections.FXCollections;
2121
import javafx.collections.ObservableList;
22+
import settings.Settings;
2223

2324
import java.io.*;
2425
import java.net.ServerSocket;
2526
import java.nio.file.Paths;
2627
import java.util.*;
27-
import java.util.stream.Collectors;
2828

2929
public final class Configuration implements BotParameter, Copyable<Configuration>, Serializable {
3030

@@ -53,7 +53,7 @@ public Configuration(final RunescapeAccount runescapeAccount, final ObservableLi
5353
this.runescapeAccount = new SimpleObjectProperty<>(runescapeAccount);
5454
this.scripts = new SimpleListProperty<>(scripts);
5555
this.proxy = new SimpleObjectProperty<>();
56-
logFileName = Paths.get(System.getProperty("user.home"), "ExplvOSBotManager", "Logs", UUID.randomUUID().toString()).toString();
56+
logFileName = Paths.get(Settings.LOGS_DIR, UUID.randomUUID().toString()).toString();
5757
}
5858

5959
public RunescapeAccount getRunescapeAccount() {
@@ -344,7 +344,7 @@ public Configuration createCopy() {
344344
return configurationCopy;
345345
}
346346

347-
public void run(final Bot bot, final OSBotAccount osBotAccount) throws IOException {
347+
public void run() throws IOException {
348348

349349
File logFile = new File(logFileName);
350350

@@ -360,7 +360,7 @@ public void run(final Bot bot, final OSBotAccount osBotAccount) throws IOExcepti
360360

361361
try (BufferedWriter br = new BufferedWriter(new FileWriter(logFile))) {
362362

363-
for (final List<String> command : getCommands(bot, osBotAccount)) {
363+
for (final List<String> command : getCommands()) {
364364

365365
final ProcessBuilder processBuilder = new ProcessBuilder(command);
366366
processBuilder.redirectErrorStream(true);
@@ -425,15 +425,15 @@ public void run(final Bot bot, final OSBotAccount osBotAccount) throws IOExcepti
425425
runThread.start();
426426
}
427427

428-
public List<List<String>> getCommands(final Bot bot, final OSBotAccount osBotAccount) {
428+
public List<List<String>> getCommands() {
429429

430430
List<List<String>> commands = new ArrayList<>();
431431

432432
for (final Script script : scripts.get()) {
433433
List<String> command = new ArrayList<>();
434434

435-
Collections.addAll(command, bot.toParameter());
436-
Collections.addAll(command, osBotAccount.toParameter());
435+
Collections.addAll(command, "java", "-jar", OSBotClient.getLatestLocalVersion().get());
436+
Collections.addAll(command, OSBotAccount.getInstance().toParameter());
437437
Collections.addAll(command, this.toParameter());
438438
Collections.addAll(command, script.toParameter());
439439

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)