1010import org .osbot .rs07 .utility .Condition ;
1111import utils .Sleep ;
1212
13+ import java .util .Arrays ;
14+ import java .util .List ;
1315import java .util .Optional ;
1416
1517public final class MiningSection extends TutorialSection {
1618
1719 private static final Area SMITH_AREA = new Area (3076 , 9497 , 3082 , 9504 );
1820
21+ private static final List <Position > PATH_TO_SMITH_AREA = Arrays .asList (
22+ new Position (3080 , 9518 , 0 ),
23+ new Position (3080 , 9511 , 0 ),
24+ new Position (3080 , 9505 , 0 )
25+ );
26+
27+ private static final List <Position > PATH_TO_GATE = Arrays .asList (
28+ new Position (3086 , 9505 , 0 ),
29+ new Position (3091 , 9503 , 0 )
30+ );
31+
1932 public MiningSection () {
2033 super ("Mining Instructor" );
2134 }
@@ -26,11 +39,10 @@ public final void onLoop() throws InterruptedException {
2639 selectContinue ();
2740 return ;
2841 }
42+
2943 switch (getProgress ()) {
3044 case 260 :
31- if (!isInstructorVisible ()) {
32- walkToInstructor ();
33- } else {
45+ if (getWalking ().walkPath (PATH_TO_SMITH_AREA )) {
3446 talkToInstructor ();
3547 }
3648 break ;
@@ -63,32 +75,28 @@ public final void onLoop() throws InterruptedException {
6375 }
6476 break ;
6577 case 350 :
66- getDaggerWidget ().ifPresent (widget -> {
67- if (widget .interact ()) {
78+ Optional <RS2Widget > daggerWidgetOpt = getDaggerWidget ();
79+ if (daggerWidgetOpt .isPresent ()) {
80+ if (daggerWidgetOpt .get ().interact ()) {
6881 Sleep .sleepUntil (() -> getInventory ().contains ("Bronze dagger" ), 6000 );
6982 }
70- });
83+ } else {
84+ smith ();
85+ }
7186 break ;
7287 case 360 :
73- getWalking ().webWalk (new Position (3109 , 9510 , 0 ));
88+ if (getWalking ().walkPath (PATH_TO_GATE )) {
89+ if (getDoorHandler ().handleNextObstacle (new Position (3096 , 9503 , 0 ))) {
90+ Sleep .sleepUntil (() -> getProgress () != 360 , 5000 );
91+ }
92+ }
7493 break ;
7594 }
7695 }
7796
78- private void walkToInstructor () {
79- WebWalkEvent webWalkEvent = new WebWalkEvent (SMITH_AREA );
80- webWalkEvent .setBreakCondition (new Condition () {
81- @ Override
82- public boolean evaluate () {
83- return isInstructorVisible ();
84- }
85- });
86- execute (webWalkEvent );
87- }
88-
8997 private void smith () {
9098 if (!SMITH_AREA .contains (myPosition ())) {
91- getWalking ().walk (SMITH_AREA . getRandomPosition () );
99+ getWalking ().walk (SMITH_AREA );
92100 } else if (!"Bronze bar" .equals (getInventory ().getSelectedItemName ())) {
93101 getInventory ().getItem ("Bronze bar" ).interact ("Use" );
94102 } else if (getObjects ().closest ("Anvil" ).interact ("Use" )) {
@@ -97,7 +105,7 @@ private void smith() {
97105 }
98106
99107 private Optional <RS2Widget > getDaggerWidget () {
100- RS2Widget daggerTextWidget = getWidgets ().getWidgetContainingText ("Dagger" );
108+ RS2Widget daggerTextWidget = getWidgets ().getWidgetContainingText (312 , "Dagger" );
101109 if (daggerTextWidget != null ) {
102110 return Optional .ofNullable (getWidgets ().get (daggerTextWidget .getRootId (), daggerTextWidget .getSecondLevelId ()));
103111 }
0 commit comments