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

Commit 3a30c18

Browse files
ExplvExplv
authored andcommitted
- Replace deprecated Entity::isOnScreen references.
- Implement custom settings handler as OSBot deprecated theirs. - Fix tool banking when members items in bank but player is in F2P world. v3.4.0
1 parent e449dd6 commit 3a30c18

File tree

14 files changed

+221
-30
lines changed

14 files changed

+221
-30
lines changed

resources-archive.zip

0 Bytes
Binary file not shown.

src/main/java/activities/banking/ToolUpgradeBanking.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public T getCurrentTool() {
3030
public void onStart() throws InterruptedException {
3131
super.onStart();
3232
currentTool = Stream.of(toolClass.getEnumConstants())
33+
.filter(tool -> !tool.isMembersOnly() || getWorlds().isMembersWorld())
3334
.filter(tool -> tool.canUse(getSkills()))
3435
.filter(tool -> getInventory().contains(tool.getName()) ||
3536
getEquipment().isWearingItem(EquipmentSlot.WEAPON, tool.getName()))
@@ -49,6 +50,10 @@ public boolean toolUpgradeAvailable() {
4950
protected void bank(final BankType currentBankType) {
5051
if (toolsInBank.isEmpty()) {
5152
for (T tool : toolClass.getEnumConstants()) {
53+
if (!getWorlds().isMembersWorld() && tool.isMembersOnly()) {
54+
log(String.format("Skipping tool '%s' as not in members world", tool.getName()));
55+
continue;
56+
}
5257
if (getBank().contains(tool.getName())) {
5358
log(String.format("Found tool '%s' in the bank", tool.getName()));
5459
toolsInBank.add(tool);
@@ -98,6 +103,8 @@ private boolean bankContainsBetterTool() {
98103
private Optional<T> getBestUsableTool() {
99104
return toolsInBank.stream()
100105
.filter(tool -> tool.canUse(getSkills()))
101-
.max(Comparator.comparingInt(Tool::getLevelRequired));
106+
// NOTE: Do not replace this with a method reference Tool::getLevelRequired
107+
// There is a bug in the Java compiler which causes the code to crash.
108+
.max(Comparator.comparingInt(tool -> tool.getLevelRequired()));
102109
}
103110
}

src/main/java/activities/quests/DialogueCompleter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ private String[] buildDialogueOptions(final String[] dialogueOptions) {
4040
public void run() throws InterruptedException {
4141
NPC npc = getNpcs().closest(npcName);
4242

43-
if (npc == null || !npc.isOnScreen()) {
43+
if (npc == null || !npc.isVisible()) {
4444
if (area != null && !area.contains(myPosition())) {
4545
WebWalkEvent webWalkEvent = new WebWalkEvent(area);
4646
webWalkEvent.setBreakCondition(new Condition() {
4747
@Override
4848
public boolean evaluate() {
4949
NPC npc = getNpcs().closest(npcName);
50-
return npc != null && npc.isOnScreen() && getMap().canReach(npc);
50+
return npc != null && npc.isVisible() && getMap().canReach(npc);
5151
}
5252
});
5353
execute(webWalkEvent);

src/main/java/activities/skills/fishing/FishingActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void runActivity() throws InterruptedException {
6464
private void fish() {
6565
currentFishingSpot = getFishingSpot();
6666
if (currentFishingSpot != null) {
67-
if (!currentFishingSpot.isOnScreen()) {
67+
if (!currentFishingSpot.isVisible()) {
6868
getWalking().walk(currentFishingSpot);
6969
}
7070
if (currentFishingSpot.interact(fish.fishingMethod.action)) {

src/main/java/activities/skills/mining/Pickaxe.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,25 @@ public enum Pickaxe implements Tool {
1717
MITHRIL("Mithril pickaxe", 21, 20),
1818
ADAMANT("Adamant pickaxe", 31, 30),
1919
RUNE("Rune pickaxe", 41, 40),
20-
DRAGON("Dragon pickaxe", 61, 60),
21-
INFERNAL("Infernal pickaxe", 61, 60);
20+
DRAGON("Dragon pickaxe", 61, 60, true),
21+
INFERNAL("Infernal pickaxe", 61, 60, true);
2222

2323
String name;
2424
int miningLevelRequired;
2525
int attackLevelRequired;
26+
boolean membersOnly;
2627

2728
Pickaxe(final String name, final int miningLevelRequired, final int attackLevelRequired) {
2829
this.name = name;
2930
this.miningLevelRequired = miningLevelRequired;
3031
this.attackLevelRequired = attackLevelRequired;
3132
}
3233

34+
Pickaxe(final String name, final int miningLevelRequired, final int attackLevelRequired, final boolean membersOnly) {
35+
this(name, miningLevelRequired, attackLevelRequired);
36+
this.membersOnly = membersOnly;
37+
}
38+
3339
public static List<String> getNames() {
3440
return Arrays.stream(values()).map(Pickaxe::toString).collect(Collectors.toList());
3541
}
@@ -39,6 +45,11 @@ public String getName() {
3945
return name;
4046
}
4147

48+
@Override
49+
public boolean isMembersOnly() {
50+
return membersOnly;
51+
}
52+
4253
@Override
4354
public int getLevelRequired() {
4455
return miningLevelRequired;

src/main/java/activities/skills/woodcutting/Axe.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,35 @@ public enum Axe implements Tool {
1414
MITHRIL("Mithril axe", 21, 20),
1515
ADAMANT("Adamant axe", 31, 30),
1616
RUNE("Rune axe", 41, 40),
17-
DRAGON("Dragon axe", 61, 60),
18-
INFERNAL("Infernal axe", 61, 60);
17+
DRAGON("Dragon axe", 61, 60, true),
18+
INFERNAL("Infernal axe", 61, 60, true);
1919

2020
String name;
2121
int wcLevelRequired;
2222
int attLevelRequired;
23+
boolean membersOnly;
2324

2425
Axe(final String name, final int wcLevelRequired, final int attLevelRequired) {
2526
this.name = name;
2627
this.wcLevelRequired = wcLevelRequired;
2728
this.attLevelRequired = attLevelRequired;
2829
}
2930

31+
Axe(final String name, final int wcLevelRequired, final int attLevelRequired, final boolean membersOnly) {
32+
this(name, wcLevelRequired, attLevelRequired);
33+
this.membersOnly = membersOnly;
34+
}
35+
3036
@Override
3137
public String getName() {
3238
return name;
3339
}
3440

41+
@Override
42+
public boolean isMembersOnly() {
43+
return membersOnly;
44+
}
45+
3546
@Override
3647
public int getLevelRequired() {
3748
return wcLevelRequired;

src/main/java/activities/tutorial_island/RuneScapeGuideSection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public final void run() throws InterruptedException {
8686
break;
8787
case 10:
8888
if (!isConfigured) {
89-
isConfigured = execute(new ConfigureClientEvent()).hasFinished();
89+
execute(new ConfigureClientEvent());
90+
isConfigured = true;
9091
} else if (getObjects().closest("Door").interact("Open")) {
9192
Sleep.sleepUntil(() -> getProgress() != 10, 5000, 600);
9293
}

src/main/java/activities/tutorial_island/TutorialIsland.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public TutorialIsland() {
2121

2222
@Override
2323
public void onStart() throws InterruptedException {
24-
Sleep.sleepUntil(() -> getClient().isLoggedIn() && myPlayer().isVisible() && myPlayer().isOnScreen(), 6000, 500);
24+
Sleep.sleepUntil(() -> getClient().isLoggedIn() && myPlayer().isVisible(), 6000, 500);
2525
}
2626

2727
@Override

src/main/java/script/AIO.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
@ScriptManifest(author = "Explv", name = "Explv's AIO " + AIO.VERSION, info = "AIO", version = 0, logo = "http://i.imgur.com/58Zz0fb.png")
2828
public class AIO extends Script {
2929

30-
public static final String VERSION = "v3.3.0";
30+
public static final String VERSION = "v3.4.0";
3131

3232
private Gui gui;
3333
private Paint paint;
@@ -141,7 +141,8 @@ public int onLoop() throws InterruptedException {
141141
if (!getClient().isLoggedIn()) {
142142
return random(1200, 1800);
143143
} else if (!osrsClientIsConfigured && osrsClientIsConfigurable()) {
144-
osrsClientIsConfigured = configureOSRSClient();
144+
configureOSRSClient();
145+
osrsClientIsConfigured = true;
145146
} else if (taskExecutor.isComplete()) {
146147
stop(true);
147148
} else {
@@ -159,8 +160,8 @@ private boolean osrsClientIsConfigurable() {
159160
getNpcs().closest("Lumbridge Guide") == null;
160161
}
161162

162-
private boolean configureOSRSClient() {
163-
return execute(new ConfigureClientEvent()).hasFinished();
163+
private void configureOSRSClient() throws InterruptedException {
164+
customMethodProvider.execute(new ConfigureClientEvent());
164165
}
165166

166167
@Override

src/main/java/util/Tool.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
public interface Tool {
66
String getName();
77

8+
boolean isMembersOnly();
9+
810
int getLevelRequired();
911

1012
boolean canUse(final Skills skills);

0 commit comments

Comments
 (0)