forked from Brookpc/USMiner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUSPMiner.java
More file actions
113 lines (87 loc) · 3.41 KB
/
USPMiner.java
File metadata and controls
113 lines (87 loc) · 3.41 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.io.IOException;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import org.parabot.environment.api.interfaces.Paintable;
import org.parabot.environment.scripts.Category;
import org.parabot.environment.scripts.Script;
import org.parabot.environment.scripts.ScriptManifest;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.methods.Skill;
@ScriptManifest(author = "Ark",
category = Category.MINING,
description = "Ultimate Scape 2 - Power Miner",
name = "USPMiner by Ark",
servers = { "Ultimate Scape" },
version = 2.0)
public class USPMiner extends Script implements Paintable {
private final ArrayList<Strategy> strategies = new ArrayList<Strategy>();
public long startTime;
private final Color color1 = new Color(100,255,0);
private final Font font2 = new Font( "Arial", 0, 14 );
public static int startExp;
public static int expGained;
public static Image img1;
/********************************************************************************************************************************************/
public boolean onExecute() {
img1 = getImage( "http://i.imgur.com/0vKVzVq.png" );
startTime = System.currentTimeMillis();
startExp = Skill.MINING.getExperience();
strategies.add(new Relog());
strategies.add(new Tele());
strategies.add(new Mine());
strategies.add(new Bank());
provide(strategies);
return true;
}
/***************************************************************************************************************************************/
public static Image getImage( String url )
{
try {
return ImageIO.read( new URL( url ) );
} catch( IOException e ) {
return null;
}
}
/***************************************************************************************************************************************/
/********************************************************************************************************************************************/
@Override
public void paint(Graphics arg0) {
final int expGained = Skill.MINING.getExperience() - startExp;
Graphics2D g = (Graphics2D) arg0;
g.drawImage(img1, 4, 23, null);
g.setFont(font2);
g.setColor(color1);
g.drawString(addDecimals(expGained), 91, 62);
g.drawString(runTime(startTime), 91,75);
}
public String addDecimals(int i)
{
DecimalFormat x = new DecimalFormat("#,###");
return "" + x.format(i);
}
/********************************************************************************************************************************************/
public static boolean isLoggedIn() {
return SceneObjects.getNearest().length > 0;
}
/********************************************************************************************************************************************/
public static String runTime(long i) {
DecimalFormat nf = new DecimalFormat("00");
long millis = System.currentTimeMillis() - i;
long hours = millis / (1000 * 60 * 60);
millis -= hours * (1000 * 60 * 60);
long minutes = millis / (1000 * 60);
millis -= minutes * (1000 * 60);
long seconds = millis / 1000;
return nf.format(hours) + ":" + nf.format(minutes) + ":"
+ nf.format(seconds);
}
}