-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtility.java
More file actions
59 lines (46 loc) · 1.92 KB
/
Utility.java
File metadata and controls
59 lines (46 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package net.runelite.client.plugins.deecat;
import java.awt.*;
import java.util.concurrent.ThreadLocalRandom;
import static java.time.Instant.*;
import net.runelite.api.Point;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
public class Utility {
public static void sleep(long ms){
long now = now().toEpochMilli();
long elapsed = 0;
while (elapsed < ms){
if (elapsed >= ms) {break;}
else { elapsed = now().toEpochMilli() - now;};
}
}
public static Point randomPoint(Rectangle bounds){
int w = 1;//Math.toIntExact(Math.round(bounds.width * 0.4));
int h = 1;//Math.toIntExact(Math.round(bounds.height * 0.4));
int x = bounds.x + ThreadLocalRandom.current().nextInt(w, bounds.width - w);
int y = bounds.y + ThreadLocalRandom.current().nextInt(h, bounds.height - h);
Point p = new Point(x,y);
return p;
}
public static Point randomPoint(Rectangle bounds, float skew){
int w = 1 ;//Math.toIntExact(Math.round(bounds.width * 0.4));
int h = 1 ;//Math.toIntExact(Math.round(bounds.height * 0.4));
int midX = (bounds.width / 2);
int midY = (bounds.height / 2);
int randW = ThreadLocalRandom.current().nextInt(w, bounds.width - w);
int randH = ThreadLocalRandom.current().nextInt(h, bounds.height - h);
float skewW = (midX - randW) * skew / 100;
float skewH = (midY - randH) * skew / 100;
int x = (int) (bounds.x + midX - skewW);
int y = (int) (bounds.y + midY - skewH);
return new Point(x,y);
}
public static int rand(int start, int end){
return ThreadLocalRandom.current().nextInt(start,end);
}
public static int rand(long start, long end){
int s = Math.toIntExact(start);
int e = Math.toIntExact(end);
return ThreadLocalRandom.current().nextInt(s,e);
}
}