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

Commit e449dd6

Browse files
ExplvExplv
andauthored
Bug fixes, Custom method provider, Custom executable improvements, etc. (#83)
- Loads of bug fixes - Massive improvement to agility activity - Allow activities to define their own paints - Introduce custom method provider - Introduce blocking executable v3.3.0 Co-authored-by: Explv <[email protected]>
1 parent df171b5 commit e449dd6

File tree

79 files changed

+1292
-970
lines changed

Some content is hidden

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

79 files changed

+1292
-970
lines changed

explvs_aio.iml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
4+
<output url="file://$MODULE_DIR$/target/classes" />
5+
<output-test url="file://$MODULE_DIR$/target/test-classes" />
6+
<content url="file://$MODULE_DIR$">
7+
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8+
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
9+
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" />
10+
<excludeFolder url="file://$MODULE_DIR$/target" />
11+
</content>
12+
<orderEntry type="inheritedJdk" />
13+
<orderEntry type="sourceFolder" forTests="false" />
14+
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
15+
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
16+
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
17+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.osbot:osbot:0" level="project" />
18+
</component>
19+
</module>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>org.explv.explv_osbot_manager</groupId>
7+
<groupId>org.explv</groupId>
88
<artifactId>explvs_aio</artifactId>
99

1010
<!--

src/main/java/activities/activity/Activity.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package activities.activity;
22

33

4+
import org.osbot.rs07.canvas.paint.Painter;
45
import util.Copyable;
5-
import util.Executable;
6+
import util.executable.Executable;
67

7-
public abstract class Activity extends Executable implements Copyable<Activity> {
8+
import java.awt.*;
9+
10+
public abstract class Activity extends Executable implements Copyable<Activity>, Painter {
811

912
private final ActivityType activityType;
1013
public boolean isComplete = false;
@@ -40,4 +43,7 @@ public void run() throws InterruptedException {
4043
public String toString() {
4144
return activityType != null ? String.format("%s : %s", activityType.toString(), status) : "";
4245
}
46+
47+
@Override
48+
public void onPaint(Graphics2D graphics) {}
4349
}

src/main/java/activities/banking/Bank.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import java.util.Arrays;
88

9-
// TODO: Check these areas
109
public enum Bank {
1110

1211
LUMBRIDGE_CASTLE(new Location("Lumbridge Castle", new Area(3207, 3220, 3209, 3216).setPlane(2))),

src/main/java/activities/banking/Banking.java

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
package activities.banking;
22

33
import org.osbot.rs07.api.map.Area;
4-
import util.Executable;
54
import util.Sleep;
6-
import util.widget.CachedWidget;
7-
import util.widget.filters.WidgetActionFilter;
5+
import util.executable.BlockingExecutable;
86

97
import java.util.stream.Stream;
108

11-
public abstract class Banking extends Executable {
9+
public abstract class Banking extends BlockingExecutable {
1210

1311
private static final Area[] ALL_BANK_AND_DEPOSIT_BOX_AREAS = Stream.concat(Stream.of(Bank.AREAS), Stream.of(DepositBox.AREAS)).toArray(Area[]::new);
1412

15-
private static final CachedWidget CONTINUE_BANK_INSTRUCTIONS_WIDGET = new CachedWidget(new WidgetActionFilter("Continue"));
16-
1713
private final boolean useDepositBoxes;
1814

1915
protected enum BankType {
@@ -22,7 +18,7 @@ protected enum BankType {
2218
}
2319

2420
private BankType currentBankType;
25-
public boolean succeeded;
21+
private boolean finishedBanking;
2622

2723
public Banking() {
2824
this.useDepositBoxes = false;
@@ -32,10 +28,29 @@ public Banking(final boolean useDepositBoxes) {
3228
this.useDepositBoxes = useDepositBoxes;
3329
}
3430

31+
/**
32+
* Override BlockingExecutable::setFinished
33+
* to prevent finishing immediately upon a super class
34+
* setFinished() call. We need to ensure that the bank is closed
35+
* before we end the executable.
36+
*/
37+
@Override
38+
public void setFinished() {
39+
finishedBanking = true;
40+
}
41+
3542
@Override
36-
public void run() throws InterruptedException {
37-
if (!playerInBank()) {
43+
public void blockingRun() throws InterruptedException {
44+
if (finishedBanking) {
45+
if (isBankOpen()) {
46+
closeBank();
47+
} else {
48+
super.setFinished();
49+
}
50+
} else if (!playerInBank()) {
3851
walkToBank();
52+
} else if (getInventory().contains("Coin pouch")) {
53+
getInventory().getItem("Coin pouch").interact();
3954
} else if (!isBankOpen()) {
4055
openBank();
4156
} else {
@@ -45,11 +60,7 @@ public void run() throws InterruptedException {
4560
currentBankType = BankType.DEPOSIT_BOX;
4661
}
4762

48-
if (CONTINUE_BANK_INSTRUCTIONS_WIDGET.isVisible(getWidgets())) {
49-
CONTINUE_BANK_INSTRUCTIONS_WIDGET.interact(getWidgets(), "Continue");
50-
} else {
51-
succeeded = bank(currentBankType);
52-
}
63+
bank(currentBankType);
5364
}
5465
}
5566

@@ -100,10 +111,8 @@ private void openBank() throws InterruptedException {
100111

101112
/**
102113
* Execute banking operation
103-
*
104-
* @return whether the operation was a success or not
105114
*/
106-
protected abstract boolean bank(final BankType currentBankType);
115+
protected abstract void bank(final BankType currentBankType) throws InterruptedException;
107116

108117
@Override
109118
public void onEnd() {

src/main/java/activities/banking/DepositAllBanking.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,23 @@ public void setExceptItems(final String... exceptItems) {
2626
}
2727

2828
@Override
29-
protected boolean bank(final BankType currentBankType) {
29+
protected void bank(final BankType currentBankType) {
30+
boolean success;
31+
3032
if (exceptItems == null) {
3133
if (currentBankType == BankType.DEPOSIT_BOX) {
32-
return getDepositBox().depositAll();
34+
success = getDepositBox().depositAll();
3335
} else {
34-
return getBank().depositAll();
36+
success = getBank().depositAll();
3537
}
38+
} else if (currentBankType == BankType.DEPOSIT_BOX) {
39+
success = getDepositBox().depositAllExcept(exceptItems);
40+
} else {
41+
success = getBank().depositAllExcept(exceptItems);
3642
}
3743

38-
if (currentBankType == BankType.DEPOSIT_BOX) {
39-
return getDepositBox().depositAllExcept(exceptItems);
40-
} else {
41-
return getBank().depositAllExcept(exceptItems);
44+
if (success) {
45+
setFinished();
4246
}
4347
}
4448
}

0 commit comments

Comments
 (0)