-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLancerbot.java
More file actions
281 lines (180 loc) · 5.88 KB
/
Lancerbot.java
File metadata and controls
281 lines (180 loc) · 5.88 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
package botpackage;
import java.*;
import java.awt.AWTException;
import java.awt.EventQueue;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Lancerbot extends Thread {
private static Randomsleep randomsleep = new Randomsleep();
public static boolean actif = true;
static WebDriver driver;
static Attaque attaque = new Attaque();
static ArrayList<Attaque> listeAttaques = new ArrayList<Attaque>();
Travian travian;
Fenetre tfenetre;
Lancerbot bot;
public void lancerbot(Lancerbot bot) {
this.bot = bot;
tfenetre = new Fenetre(bot);
}
public static void main(String[] args) throws AWTException, IOException {
Lancerbot botStart = new Lancerbot();
botStart.lancerbot(botStart);
}
public static void arreter(){
actif = false;
}
public WebDriver setDriver(WebDriver driver) {
driver = this.driver;
return driver;
}
public void lancerTravian(){
travian = new Travian(bot);
travian.allume = true;
System.out.println(travian.getName());
System.out.println(travian.getState());
if (!travian.isAlive()){
travian.start();
System.out.println(travian.getName());
System.out.println(travian.getState());
}/*else {travian= new Travian();
travian.start();
System.out.println(travian.getName());
System.out.println(travian.getState());
}*/
}
public void reprendreTravian(){
System.out.println(travian.getName());
System.out.println(travian.getState());
travian.resume();
System.out.println(travian.getName());
System.out.println(travian.getState());
}
public void eteindreTravian(){
if (travian.isAlive()){
// travian.stop();
travian.allume = false;
System.out.println("********* Arret Demande ************ Arret Demande ************** Arret Demande *************");
//travian.notify();
//travian.stop();
//try {travian.getCompte().getDriver().close();}catch (Exception e) {}
// try {travian.getCompte().getDriver().quit();}catch (Exception e) {}
//System.out.println(travian.getName());
//System.out.println(travian.getState());
/* // Attente de la fin du thread
try {
travian.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//travian.getThreadGroup().destroy();*/
}
}
public void attaque(){
try {Thread.sleep(20000);} catch (InterruptedException e) {e.printStackTrace();}
travian.suspend();
Verifierdate verifDate = new Verifierdate(travian, attaque, listeAttaques);
verifDate.start();
System.out.println(verifDate.getName());
System.out.println(verifDate.getState());
// randomsleep.court();
try {
Attaque attaque1 = new Attaque(travian,verifDate);
attaque1.start();
listeAttaques.add(attaque1);
//try {Thread.sleep(20000);} catch (InterruptedException e) {e.printStackTrace();}
randomsleep.court();
Attaque attaque2 = new Attaque(travian,verifDate);
attaque2.start();
listeAttaques.add(attaque2);
// try {Thread.sleep(20000);} catch (InterruptedException e) {e.printStackTrace();}
randomsleep.court();
Attaque attaque3 = new Attaque(travian,verifDate);
attaque3.start();
listeAttaques.add(attaque3);
// try {Thread.sleep(20000);} catch (InterruptedException e) {e.printStackTrace();}
randomsleep.court();
Attaque attaque4 = new Attaque(travian,verifDate);
attaque4.start();
listeAttaques.add(attaque4);
// try {Thread.sleep(20000);} catch (InterruptedException e) {e.printStackTrace();}
Attaque attaque5 = new Attaque(travian,verifDate);
attaque5.start();
listeAttaques.add(attaque5);
//try {Thread.sleep(20000);} catch (InterruptedException e) {e.printStackTrace();}
randomsleep.court();
Attaque attaque6 = new Attaque(travian,verifDate);
attaque6.start();
listeAttaques.add(attaque6);
// try {Thread.sleep(20000);} catch (InterruptedException e) {e.printStackTrace();}
randomsleep.court();
Attaque attaque7 = new Attaque(travian,verifDate);
attaque7.start();
listeAttaques.add(attaque7);
// try {Thread.sleep(20000);} catch (InterruptedException e) {e.printStackTrace();}
randomsleep.court();
Attaque attaque8 = new Attaque(travian,verifDate);
attaque8.start();
listeAttaques.add(attaque8);
// try {Thread.sleep(20000);} catch (InterruptedException e) {e.printStackTrace();}
}catch (Exception e){}
// randomsleep.court();
// for(Attaque attaque : listeAttaques){
// attaque.bouttons.get(0).submit();
// }
}
public static void copyFullRecursive(File source, File dest) throws IOException
{
if (source.isDirectory())
{
File dir = new File(dest, source.getName());
dir.mkdir();
File[] list = source.listFiles();
if (list != null)
for (File fic : list)
copyFullRecursive(fic, dir);
}
else
{
Files.copy(source.toPath(), new File(dest, source.getName()).toPath());
}
}
/** copie le fichier source dans le fichier resultat
* retourne vrai si cela réussit
*/
public static boolean copyFile(File source, File dest){
try{
// Declaration et ouverture des flux
java.io.FileInputStream sourceFile = new java.io.FileInputStream(source);
try{
java.io.FileOutputStream destinationFile = null;
try{
destinationFile = new FileOutputStream(dest);
// Lecture par segment de 0.5Mo
byte buffer[] = new byte[512 * 1024];
int nbLecture;
while ((nbLecture = sourceFile.read(buffer)) != -1){
destinationFile.write(buffer, 0, nbLecture);
}
} finally {
destinationFile.close();
}
} finally {
sourceFile.close();
}
} catch (IOException e){
e.printStackTrace();
return false; // Erreur
}
return true; // Résultat OK
}
}