This repository was archived by the owner on Nov 28, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractScript.java
More file actions
148 lines (124 loc) · 5.04 KB
/
AbstractScript.java
File metadata and controls
148 lines (124 loc) · 5.04 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package scripts.tribotapi;
import com.allatori.annotations.DoNotRename;
import org.tribot.api.General;
import org.tribot.api.Timing;
import org.tribot.api.util.Screenshots;
import org.tribot.api2007.Walking;
import org.tribot.api2007.util.ThreadSettings;
import org.tribot.script.Script;
import org.tribot.script.interfaces.*;
import org.tribot.util.Util;
import scripts.generalapi.FileManagment;
import scripts.task_framework.framework.Task;
import scripts.task_framework.framework.TaskManager;
import scripts.tribotapi.gui.GUI;
import scripts.tribotapi.painting.mouse.MouseManager;
import scripts.tribotapi.painting.paint.PaintManager;
import scripts.tribotapi.painting.paint.SkillData;
import scripts.tribotapi.painting.paint.enums.DataPosition;
import scripts.tribotapi.painting.paint.paintables.InteractivePaint;
import scripts.tribotapi.painting.paint.paintables.SkillBackground;
import scripts.tribotapi.painting.paint.paintables.tabs.*;
import scripts.tribotapi.util.Logging;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.ArrayList;
/**
* Created by Sphiinx on 7/24/2016.
*/
@DoNotRename
public abstract class AbstractScript extends Script implements Painting, MousePainting, MouseSplinePainting, EventBlockingOverride, Ending {
/**
* The master object for the task manager.
* */
protected TaskManager task_manager = new TaskManager();
/**
* The master object for the paint manager.
* */
protected PaintManager paint_manager = new PaintManager(new InteractivePaint(Client.getManifest(this.getClass()).name(), Client.getManifest(this.getClass()).version()), new SkillBackground(), new GeneralTab(), new StatsTab(), new GUITab(), new ScreenshotTab(), new TogglePaintTab(), new StackTraceTab());
/**
* The master object for the mouse manager.
* */
protected MouseManager mouse_manager = new MouseManager();
/**
* The master object for the GUI.
* */
protected GUI gui = getGUI();
/**
* Gets the GUI object.
* */
protected abstract GUI getGUI();
/**
* Adds all of the given tasks to the task list.
*
* @param tasks The tasks to be added to the task list.
* */
public void addTasks(Task... tasks) {
task_manager.addTask(tasks);
}
@Override
public void run() {
ThreadSettings.get().setClickingAPIUseDynamic(true);
Walking.setWalkingTimeout(1000);
SkillData.initialiseAll();
if (FileManagment.createDirectory(Util.getWorkingDirectory().getAbsolutePath(), "SPXScripts"))
FileManagment.createDirectory(Util.getWorkingDirectory().getAbsolutePath() + File.separator + "SPXScripts", Client.getManifest(this.getClass()).name().replace(" ", "_"));
General.sleep(150); // The GUI didn't seem to instantiate quick enough.
if (this.gui != null) {
this.gui.show();
TaskManager.setStatus("Initializing");
while (this.gui.isOpen())
sleep(250);
}
addTasks();
task_manager.loop(150, 200);
}
@Override
public void onEnd() {
Logging.status("Thank you for using " + Client.getManifest(this.getClass()).name() + ", " + General.getTRiBotUsername() + "!");
if (this.gui != null)
this.gui.close();
}
@Override
public void onPaint(Graphics g) {
SkillData.updateAll();
paint_manager.drawInteractivePaint(g);
paint_manager.drawGeneralData("Runtime: ", Timing.msToString(this.getRunningTime()), DataPosition.ONE, g);
paint_manager.drawStatData(this, g);
}
@Override
public OVERRIDE_RETURN overrideKeyEvent(KeyEvent keyEvent) {
return OVERRIDE_RETURN.PROCESS;
}
@Override
public OVERRIDE_RETURN overrideMouseEvent(MouseEvent mouse_event) {
if (mouse_event.getID() == MouseEvent.MOUSE_PRESSED) {
if (paint_manager.togglePaint(mouse_event.getPoint())) {
return OVERRIDE_RETURN.DISMISS;
} else if (paint_manager.isInClick(StackTraceTab.class, mouse_event.getPoint())) {
Client.printStackTrace(this);
return OVERRIDE_RETURN.DISMISS;
} else if (paint_manager.toggleTab(mouse_event.getPoint())) {
return OVERRIDE_RETURN.DISMISS;
} else if (paint_manager.isInClick(ScreenshotTab.class, mouse_event.getPoint())) {
Logging.status("Screenshot saved to your .TRiBot folder.");
Screenshots.take(true);
return OVERRIDE_RETURN.DISMISS;
} else if (paint_manager.isInClick(GUITab.class, mouse_event.getPoint())) {
if (gui != null)
this.gui.show();
return OVERRIDE_RETURN.DISMISS;
}
}
return OVERRIDE_RETURN.PROCESS;
}
@Override
public void paintMouse(Graphics g, Point point, Point point1) {
mouse_manager.drawMouse(g);
}
@Override
public void paintMouseSpline(Graphics graphics, ArrayList<Point> arrayList) {
}
}