From 4b81c9d19f66418fa8877527a466751962d85ba7 Mon Sep 17 00:00:00 2001
From: tsb1995 <47466105+tsb1995@users.noreply.github.com>
Date: Sun, 3 May 2020 12:21:09 -0700
Subject: [PATCH] Add base script
---
.gitignore.txt | 3 +
.idea/.gitignore | 8 ++
.idea/artifacts/CowKiller2.xml | 8 ++
.idea/libraries/OSBot_2_5_80.xml | 9 +++
.idea/misc.xml | 6 ++
.idea/modules.xml | 8 ++
CowKiller2.iml | 12 +++
.../CowKiller2/CowKiller2Main$1.class | Bin 0 -> 662 bytes
.../CowKiller2/CowKiller2Main.class | Bin 0 -> 2421 bytes
out/production/CowKiller2/data/State.class | Bin 0 -> 932 bytes
.../CowKiller2/tasks/BankCowhides.class | Bin 0 -> 1874 bytes
.../CowKiller2/tasks/KillCows$1.class | Bin 0 -> 1095 bytes
.../CowKiller2/tasks/KillCows.class | Bin 0 -> 3125 bytes
out/production/CowKiller2/tasks/NavCows.class | Bin 0 -> 1241 bytes
out/production/CowKiller2/util/Sleep.class | Bin 0 -> 793 bytes
src/CowKiller2Main.java | 72 ++++++++++++++++++
src/data/State.java | 5 ++
src/tasks/BankCowhides.java | 29 +++++++
src/tasks/KillCows.java | 35 +++++++++
src/tasks/NavCows.java | 20 +++++
src/util/Sleep.java | 24 ++++++
21 files changed, 239 insertions(+)
create mode 100644 .gitignore.txt
create mode 100644 .idea/.gitignore
create mode 100644 .idea/artifacts/CowKiller2.xml
create mode 100644 .idea/libraries/OSBot_2_5_80.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 CowKiller2.iml
create mode 100644 out/production/CowKiller2/CowKiller2Main$1.class
create mode 100644 out/production/CowKiller2/CowKiller2Main.class
create mode 100644 out/production/CowKiller2/data/State.class
create mode 100644 out/production/CowKiller2/tasks/BankCowhides.class
create mode 100644 out/production/CowKiller2/tasks/KillCows$1.class
create mode 100644 out/production/CowKiller2/tasks/KillCows.class
create mode 100644 out/production/CowKiller2/tasks/NavCows.class
create mode 100644 out/production/CowKiller2/util/Sleep.class
create mode 100644 src/CowKiller2Main.java
create mode 100644 src/data/State.java
create mode 100644 src/tasks/BankCowhides.java
create mode 100644 src/tasks/KillCows.java
create mode 100644 src/tasks/NavCows.java
create mode 100644 src/util/Sleep.java
diff --git a/.gitignore.txt b/.gitignore.txt
new file mode 100644
index 0000000..aad7015
--- /dev/null
+++ b/.gitignore.txt
@@ -0,0 +1,3 @@
+/.idea/
+/out/
+.CowKiller2.iml
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..73f69e0
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/artifacts/CowKiller2.xml b/.idea/artifacts/CowKiller2.xml
new file mode 100644
index 0000000..fca03bd
--- /dev/null
+++ b/.idea/artifacts/CowKiller2.xml
@@ -0,0 +1,8 @@
+
+
+ $USER_HOME$/OSBot/Scripts
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/OSBot_2_5_80.xml b/.idea/libraries/OSBot_2_5_80.xml
new file mode 100644
index 0000000..6bcc02f
--- /dev/null
+++ b/.idea/libraries/OSBot_2_5_80.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..0548357
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..99e6808
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CowKiller2.iml b/CowKiller2.iml
new file mode 100644
index 0000000..f3a85af
--- /dev/null
+++ b/CowKiller2.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/CowKiller2/CowKiller2Main$1.class b/out/production/CowKiller2/CowKiller2Main$1.class
new file mode 100644
index 0000000000000000000000000000000000000000..75aa56d880f00eaf294cf9f1c63fce476b7354b7
GIT binary patch
literal 662
zcmY*X+iuf95IvhXacrE%y+J6qLJdg(5mAA703nr-iYQL$5JIRQz(*lwt%xX+XJ^jLoHO>U|NQ-R3E&wX+qj0hg$k})6zynu!^BMuZt3H;
zi906lGHiRnh0Ma~fPeBLo^db8cqSMM$32G1t5C^UX0I8F&DNN~=p+#pYrc%daQ<;3
z()WC#D6`=wAy;FbN{tuEDrtouNIAzep1}^1c^ZmCsY#oi|swfg2@*w^v9-rH{A?$X^^beGJn>yOqE
zWgJw=uMzr;B1OQ9pJ122?e8dj(@*gS3}f^KMn8vTf~6%i36^vCmFO0>=uar2jy+mw
z2@UMyIr$=LBwWtrn{X*EkgexdJ~FX^!T*DrH}i%qY?C)|mCjuQtWN3yaGjV3pi#No(
z;sq}+`V(9{Aj<}quH_H#%|GF@&n}nCZzpNe3(KsPbM`rBpZ)Fq?Y+B`{g@O2b)END;(+cw>y
ztl@d4ry=C|hF_r2mb_^!7_qEj&&4Kv*RtpOH8c!enz!jQ8_OD##?@aDbPczHw2%v;%P`LMNeI9l1^shTzHd7fsh
zw0N|wqA|E;ms+6#%eMTp8tQs_r!@qJoU|!emTis~aDK
zgMP-M>DDA+1le>?j2V_KZaem*Z@4}I9D8KRDho-+$(N848tR218dk});TzsXyb;I<0#u>DY91+4b1X5)b{EXw0p($^caW0syN3)@Gf3Y3-<1Nd+
z;b&!U{$8kd85PCFp{!bl=-m*e3`bhA)DpEL%Bc!3cxmrC6kK-tFUfx|>F$ysp
zQ+OS3D7=Zc6wc!UlcexAZYjKj+Y0ZZU*SFR>wOtMkl{mor0_95(ebIm9ek$nInF42
zfiD&A;wy!(W%&)x(3Kh^QcD_kZ3t`~qb$Dl`qASgwN_CY_SE_>Vf&`*7V^HCu9g&O
z?n&?`H4|c83_7f<4pzkmRPHltE#^`x!&Wwj9NJo<>Ojw`JhTO~RiUB9=1=IE&cUi-}&0))HRMnur8l{S>^HU-$0xYD%`XHS4?}$qq4l)|
zR#4aXD}q-dYB{3*h^RXe_2)y>uOP&2{mMf$te}x%nBtZdD2h!Kn^(~CBh3W(c>{J5
z1Zd_*rIp{F2=-$uUD<|HXvb4LQDsP+7`(^Yq_(So?s-S-n=ifAn&GDBIFaGGkQw2I)0w#FPh!6uDSaVUUUObI{dM1S3;~e08
ziG*!S_8l&wot!;D2c^f3{=gHIXck*_{CDzyfd5{JsEF+nOc6UIjv{tO@OMPJ`!hQ4
zmDGj2JtlXl?ip0BjQZ
literal 0
HcmV?d00001
diff --git a/out/production/CowKiller2/data/State.class b/out/production/CowKiller2/data/State.class
new file mode 100644
index 0000000000000000000000000000000000000000..c3cd1d20ed89e69e8eb3446d0a90b5a8dfc4130b
GIT binary patch
literal 932
zcmZuv?{5-85Pi!X+;KgA^u#K))>^9tT8k)tf;2^JBk2V`pcrC|S?Gz^97h62|1PD8
zH5yGn`$rjPw?shQOLlhly_tD4w?BV<{Q;neViYR24P=njkkXJd5XX+#c6B5S0(S-D
zp^jx?_jFjo<~2NG(Cd}fyK3Wglfkr4c);_`fCo;AA$nZ1?I{#{R;eG0^NZT^L!xS1
zt&06hoMLYlqatVA8#^P0L?-(eq*ezf4gt37JN0qD;|yQ&jz>3|jA^`Q*vQzY{EX*4
z?)ON@(Di$z>|z1S9(1|a;zL&iPcx`K?^7b{-)M$N+4bFEpJC-c$!pmbgBpBrNpZC4
z_Iw_Uhm=Xl2tY4)y=n0JTXctZNZuNjn)`zAB~-x=E%0yAjd{hw8g5IRMnf!7u>gfWK+El{T_EyF
z!t>>3;TkrCbljDkP3X8M1&cIqsS&X%-=MZFO}T)6j;M4DRXR)3F~ib{MZObHnb6Z{
ks}n3W+u;df&2umz;HqDP6pHz5lfKZj=oaqNT?h|;1Ie|q4*&oF
literal 0
HcmV?d00001
diff --git a/out/production/CowKiller2/tasks/BankCowhides.class b/out/production/CowKiller2/tasks/BankCowhides.class
new file mode 100644
index 0000000000000000000000000000000000000000..1eda2afc43c5a6f19177f914511355e0072b6ac4
GIT binary patch
literal 1874
zcma)7ZBrXn6n<_J*syGxCPJYttsu09fZbZFXrU;ffu<%QlE50O)=hE=E6eWA?uO8x
zV*h}j^+Ry%*dNfp)EUQf6TnVhY?dW5bF{iNk}scuNao$uQCJ^^Scb8b-TtHqFKY@`NmO&yCuD1(oQ^US9Nn&cMY*V
z+YI>!hQ~0L^>y#iQ&YNixNbKOj2icr8I-rz4B;lPq>s7fGt6dfx31b=#r9R#ySt=v
zv9D^pqUq*g8$|bmj^i-g?~f&8O~R@L-9IR}e4o4As`7$s?;9qk%aNk5R}XW#a~7(c
zKB;oYH*Cw3u)!b~?S@ZH61&4RL-~&_|V*kDeE7&k&`iPD{)Wf}exvN|@aGx?z#Oxx_p1
z^Ly0Wb?#>@(Y3bwoMF1Zn+pW_nCg@9#W~HP;cYZbvpt7oebT`_>b#KM{>U|=n7WY|*v0*V+$r0OSEvByZ4Kr7xrJQ1TS)cTxhlNpiTo8ODdC
zD;)r)$p{d`M|3&RzWj!8LE1Y>#se(`|3E0&!cYstFR)3P)I#`IJba0fa_Dc!WdSIj
zVl=zZf}*`dq#mlbVP(
z*p7D-~oF=!Zvjw>)Q0h?%P5*;GXX|ko_
p7G^O=8LwcH^xKpv<#(3*$D~ULzJWF&Awi1}0q5yINqPVa{{mD->r(
literal 0
HcmV?d00001
diff --git a/out/production/CowKiller2/tasks/KillCows$1.class b/out/production/CowKiller2/tasks/KillCows$1.class
new file mode 100644
index 0000000000000000000000000000000000000000..c8a84dd36d83a7c2478a9814edbd11fbe914e878
GIT binary patch
literal 1095
zcmaJ=OHKMQc9ckQ5lIy!_Szx$u{Ia+ukg5dR
zj=)gW^_}&0tL}uGvhLB7uLidCwq)qW=dLpq3kevjzVCz;Pezf$WBwSiIZNHXmQ;3A
zV6spR!iE(@^*~u+G_zpIJ=bbc)w9+&DvQNe0!e?*78pMpD3GlwY45Jdy>2w4h3bxc
zD=km@4eLdH$FWt1E>m+GzEtgyX>6W^oF?S29FX6qz}_!fQ5KQw1%VBWs8}P6pB6dtf`PW
zGTt8H10ToEdDE62ha>AoFa2#NTv2iJI+W~qj+D8a+1!#et^bFqpEPWAveVGy}o
zTrU0;Nq$4f(R+^8G7@|Ny;S}RQTm3&7oHNxbL}SvL=JO3e}KXWt@zP9Y=Q`uughh3
zxyJw7Q&*Vt0^n%bLQ~4r(0NI{O4Bxu-CN>lme_6RmUS^B3dY
B>*fFe
literal 0
HcmV?d00001
diff --git a/out/production/CowKiller2/tasks/KillCows.class b/out/production/CowKiller2/tasks/KillCows.class
new file mode 100644
index 0000000000000000000000000000000000000000..4d91ddfa3e504f19bbb9bb72526e28ffdeddb197
GIT binary patch
literal 3125
zcmb7GSyLQU6#kk4dT5%k1`?nM2@@R_Gf6awN{k^$$Rq>73<*NqnxTOXP50Q{LxTHm
z-1j9h`eapJ^uf}?6qZ(=e6ajEzH0g1?tvMgq2g3c-`n?|SjN)+xwRoZq5}u0UX$7iyDZykJW%!f+7HS!xHYGN7A+F1qmN6qiOaK+HqlRU8$0S7JofjmO_S;jsgzA)G>BG7CN!=OMCQYu?rR1nx&1dx0S_X>Emo
zlNQtH)aghwQ+Cm@}Nk}+Md>a`F
zgS-w;bbfKf)D{Kz9pOjcCrmk56
z^aeVDAab5zCZ=;%Mzpg;UOt`6W=%tPh(YlM(x$FwML~%1JQHmCoyt$c))tbYXrhKF
za4kc28$+`(e(tI(Swf_138hOYtBHRHRm}NP
zKE{b$`WvF-kzY|UPA^J&36-~@rnpnZoo(Zhx@xY~+(zvX*Xou~e+~6r%V?mt`m49F
zee5REJ%1q9lNWEKc+)jBboDG_N0HFJZVGkhg?3V?SqOD6qoqiwq5-Y9&?aJy_^}>F
z73YPaBK>)ulA3tv-UrKqZfW%6SCBZ#g2hk>e7b@PuvYWcOxHnm2JGf|LB<3Ql;I
z^G-%MimGZ}jif5i>}Gy;6qQ5IwiMcFVd2iz47hDW8^tECPyBV`2!JO-kFOgr@O_*|wLmvg~elw}qen
z^>Iv;CK7!BAHjz)&ZUjSQjj#gotZmxX6DS?{`~#z2Y@wXRSaQD!L*79W(F{b*%;7OncY#
zEunXfa=32=!aFpBgFw%ltxfkRAXKF*GQ^H}b*sglkYT#F94_p7nODoEeQ@SPp_1o$
z3~T*;3G9e`^`aT>7k$3ReeTqF(RcSOn^Um5bzI|~Xf05%OnS*}`ZfNBZi$_4QA;1p
zmZ@PFw;3k>!;o-$qTv=241@XCyGH(PYNwDQo=X~5uu3HNAY5!pV616)if0TfeZ8-2
zOT#*zYj}YThWI~3GtBhB1vTIDLVcTu`)-|RX<2pdGbBaFx@|fQ-Eczg`%N$8^}k%v
z7NiZs5c8L8x4|%y&Yee;Lf>*4S#dj?e%Cvf3o9l3;?01UtV7S{Vo)M(zBle7O*Fo-
zfQNlY%TP)8N4S!@?Df(r{Fv98A+5;9C0RPlc?nwQ5|i{2hv*?Q+7{Xuk|HG2meF~K
zv@JwQ0!A}!u*@kUm4x;&q5YEDkiJ6xd=@Z5r+EHA3^E3Amn5wdhEa@>mcTecM$RBV
z5u`-6)y(jX6GTs;ROIgjEM>kxF0~QMEu3JWd`d4B6u4^K?o28xcvO
zh!gZ6lGMcO2yikN%6aqnzXhH8bn=y`Tcf#(h=sS5M
zs6_=Iz=smgOrnA}_GWg@`Mx>dnKS$2=hyE5_OTlxz@;X9thKO?%K33lyd{4j-{@QfanX<
zx_d7K!iR5DIkiU109(YRZGM*X3a9sHb%wesQu#<(PobN5(}oct#CC);Xa?Aca1E<0
z|8-@{tq9jGy{n5!tjm!$aZ%p7<6>0iU3~aE;3RXp0vj&oEXgNvKR2={s;QCVKR01o
zT^HKc|DS^)O{6&}=dUDCcLCrwA2{GIz<{lJ?rPlAEZ2zW2|O}DtG9jv(Yx^p-UmVt
z3tSgnDMFnnBw8f5IcvufmWg=K$qKhy;SdiiWLEjL^7|ZPYhmvryf3H;yeFEeH(aId
zRHIqfT=gt_d@|=~xP$ZDS*-(d9={9U;6LxJouK|1jeq4jPOdX+oZpy7XsS&afeUW@
F#b1~8qMQH#
literal 0
HcmV?d00001
diff --git a/src/CowKiller2Main.java b/src/CowKiller2Main.java
new file mode 100644
index 0000000..85ae6ce
--- /dev/null
+++ b/src/CowKiller2Main.java
@@ -0,0 +1,72 @@
+import data.State;
+import org.osbot.rs07.api.map.Area;
+import org.osbot.rs07.script.Script;
+
+import org.osbot.rs07.script.ScriptManifest;
+import tasks.BankCowhides;
+import tasks.KillCows;
+import tasks.NavCows;
+
+import java.awt.*;
+
+@ScriptManifest(name = "CowKiller2", author = "Tsb", version = 1.0, info = "", logo = "")
+public final class CowKiller2Main extends Script {
+
+ private String status = "";
+ private final Area COW_AREA = new Area(3193, 3281, 3211, 3302);
+
+ // Initialize task classes
+ private final NavCows navCows = new NavCows();
+ private final KillCows killCows = new KillCows();
+ private final BankCowhides bankCowhides = new BankCowhides();
+
+ @Override
+ public void onStart() {
+ // Exchange context to allow OSBot methods in task classes
+ navCows.exchangeContext(getBot());
+ killCows.exchangeContext(getBot());
+ bankCowhides.exchangeContext(getBot());
+
+ }
+
+ @Override
+ public void onExit() {
+ //Code here will execute after the script ends
+ }
+
+ @Override
+ public int onLoop() throws InterruptedException {
+ // Grab current state and convert to string
+ final State state = getState();
+ status = state.toString();
+
+ // Choose task based on state
+ switch (state) {
+ case NAV_COWS:
+ navCows.NavCows();
+ case KILL_COWS:
+ killCows.KillCows();
+ case BANK_COWHIDES:
+ bankCowhides.BankCowhides();
+ }
+ // end current loop and wait between 250 and 400 miliseconds before next loop
+ return random(250, 400);
+ }
+
+ @Override
+ public void onPaint(Graphics2D g) {
+ //This is where you will put your code for paint(s)
+ }
+
+ private State getState() {
+
+ // Return proper state based on inventory and position
+ if (getInventory().isFull()) {
+ return State.BANK_COWHIDES;
+ } else if (!COW_AREA.contains(myPosition())) {
+ return State.NAV_COWS;
+ } else {
+ return State.KILL_COWS;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/data/State.java b/src/data/State.java
new file mode 100644
index 0000000..d7b5353
--- /dev/null
+++ b/src/data/State.java
@@ -0,0 +1,5 @@
+package data;
+
+public enum State {
+ NAV_COWS, KILL_COWS, BANK_COWHIDES
+}
diff --git a/src/tasks/BankCowhides.java b/src/tasks/BankCowhides.java
new file mode 100644
index 0000000..4d9600a
--- /dev/null
+++ b/src/tasks/BankCowhides.java
@@ -0,0 +1,29 @@
+package tasks;
+
+import org.osbot.rs07.api.map.constants.Banks;
+import org.osbot.rs07.event.WebWalkEvent;
+import org.osbot.rs07.event.webwalk.PathPreferenceProfile;
+import org.osbot.rs07.script.MethodProvider;
+
+public class BankCowhides extends MethodProvider {
+
+ public final void BankCowhides() throws InterruptedException {
+ // If not at bank and full inventory, got to the bank
+ if (!Banks.LUMBRIDGE_UPPER.contains(myPosition()) && getInventory().isFull()) {
+ WebWalkEvent webEvent = new WebWalkEvent(Banks.LUMBRIDGE_UPPER);
+ webEvent.useSimplePath();
+ PathPreferenceProfile ppp = new PathPreferenceProfile();
+ ppp.setAllowTeleports(false);
+ webEvent.setPathPreferenceProfile(ppp);
+ execute(webEvent);
+ sleep(300);
+ } else {
+ // if at bank, open bank and deposit all
+ if (!getBank().isOpen()) {
+ getBank().open();
+ sleep(300);
+ }
+ getBank().depositAll();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/tasks/KillCows.java b/src/tasks/KillCows.java
new file mode 100644
index 0000000..649f24a
--- /dev/null
+++ b/src/tasks/KillCows.java
@@ -0,0 +1,35 @@
+package tasks;
+
+import org.osbot.rs07.api.filter.Filter;
+import org.osbot.rs07.api.model.GroundItem;
+import org.osbot.rs07.api.model.NPC;
+import org.osbot.rs07.script.MethodProvider;
+import util.Sleep;
+
+public class KillCows extends MethodProvider {
+ public final void KillCows() throws InterruptedException {
+ // Toggle run only if above 40 energy
+ if (getSettings().getRunEnergy() >40) {
+ getSettings().setRunning(true);
+ }
+
+ // Grab cows not in combat and not in dying state
+ NPC cow = getNpcs().closest(new Filter() {
+ public boolean match(NPC npc) {
+ return npc != null && npc.getName().equals("Cow") && !npc.isUnderAttack() && npc.getHealthPercent() > 0;
+ }
+ });
+
+ // Check for cowhides and grab with proper conditional sleep
+ GroundItem cowhide = getGroundItems().closest("Cowhide");
+ if (myPlayer().isUnderAttack()) {
+ Sleep.sleepUntil(() -> myPlayer().isAnimating() || !myPlayer().isUnderAttack(), 5000);
+ }else if (cowhide != null && cowhide.interact("take")) {
+ Sleep.sleepUntil(() -> myPlayer().isAnimating() || !cowhide.exists(), 5000);
+ } else if (cow != null && cow.interact("Attack")) {
+ Sleep.sleepUntil(() -> myPlayer().isAnimating() || !cow.exists(), 5000);
+ } else {
+ sleep(500);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/tasks/NavCows.java b/src/tasks/NavCows.java
new file mode 100644
index 0000000..6e62eb8
--- /dev/null
+++ b/src/tasks/NavCows.java
@@ -0,0 +1,20 @@
+package tasks;
+
+import org.osbot.rs07.api.map.Position;
+import org.osbot.rs07.event.WebWalkEvent;
+import org.osbot.rs07.event.webwalk.PathPreferenceProfile;
+import org.osbot.rs07.script.MethodProvider;
+
+public class NavCows extends MethodProvider {
+ // Nav to cow position
+
+ final Position COW_POSITION = new Position(3200, 3290, 0);
+
+ public final void NavCows() throws InterruptedException {
+ WebWalkEvent webEvent = new WebWalkEvent(COW_POSITION);
+ webEvent.useSimplePath();
+ PathPreferenceProfile ppp = new PathPreferenceProfile();
+ webEvent.setPathPreferenceProfile(ppp);
+ execute(webEvent);
+ }
+}
diff --git a/src/util/Sleep.java b/src/util/Sleep.java
new file mode 100644
index 0000000..291d521
--- /dev/null
+++ b/src/util/Sleep.java
@@ -0,0 +1,24 @@
+package util;
+
+import org.osbot.rs07.utility.ConditionalSleep;
+
+import java.util.function.BooleanSupplier;
+
+public final class Sleep extends ConditionalSleep {
+
+ private final BooleanSupplier condition;
+
+ public Sleep(final BooleanSupplier condition, final int timeout) {
+ super(timeout);
+ this.condition = condition;
+ }
+
+ @Override
+ public final boolean condition() throws InterruptedException {
+ return condition.getAsBoolean();
+ }
+
+ public static boolean sleepUntil(final BooleanSupplier condition, final int timeout) {
+ return new Sleep(condition, timeout).sleep();
+ }
+}
\ No newline at end of file