3v324v23 commited on
Commit
7f654c8
·
1 Parent(s): 8dcc407
Dockerfile CHANGED
@@ -12,4 +12,4 @@ FROM openjdk:11-jdk-slim
12
  COPY --from=build /target/demo-0.0.1-SNAPSHOT.jar demo.jar
13
  # ENV PORT=8080
14
  EXPOSE 8080
15
- ENTRYPOINT ["java","-jar","demo.jar"]
 
12
  COPY --from=build /target/demo-0.0.1-SNAPSHOT.jar demo.jar
13
  # ENV PORT=8080
14
  EXPOSE 8080
15
+ ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-jar","demo.jar"]
New Text Document (2).txt ADDED
File without changes
New Text Document.txt ADDED
File without changes
pom.xml CHANGED
@@ -17,6 +17,30 @@
17
  <java.version>11</java.version>
18
  </properties>
19
  <dependencies>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  <dependency>
21
  <groupId>org.springframework.boot</groupId>
22
  <artifactId>spring-boot-starter-web</artifactId>
 
17
  <java.version>11</java.version>
18
  </properties>
19
  <dependencies>
20
+ <dependency>
21
+ <groupId>org.apache.commons</groupId>
22
+ <artifactId>commons-lang3</artifactId>
23
+ <version>3.9</version>
24
+ </dependency>
25
+ <dependency>
26
+ <groupId>com.fasterxml.jackson.core</groupId>
27
+ <artifactId>jackson-annotations</artifactId>
28
+ <version>2.13.3</version>
29
+
30
+ </dependency>
31
+ <dependency>
32
+ <groupId>com.fasterxml.jackson.core</groupId>
33
+ <artifactId>jackson-core</artifactId>
34
+ <version>2.13.3</version>
35
+
36
+ </dependency>
37
+ <dependency>
38
+ <groupId>com.fasterxml.jackson.core</groupId>
39
+ <artifactId>jackson-databind</artifactId>
40
+ <version>2.12.7.1</version>
41
+
42
+ </dependency>
43
+
44
  <dependency>
45
  <groupId>org.springframework.boot</groupId>
46
  <artifactId>spring-boot-starter-web</artifactId>
src/main/java/com/example/demo/DemoApplication.java CHANGED
@@ -8,6 +8,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
8
  import org.springframework.web.bind.annotation.GetMapping;
9
  import org.springframework.web.bind.annotation.RestController;
10
 
 
 
 
 
11
  @SpringBootApplication
12
  @RestController
13
  public class DemoApplication {
@@ -21,5 +25,18 @@ public class DemoApplication {
21
  count++;
22
  return "Number of users = "+ count;
23
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  }
 
8
  import org.springframework.web.bind.annotation.GetMapping;
9
  import org.springframework.web.bind.annotation.RestController;
10
 
11
+ import tqtk.Entity.SessionEntity;
12
+ import tqtk.Tqtk;
13
+ import tqtk.XuLy.login.LayThongTinSession;
14
+
15
  @SpringBootApplication
16
  @RestController
17
  public class DemoApplication {
 
25
  count++;
26
  return "Number of users = "+ count;
27
  }
28
+
29
+ @GetMapping("start")
30
+ public String start(){
31
+ if (LayThongTinSession.getListSession().size() < 1) {
32
+ Thread t = new Thread() {
33
+ public void run() {
34
+ tqtk.Tqtk.main();
35
+ }
36
+ };
37
+ t.start();
38
+ }
39
+ return "ok";
40
+ }
41
 
42
  }
src/main/java/tqtk/Entity/Barrack.java ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package tqtk.Entity;
7
+
8
+ import java.util.List;
9
+
10
+ /**
11
+ *
12
+ * @author Alex
13
+ */
14
+ public class Barrack {
15
+ public List<Hero> General;
16
+
17
+ public List<Hero> getGeneral() {
18
+ return General;
19
+ }
20
+
21
+ public void setGeneral(List<Hero> General) {
22
+ this.General = General;
23
+ }
24
+
25
+
26
+ }
src/main/java/tqtk/Entity/Hero.java ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package tqtk.Entity;
7
+
8
+ /**
9
+ *
10
+ * @author Alex
11
+ */
12
+ public class Hero {
13
+ public String Generalid;
14
+ public String Generalname;
15
+
16
+ public String getGeneralid() {
17
+ return Generalid;
18
+ }
19
+
20
+ public void setGeneralid(String Generalid) {
21
+ this.Generalid = Generalid;
22
+ }
23
+
24
+
25
+
26
+
27
+
28
+ public String getGeneralname() {
29
+ return Generalname;
30
+ }
31
+
32
+ public void setGeneralname(String Generalname) {
33
+ this.Generalname = Generalname;
34
+ }
35
+
36
+
37
+ }
src/main/java/tqtk/Entity/JsonObject.java ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package tqtk.Entity;
7
+
8
+ /**
9
+ *
10
+ * @author Alex
11
+ */
12
+ public class JsonObject {
13
+
14
+ public Object u;
15
+ public Object r;
16
+ public Barrack m;
17
+
18
+ public Barrack getM() {
19
+ return m;
20
+ }
21
+
22
+ public void setM(Barrack m) {
23
+ this.m = m;
24
+ }
25
+
26
+ public Object getU() {
27
+ return u;
28
+ }
29
+
30
+ public void setU(Object u) {
31
+ this.u = u;
32
+ }
33
+
34
+ public Object getR() {
35
+ return r;
36
+ }
37
+
38
+ public void setR(Object r) {
39
+ this.r = r;
40
+ }
41
+
42
+ }
src/main/java/tqtk/Entity/SessionEntity.java ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package tqtk.Entity;
7
+
8
+ import java.io.IOException;
9
+ import java.net.InetAddress;
10
+ import java.net.InetSocketAddress;
11
+ import java.net.Socket;
12
+
13
+ /**
14
+ *
15
+ * @author Alex
16
+ */
17
+ public class SessionEntity {
18
+
19
+ private String userId;
20
+ private String pass;
21
+ private String ip;
22
+ private int ports;
23
+ private String sessionKey;
24
+ private Socket socket;
25
+ private boolean isConnected;
26
+ private String stringName;
27
+
28
+ public String getStringName() {
29
+ return stringName;
30
+ }
31
+
32
+ public void setStringName(String stringName) {
33
+ this.stringName = stringName;
34
+ }
35
+
36
+
37
+ public SessionEntity(String stringName, String pass) {
38
+ this.stringName = stringName;
39
+ this.pass = pass;
40
+ }
41
+
42
+ public SessionEntity() {
43
+ }
44
+
45
+ public void resetSocket() throws IOException {
46
+ this.socket.close();
47
+ this.socket = new Socket();
48
+ this.socket.connect(new InetSocketAddress(InetAddress.getByName(ip), ports), 7000);
49
+ }
50
+
51
+ public String getPass() {
52
+ return pass;
53
+ }
54
+
55
+ public void setPass(String pass) {
56
+ this.pass = pass;
57
+ }
58
+
59
+ public boolean isIsConnected() {
60
+ return isConnected;
61
+ }
62
+
63
+ public void setIsConnected(boolean isConnected) {
64
+ this.isConnected = isConnected;
65
+ }
66
+
67
+ public Socket getSocket() {
68
+ return socket;
69
+ }
70
+
71
+ public void setSocket(Socket socket) {
72
+ this.socket = socket;
73
+ }
74
+
75
+ private StringBuilder message = new StringBuilder();
76
+
77
+ public StringBuilder getMessage() {
78
+ return message;
79
+ }
80
+
81
+ public void setMessage(StringBuilder message) {
82
+ this.message = message;
83
+ }
84
+
85
+ public String getUserId() {
86
+ return userId;
87
+ }
88
+
89
+ public void setUserId(String userId) {
90
+ this.userId = userId;
91
+ }
92
+
93
+ public String getIp() {
94
+ return ip;
95
+ }
96
+
97
+ public void setIp(String ip) {
98
+ this.ip = ip;
99
+ }
100
+
101
+ public int getPorts() {
102
+ return ports;
103
+ }
104
+
105
+ public void setPorts(int ports) {
106
+ this.ports = ports;
107
+ }
108
+
109
+ public String getSessionKey() {
110
+ return sessionKey;
111
+ }
112
+
113
+ public void setSessionKey(String sessionKey) {
114
+ this.sessionKey = sessionKey;
115
+ }
116
+
117
+ }
src/main/java/tqtk/Tqtk.java ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package tqtk;
7
+
8
+ import java.net.InetAddress;
9
+ import java.net.InetSocketAddress;
10
+ import java.net.Socket;
11
+ import java.util.ArrayList;
12
+ import java.util.Collections;
13
+ import java.util.List;
14
+ import java.util.Properties;
15
+ import java.util.concurrent.Executors;
16
+ import java.util.concurrent.ScheduledExecutorService;
17
+ import java.util.concurrent.TimeUnit;
18
+ import java.util.logging.Level;
19
+ import java.util.logging.Logger;
20
+ import tqtk.Entity.SessionEntity;
21
+ import tqtk.Utils.Util;
22
+ import tqtk.XuLy.Worker;
23
+ import tqtk.XuLy.login.LayThongTinSession;
24
+
25
+ /**
26
+ *
27
+ * @author Alex
28
+ */
29
+ public class Tqtk {
30
+
31
+ public static List<String> loaiTruyna = new ArrayList<>();
32
+ public static List<Object> listruong = new ArrayList<>();
33
+
34
+ static {
35
+ loaiTruyna = Collections.synchronizedList(loaiTruyna);
36
+ listruong = Collections.synchronizedList(listruong);
37
+ }
38
+
39
+ public static void main() {
40
+ // TODO code application logic here
41
+ try {
42
+ // Properties pr = Util.loadProperties("user.properties");
43
+ // String value = "";
44
+ // String[] temp = new String[2];
45
+ // for (int i = 0; (value = pr.getProperty("user" + "." + i)) != null; i++) {
46
+ // temp = value.split("\\|");
47
+ // LayThongTinSession.getListSession().add(new SessionEntity(temp[0], temp[1]));
48
+ // }
49
+
50
+ LayThongTinSession.getListSession().add(new SessionEntity("n", "p"));
51
+
52
+ List<SessionEntity> ss = LayThongTinSession.getListSession();
53
+
54
+ final ScheduledExecutorService executor = Executors.newScheduledThreadPool(ss.size());
55
+ for (int i = 0; i < ss.size(); ++i) {
56
+ Runnable worker = new Worker(ss.get(i));
57
+ executor.schedule(worker, 300L, TimeUnit.MILLISECONDS);
58
+ }
59
+ executor.shutdown();
60
+ while (!executor.isTerminated()) {
61
+ }
62
+ System.out.println("tqtk.Tqtk.main()");
63
+
64
+ } catch (Exception ex) {
65
+ System.out.println(ex.getMessage());
66
+ }
67
+ }
68
+
69
+ public static synchronized void sendMessage(final String ms) {
70
+ System.out.println(ms);
71
+ }
72
+
73
+ }
src/main/java/tqtk/Utils/Doc_file_kieu_txt.java ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package tqtk.Utils;
2
+
3
+ import java.io.BufferedReader;
4
+ import java.io.FileReader;
5
+ import java.io.IOException;
6
+ import java.util.ArrayList;
7
+ import java.util.List;
8
+
9
+ /**
10
+ *
11
+ * @author Alex
12
+ */
13
+ public class Doc_file_kieu_txt {
14
+
15
+ public static List<String> readFile(String path) {
16
+ BufferedReader br = null;
17
+ FileReader fr = null;
18
+ List<String> lists = new ArrayList<String>();
19
+ try {
20
+
21
+ fr = new FileReader(path);
22
+ br = new BufferedReader(fr);
23
+
24
+ String read = "";
25
+
26
+ br = new BufferedReader(new FileReader(path));
27
+
28
+ while ((read = br.readLine()) != null) {
29
+ lists.add(read);
30
+ }
31
+ return lists;
32
+
33
+ } catch (IOException e) {
34
+
35
+ e.printStackTrace();
36
+
37
+ } finally {
38
+
39
+ try {
40
+
41
+ if (br != null) {
42
+ br.close();
43
+ }
44
+
45
+ if (fr != null) {
46
+ fr.close();
47
+ }
48
+
49
+ } catch (IOException ex) {
50
+
51
+ ex.printStackTrace();
52
+
53
+ }
54
+
55
+ }
56
+ return null;
57
+ }
58
+
59
+ }
src/main/java/tqtk/Utils/Util.java ADDED
@@ -0,0 +1,461 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package tqtk.Utils;
7
+
8
+ import java.io.BufferedReader;
9
+ import java.io.DataOutputStream;
10
+ import java.io.FileInputStream;
11
+ import java.io.IOException;
12
+ import java.io.InputStream;
13
+ import java.io.InputStreamReader;
14
+ import java.io.UnsupportedEncodingException;
15
+ import java.net.CookieHandler;
16
+ import java.net.CookieManager;
17
+ import java.net.HttpCookie;
18
+ import java.net.HttpURLConnection;
19
+ import java.net.SocketTimeoutException;
20
+ import java.net.URL;
21
+ import java.nio.charset.StandardCharsets;
22
+ import java.security.MessageDigest;
23
+ import java.security.NoSuchAlgorithmException;
24
+ import java.text.SimpleDateFormat;
25
+ import java.util.Date;
26
+ import java.util.List;
27
+ import java.util.Properties;
28
+ import javax.net.ssl.HttpsURLConnection;
29
+ import org.apache.commons.lang3.StringUtils;
30
+ import tqtk.Entity.SessionEntity;
31
+
32
+ /**
33
+ *
34
+ * @author Alex
35
+ */
36
+ public class Util {
37
+
38
+ public CookieManager msCookieManager = null;
39
+
40
+ public Util() {
41
+ msCookieManager = new CookieManager();
42
+ }
43
+
44
+ public void setCookie(CookieManager msCookieManager) {
45
+ CookieHandler.setDefault(msCookieManager);
46
+ }
47
+
48
+ public String getPageSource(String url) throws Exception {
49
+ HttpURLConnection con = null;
50
+ try {
51
+ URL obj = new URL(url);
52
+
53
+ String pro = obj.getProtocol();
54
+ if (pro.equals("http")) {
55
+ con = (HttpURLConnection) obj.openConnection();
56
+ } else {
57
+ con = (HttpsURLConnection) obj.openConnection();
58
+ }
59
+ con.setConnectTimeout(7000);
60
+ con.setRequestMethod("GET");
61
+ // con.setRequestProperty("Host", "app.slg.vn");
62
+ con.setRequestProperty("Upgrade-Insecure-Requests", "1");
63
+ con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
64
+ con.setUseCaches(false);
65
+ con.setDoOutput(true);
66
+
67
+ int responseCode = con.getResponseCode();
68
+ if (200 <= responseCode && responseCode <= 399) {
69
+
70
+ BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
71
+ StringBuffer response = new StringBuffer();
72
+ String inputLine;
73
+ while ((inputLine = in.readLine()) != null) {
74
+ response.append(inputLine);
75
+ }
76
+ in.close();
77
+
78
+ return response.toString();
79
+
80
+ } else {
81
+ return "Hệ thống đang quá tải vui lòng";
82
+ }
83
+
84
+ } catch (Exception e) {
85
+ if (e instanceof SocketTimeoutException) {
86
+ throw new SocketTimeoutException("");
87
+ }
88
+ throw e;
89
+ }
90
+ }
91
+
92
+ public static String getToken(String htmlCode) {
93
+ String prefix = "name=\"_token\" value=\"";
94
+ int index = htmlCode.indexOf(prefix);
95
+ if (index == -1) {
96
+ // Could not find the prefix string.
97
+ return null;
98
+ }
99
+
100
+ index += prefix.length();
101
+
102
+ // Login token has a fixed length of 40.
103
+ int TokenLength = 40;
104
+ if (htmlCode.length() < index + TokenLength) {
105
+ // Given html code is not long enough.
106
+ return null;
107
+ }
108
+
109
+ String token = htmlCode.substring(index, index + TokenLength);
110
+ return token;
111
+ }
112
+
113
+ public static String getRefer(String htmlCode) throws UnsupportedEncodingException {
114
+ String prefix = "action=\"";
115
+ int prefixIndex = htmlCode.indexOf(prefix);
116
+ if (prefixIndex == -1) {
117
+ // Could not find the prefix string.
118
+ return null;
119
+ }
120
+ String suffix = "\" accept-charset";
121
+ int suffixIndex = htmlCode.indexOf(suffix);
122
+
123
+ int beginIndex = prefixIndex + prefix.length();
124
+ int endIndex = suffixIndex;
125
+ String address = htmlCode.substring(beginIndex, endIndex);
126
+ String result = java.net.URLDecoder.decode(address, StandardCharsets.UTF_8.toString());
127
+ return result.replace("&amp;", "&");
128
+ }
129
+
130
+ public String dangNhap(String url, String user, String pass, String token, String Refer) throws Exception {
131
+ HttpURLConnection con = null;
132
+ try {
133
+ URL obj = new URL(Refer);
134
+
135
+ String pro = obj.getProtocol();
136
+ if (pro.equals("http")) {
137
+ con = (HttpURLConnection) obj.openConnection();
138
+ } else {
139
+ con = (HttpsURLConnection) obj.openConnection();
140
+ }
141
+ con.setConnectTimeout(7000);
142
+ String urlParameters = "_token=" + token + "&callback=&email=" + user + "&password=" + pass;
143
+ byte[] postData = urlParameters.getBytes(StandardCharsets.UTF_8);
144
+ int postDataLength = postData.length;
145
+ con.setRequestMethod("POST");
146
+ con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
147
+ con.setRequestProperty("Host", "id.slg.vn");
148
+ con.setRequestProperty("Content-Length", Integer.toString(postDataLength));
149
+ con.setRequestProperty("Upgrade-Insecure-Requests", "1");
150
+ con.setRequestProperty("Referer", Refer);
151
+ con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
152
+ con.setUseCaches(false);
153
+ con.setDoOutput(true);
154
+
155
+ DataOutputStream wr = new DataOutputStream(con.getOutputStream());
156
+ wr.write(postData);
157
+ wr.flush();
158
+ wr.close();
159
+ int responseCode = con.getResponseCode();
160
+ if (200 <= responseCode && responseCode <= 399) {
161
+
162
+ BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
163
+ StringBuffer response = new StringBuffer();
164
+ String inputLine;
165
+ while ((inputLine = in.readLine()) != null) {
166
+ response.append(inputLine);
167
+ }
168
+ in.close();
169
+
170
+ return response.toString();
171
+
172
+ } else {
173
+ return "Hệ thống đang quá tải vui lòng";
174
+ }
175
+
176
+ } catch (Exception e) {
177
+ if (e instanceof SocketTimeoutException) {
178
+ throw new SocketTimeoutException("");
179
+ }
180
+ throw e;
181
+ }
182
+ }
183
+
184
+ public String getThongTinFrame(String url) throws Exception {
185
+ HttpURLConnection con = null;
186
+ try {
187
+ URL obj = new URL(url);
188
+
189
+ String pro = obj.getProtocol();
190
+ if (pro.equals("http")) {
191
+ con = (HttpURLConnection) obj.openConnection();
192
+ } else {
193
+ con = (HttpsURLConnection) obj.openConnection();
194
+ }
195
+ con.setConnectTimeout(7000);
196
+ con.setRequestMethod("GET");
197
+ con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
198
+ con.setRequestProperty("Host", "app.slg.vn");
199
+ // con.setRequestProperty("Upgrade-Insecure-Requests", "1");
200
+ con.setUseCaches(false);
201
+ con.setDoOutput(true);
202
+
203
+ int responseCode = con.getResponseCode();
204
+ if (200 <= responseCode && responseCode <= 399) {
205
+
206
+ BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
207
+ StringBuffer response = new StringBuffer();
208
+ String inputLine;
209
+ while ((inputLine = in.readLine()) != null) {
210
+ response.append(inputLine);
211
+ }
212
+ in.close();
213
+
214
+ return response.toString();
215
+
216
+ } else {
217
+ return "Hệ thống đang quá tải vui lòng";
218
+ }
219
+
220
+ } catch (Exception e) {
221
+ if (e instanceof SocketTimeoutException) {
222
+ throw new SocketTimeoutException("");
223
+ }
224
+ throw e;
225
+ }
226
+ }
227
+
228
+ public String getThongTinPort(String url) throws Exception {
229
+ HttpURLConnection con = null;
230
+ try {
231
+ URL obj = new URL(url);
232
+
233
+ String pro = obj.getProtocol();
234
+ if (pro.equals("http")) {
235
+ con = (HttpURLConnection) obj.openConnection();
236
+ } else {
237
+ con = (HttpsURLConnection) obj.openConnection();
238
+ }
239
+ con.setConnectTimeout(7000);
240
+ con.setRequestMethod("GET");
241
+ // con.setRequestProperty("Host", "app.slg.vn");
242
+ con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
243
+ con.setRequestProperty("Host", "api.tamquoc.slg.vn");
244
+ con.setRequestProperty("Upgrade-Insecure-Requests", "1");
245
+ con.setUseCaches(false);
246
+ con.setDoOutput(true);
247
+
248
+ int responseCode = con.getResponseCode();
249
+ if (200 <= responseCode && responseCode <= 399) {
250
+
251
+ BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
252
+ StringBuffer response = new StringBuffer();
253
+ String inputLine;
254
+ while ((inputLine = in.readLine()) != null) {
255
+ response.append(inputLine);
256
+ }
257
+ in.close();
258
+ return response.toString();
259
+
260
+ } else {
261
+ return "Hệ thống đang quá tải vui lòng";
262
+ }
263
+
264
+ } catch (Exception e) {
265
+ if (e instanceof SocketTimeoutException) {
266
+ throw new SocketTimeoutException("");
267
+ }
268
+ throw e;
269
+ }
270
+ }
271
+
272
+ public static String getFrameString(String htmlCode) throws UnsupportedEncodingException {
273
+ String prefix = "src=\"";
274
+ int index = htmlCode.indexOf(prefix);
275
+ if (index == -1) {
276
+ // Could not find the prefix string.
277
+ return null;
278
+ }
279
+
280
+ index += prefix.length();
281
+ int suffixIndex = htmlCode.indexOf("\" frameborder");
282
+ if (suffixIndex == -1) {
283
+ // Could not find the suffix string.
284
+ return null;
285
+ }
286
+
287
+ String address = htmlCode.substring(index, suffixIndex);
288
+ return java.net.URLDecoder.decode(address, StandardCharsets.UTF_8.toString()).replace("&amp;", "&");
289
+ }
290
+
291
+ public static String getInfoSocket(String htmlCode, String token) {
292
+ token = token + " : ";
293
+ int index = htmlCode.indexOf(token);
294
+ if (index == -1) {
295
+ return null;
296
+ }
297
+
298
+ index += token.length();
299
+ int suffixIndex = htmlCode.indexOf(",", index);
300
+ if (suffixIndex == -1) {
301
+ return null;
302
+ }
303
+
304
+ String value = htmlCode.substring(index, suffixIndex);
305
+ value = value.replaceAll("[\'||\"]", "");
306
+ return value;
307
+ }
308
+
309
+ public static String TaoMsg(String commandId, List<String> list, SessionEntity ss) throws NoSuchAlgorithmException, UnsupportedEncodingException {
310
+ String what_is_this = "5dcd73d391c90e8769618d42a916ea1b";
311
+ String input = commandId + ss.getUserId();
312
+
313
+ String msg = String.format("%s\u0001%s\t%s\u0002", commandId, ss.getUserId(), ss.getSessionKey());
314
+ Date date = new Date();
315
+ long millisecondsSinceEpoch = date.getTime();
316
+ if (list != null && list.size() > 0) {
317
+ for (String string : list) {
318
+ input += string;
319
+ msg += string + '\t';
320
+ }
321
+ }
322
+
323
+ input += what_is_this;
324
+ if (list != null && list.size() > 0) {
325
+ msg = msg.substring(0, msg.length());
326
+ }
327
+
328
+ String checksum = hash(input);
329
+ msg += String.format("\u0003%s\u0004%d\u0005\0", checksum, millisecondsSinceEpoch);
330
+ return msg;
331
+ }
332
+
333
+ public static String hash(String input) throws NoSuchAlgorithmException, UnsupportedEncodingException {
334
+ MessageDigest md = MessageDigest.getInstance("MD5");
335
+ byte[] buffer = md.digest(input.getBytes("UTF8"));
336
+ StringBuilder builder = new StringBuilder(input.length() * 2);
337
+ for (byte b : buffer) {
338
+ builder.append(String.format("%02x", b));
339
+ }
340
+ return builder.toString();
341
+ }
342
+
343
+ public static Properties loadProperties(String file_name) {
344
+
345
+ final Properties pr = new Properties();
346
+ //window
347
+ // String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\runshell\\"+file_name;
348
+ //heroku
349
+ String x = "/app/" + file_name;
350
+ try {
351
+ final InputStream fin = new FileInputStream(x);
352
+ pr.load(fin);
353
+ fin.close();
354
+ } catch (final IOException ioe) {
355
+ return null;
356
+ }
357
+ return pr;
358
+ }
359
+
360
+ public static List<String> docFileCauHoiThuThue(String file_name) {
361
+
362
+ final Properties pr = new Properties();
363
+ //window
364
+ // String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\runshell\\cauhoi\\"+file_name;
365
+ //heroku
366
+ String x = "/app/cauhoi/" + file_name;
367
+ try {
368
+ return Doc_file_kieu_txt.readFile(x);
369
+ } catch (Exception e) {
370
+ return null;
371
+ }
372
+ }
373
+
374
+ public String test2(String url) throws Exception {
375
+ HttpURLConnection con = null;
376
+ try {
377
+ URL obj = new URL(url);
378
+
379
+ String pro = obj.getProtocol();
380
+ if (pro.equals("http")) {
381
+ con = (HttpURLConnection) obj.openConnection();
382
+ } else {
383
+ con = (HttpsURLConnection) obj.openConnection();
384
+ }
385
+ con.setConnectTimeout(7000);
386
+ con.setRequestMethod("GET");
387
+ // con.setRequestProperty("Host", "app.slg.vn");
388
+ con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
389
+ con.setRequestProperty("Host", "api.tamquoc.slg.vn");
390
+ con.setRequestProperty("Upgrade-Insecure-Requests", "1");
391
+ con.setUseCaches(false);
392
+ con.setDoOutput(true);
393
+
394
+ int responseCode = con.getResponseCode();
395
+ if (200 <= responseCode && responseCode <= 399) {
396
+
397
+ BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
398
+ StringBuffer response = new StringBuffer();
399
+ String inputLine;
400
+ while ((inputLine = in.readLine()) != null) {
401
+ response.append(inputLine);
402
+ }
403
+ in.close();
404
+ return con.getHeaderField("Location");
405
+
406
+ } else {
407
+ return "rea2";
408
+ }
409
+
410
+ } catch (Exception e) {
411
+ if (e instanceof SocketTimeoutException) {
412
+ throw new SocketTimeoutException("");
413
+ }
414
+ throw e;
415
+ }
416
+ }
417
+
418
+ public String test1(String url) throws Exception {
419
+ HttpURLConnection con = null;
420
+ try {
421
+ URL obj = new URL(url);
422
+
423
+ String pro = obj.getProtocol();
424
+ if (pro.equals("http")) {
425
+ con = (HttpURLConnection) obj.openConnection();
426
+ } else {
427
+ con = (HttpsURLConnection) obj.openConnection();
428
+ }
429
+ con.setConnectTimeout(7000);
430
+ con.setRequestMethod("GET");
431
+ // con.setRequestProperty("Host", "app.slg.vn");
432
+ con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
433
+ con.setRequestProperty("Host", "api.sengokugifu.jp");
434
+ con.setRequestProperty("Upgrade-Insecure-Requests", "1");
435
+ con.setUseCaches(false);
436
+ con.setDoOutput(true);
437
+
438
+ int responseCode = con.getResponseCode();
439
+ if (200 <= responseCode && responseCode <= 399) {
440
+
441
+ BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
442
+ StringBuffer response = new StringBuffer();
443
+ String inputLine;
444
+ while ((inputLine = in.readLine()) != null) {
445
+ response.append(inputLine);
446
+ }
447
+ in.close();
448
+ return response.toString();
449
+
450
+ } else {
451
+ return "tre1";
452
+ }
453
+
454
+ } catch (Exception e) {
455
+ if (e instanceof SocketTimeoutException) {
456
+ throw new SocketTimeoutException("");
457
+ }
458
+ throw e;
459
+ }
460
+ }
461
+ }
src/main/java/tqtk/XuLy/Worker.java ADDED
@@ -0,0 +1,911 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package tqtk.XuLy;
2
+
3
+ import com.fasterxml.jackson.core.type.TypeReference;
4
+ import com.fasterxml.jackson.databind.ObjectMapper;
5
+ import java.io.IOException;
6
+ import java.net.InetAddress;
7
+ import java.net.InetSocketAddress;
8
+ import java.net.Socket;
9
+ import java.net.UnknownHostException;
10
+ import java.nio.charset.StandardCharsets;
11
+ import java.util.ArrayList;
12
+ import java.util.LinkedHashMap;
13
+ import java.util.List;
14
+ import java.util.Map;
15
+ import java.util.logging.Level;
16
+ import java.util.logging.Logger;
17
+ import tqtk.Entity.Barrack;
18
+ import tqtk.Entity.Hero;
19
+ import tqtk.Entity.JsonObject;
20
+ import tqtk.Entity.SessionEntity;
21
+ import tqtk.Tqtk;
22
+ import tqtk.Utils.Util;
23
+ import tqtk.XuLy.login.LayThongTinSession;
24
+ import static tqtk.XuLy.XuLyPacket.GuiPacket;
25
+
26
+ import static tqtk.XuLy.XuLyPacket.GuiPacketKhongKQ;
27
+ import tqtk.exception.JsonException;
28
+
29
+ /**
30
+ *
31
+ * @author Alex
32
+ */
33
+ public class Worker extends Thread {
34
+
35
+ SessionEntity ss;
36
+
37
+ public Worker(SessionEntity ss) {
38
+
39
+ this.ss = ss;
40
+ }
41
+
42
+ public void GuiPacketDeLogin() throws InterruptedException, IOException {
43
+ // packet duy tri dang nhap , neu muon truy cap vao 1 acc tu` nhieu noi thi , phai co'
44
+ // 1 noi dang nhap truoc roi , luc nay se ko can chay packet 10100
45
+ Thread.sleep(5000);
46
+ GuiPacketKhongKQ(ss, "10100", null);
47
+ // packet cap nhat thong tin lien tuc tu server
48
+ Thread.sleep(5000);
49
+ GuiPacketKhongKQ(ss, "11102", null);
50
+ Thread.sleep(5000);
51
+ GuiPacketKhongKQ(ss, "52103", null);
52
+ Thread.sleep(5000);
53
+ GuiPacketKhongKQ(ss, "10108", null);
54
+ Thread.sleep(5000);
55
+ GuiPacketKhongKQ(ss, "20101", null);
56
+ Thread.sleep(5000);
57
+ List<String> list1 = new ArrayList<>();
58
+ list1.add(0, "1");
59
+ StringBuilder rs1 = GuiPacket(ss, "12200", list1);
60
+ list1 = null;
61
+
62
+ }
63
+
64
+ public void LuyenTuong() {
65
+ List<String> list1 = new ArrayList<>();
66
+ list1.add(0, "0");
67
+ List<String> list2 = new ArrayList<>();
68
+ list2.add(0, "0");
69
+ list2.add(1, "1");
70
+ list2.add(2, "1");
71
+
72
+ try {
73
+ StringBuilder rs1 = GuiPacket(ss, "41100", list1);
74
+ if (rs1 != null) {
75
+ try {
76
+ String[] temp = rs1.toString().split("");
77
+
78
+ ObjectMapper mapper = new ObjectMapper();
79
+ Map<String, Object> carMap = null;
80
+ int h = 0;
81
+ for (String string : temp) {
82
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
83
+ });
84
+ h = (int) carMap.get("h");
85
+ if (h == Integer.parseInt("41100")) {
86
+ break;
87
+ }
88
+ }
89
+
90
+ List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("general");
91
+ int idhero = 0;
92
+ String name = "";
93
+ int trainflag = 0;
94
+ int lvhero = 0;
95
+
96
+ list1.add(1, "1");
97
+ Tqtk.sendMessage("lt " + ss.getStringName());
98
+ for (Object object : carMap1) {
99
+
100
+ idhero = (int) ((Map<Object, Object>) object).get("generalid");
101
+ name = (String) ((Map<Object, Object>) object).get("generalname");
102
+ trainflag = (int) ((Map<Object, Object>) object).get("trainflag");
103
+ lvhero = (int) ((Map<Object, Object>) object).get("generallevel");
104
+ list1.set(0, Integer.toString(idhero));
105
+ list2.set(0, Integer.toString(idhero));
106
+ Tqtk.sendMessage("lt " + name);
107
+ if (name != null) {
108
+ if ("武田信虎 --".equals(name) && trainflag == 0) {
109
+ rs1 = GuiPacket(ss, "41101", list1);
110
+ Thread.sleep(5000);
111
+ rs1 = GuiPacket(ss, "41102", list2);
112
+ Thread.sleep(5000);
113
+
114
+ } else if ("織田信行 --".equals(name) && trainflag == 0) {
115
+ rs1 = GuiPacket(ss, "41101", list1);
116
+ Thread.sleep(5000);
117
+ rs1 = GuiPacket(ss, "41102", list2);
118
+ Thread.sleep(5000);
119
+
120
+ } else if ("井伊直盛 --".equals(name) && trainflag == 0) {
121
+ rs1 = GuiPacket(ss, "41101", list1);
122
+ Thread.sleep(5000);
123
+ rs1 = GuiPacket(ss, "41102", list2);
124
+ Thread.sleep(5000);
125
+
126
+ } else if ("彦坂元正 --".equals(name) && trainflag == 0) {
127
+ rs1 = GuiPacket(ss, "41101", list1);
128
+ Thread.sleep(5000);
129
+ rs1 = GuiPacket(ss, "41102", list2);
130
+ Thread.sleep(5000);
131
+
132
+ } else if ("大久保忠員".equals(name) && trainflag == 0) {
133
+ rs1 = GuiPacket(ss, "41101", list1);
134
+ Thread.sleep(5000);
135
+ rs1 = GuiPacket(ss, "41102", list2);
136
+ Thread.sleep(5000);
137
+
138
+ } else if ("内藤正成".equals(name) && trainflag == 0) {
139
+ rs1 = GuiPacket(ss, "41101", list1);
140
+ Thread.sleep(5000);
141
+ rs1 = GuiPacket(ss, "41102", list2);
142
+ Thread.sleep(5000);
143
+
144
+ } else if ("Thái Diễm ".equals(name) && trainflag == 0) {
145
+ rs1 = GuiPacket(ss, "41101", list1);
146
+ Thread.sleep(5000);
147
+ rs1 = GuiPacket(ss, "41102", list2);
148
+ Thread.sleep(5000);
149
+
150
+ } else if ("Tư Mã Chiêu ".equals(name) && trainflag == 0) {
151
+ rs1 = GuiPacket(ss, "41101", list1);
152
+ Thread.sleep(5000);
153
+ rs1 = GuiPacket(ss, "41102", list2);
154
+ Thread.sleep(5000);
155
+
156
+ }
157
+ }
158
+ }
159
+ } catch (Exception e) {
160
+ throw new JsonException();
161
+ }
162
+
163
+ }
164
+ } catch (Exception ex) {
165
+ if (!(ex instanceof JsonException)) {
166
+ System.out.println("loi LuyenTuong " + ss.getStringName() + ex.getMessage());
167
+ } else {
168
+ System.out.println("loi LuyenTuong json" + ss.getStringName() + ex.getMessage());
169
+ }
170
+
171
+ }
172
+
173
+ }
174
+
175
+ public void TruyNa() {
176
+ List<String> list1 = new ArrayList<>();
177
+ list1.add(0, "0");
178
+ try {
179
+ Thread.sleep(5000);
180
+ StringBuilder rs1 = GuiPacket(ss, "60605", null);
181
+ if (rs1 != null) {
182
+ try {
183
+ String[] temp = rs1.toString().split("");
184
+
185
+ ObjectMapper mapper = new ObjectMapper();
186
+ Map<String, Object> carMap = null;
187
+ int h = 0;
188
+ for (String string : temp) {
189
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
190
+ });
191
+ h = (int) carMap.get("h");
192
+ if (h == Integer.parseInt("60605")) {
193
+ break;
194
+ }
195
+ }
196
+
197
+ List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("wantedMemberList");
198
+ int idarea = 0;
199
+ int id = 0;
200
+ int attactNum = 0;
201
+ long playerId = 0;
202
+ Tqtk.sendMessage("tn " + ss.getStringName());
203
+ for (Object object : carMap1) {
204
+ idarea = (int) ((Map<Object, Object>) object).get("areaId");
205
+ id = (int) ((Map<Object, Object>) object).get("id");
206
+ attactNum = (int) ((Map<Object, Object>) object).get("attactNum");
207
+ playerId = (long) ((Map<Object, Object>) object).get("playerId");
208
+ list1.set(0, Integer.toString(id));
209
+
210
+ //synchronized (tqtk.Tqtk.loaiTruyna) {
211
+ if (id != 0 && !Tqtk.loaiTruyna.contains(Long.toString(playerId)) && attactNum != 0 && idarea == -1) {
212
+ rs1 = GuiPacket(ss, "60606", list1);
213
+ Thread.sleep(5000);
214
+ if (rs1.toString().contains("đã thất bại khi chiến đấu")) {
215
+ tqtk.Tqtk.loaiTruyna.add(Long.toString(playerId));
216
+ }
217
+
218
+ }
219
+ //}
220
+ }
221
+ } catch (Exception e) {
222
+ throw new JsonException();
223
+ }
224
+
225
+ //}
226
+ }
227
+ } catch (Exception ex) {
228
+ if (!(ex instanceof JsonException)) {
229
+
230
+ System.out.println("loi TruyNa " + ss.getStringName() + ex.getMessage());
231
+ } else {
232
+
233
+ System.out.println("loi TruyNa json " + ss.getStringName() + ex.getMessage());
234
+ }
235
+ }
236
+
237
+ }
238
+
239
+ public void NangNha() {
240
+ List<String> list1 = new ArrayList<>();
241
+
242
+ try {
243
+ // nha chinh
244
+ list1.add(0, "5");
245
+ Thread.sleep(5000);
246
+ StringBuilder rs1 = GuiPacket(ss, "12100", list1);
247
+ Tqtk.sendMessage("nang nha " + ss.getStringName());
248
+ // nang cua tiem
249
+ list1.set(0, "6");
250
+ Thread.sleep(5000);
251
+ rs1 = GuiPacket(ss, "12100", list1);
252
+ // nang thao truong
253
+ list1.set(0, "3");
254
+ Thread.sleep(5000);
255
+ rs1 = GuiPacket(ss, "12100", list1);
256
+ // nang nang binh doanh
257
+ list1.set(0, "2");
258
+ Thread.sleep(5000);
259
+ rs1 = GuiPacket(ss, "12100", list1);
260
+
261
+ list1.set(0, "1");
262
+ Thread.sleep(5000);
263
+ rs1 = GuiPacket(ss, "12100", list1);
264
+
265
+
266
+
267
+ } catch (Exception e) {
268
+ System.out.println("NangNha " + ss.getStringName() + e.getMessage());
269
+ }
270
+ }
271
+
272
+ public void NangKiNang() {
273
+ List<String> list1 = new ArrayList<>();
274
+ try {
275
+ //binh khi , 42200 ,3
276
+ list1.add(0, "3");
277
+ Thread.sleep(5000);
278
+ StringBuilder rs1 = GuiPacket(ss, "42200", list1);
279
+ Tqtk.sendMessage("nang kn " + ss.getStringName());
280
+ // nang ki nang , vu khi , 42200 ,1
281
+ list1.set(0, "1");
282
+ Thread.sleep(5000);
283
+ rs1 = GuiPacket(ss, "42200", list1);
284
+ // lenh ki , 42200 ,2
285
+ list1.set(0, "2");
286
+ Thread.sleep(5000);
287
+ rs1 = GuiPacket(ss, "42200", list1);
288
+ // giap , 42200 ,4
289
+ list1.set(0, "4");
290
+ Thread.sleep(5000);
291
+ rs1 = GuiPacket(ss, "42200", list1);
292
+ // xung phong , 42200 ,5
293
+ list1.set(0, "5");
294
+ Thread.sleep(5000);
295
+ rs1 = GuiPacket(ss, "42200", list1);
296
+
297
+
298
+ } catch (Exception e) {
299
+ System.out.println("NangKiNang " + ss.getStringName() + e.getMessage());
300
+ }
301
+ }
302
+
303
+ public void MuaLinh() {
304
+ List<String> list1 = new ArrayList<>();
305
+ try {
306
+ StringBuilder rs1 = GuiPacket(ss, "14101", null);
307
+
308
+ String[] temp = rs1.toString().split("");
309
+
310
+ ObjectMapper mapper = new ObjectMapper();
311
+ Map<String, Object> carMap = null;
312
+ int h = 0;
313
+ for (String string : temp) {
314
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
315
+ });
316
+ h = (int) carMap.get("h");
317
+ if (h == Integer.parseInt("14101")) {
318
+ break;
319
+ }
320
+ }
321
+
322
+ double tile = (double) ((Map<String, Object>) carMap.get("m")).get("recruits");
323
+ int max = (int) ((Map<String, Object>) carMap.get("m")).get("forcemax");
324
+ max = max / 3;
325
+ list1.add(0, Integer.toString((int) max));
326
+ list1.add(1, Integer.toString((int) Math.round(max * tile)));
327
+ Thread.sleep(5000);
328
+ rs1 = GuiPacket(ss, "14102", list1);
329
+ Tqtk.sendMessage("mualinh " + ss.getStringName());
330
+ Thread.sleep(5000);
331
+ GuiPacket(ss, "14100", null);
332
+ Thread.sleep(5000);
333
+
334
+ } catch (Exception e) {
335
+ System.out.println("MuaLinh " + ss.getStringName() + e.getMessage());
336
+ }
337
+ }
338
+
339
+ public void DanhQuanDoan() {
340
+ // danh quan doan vu van thi toc
341
+ List<String> list1 = new ArrayList<>();
342
+ list1.add(0, "900038");
343
+ List<String> list2 = new ArrayList<>();
344
+ list2.add(0, "0");
345
+
346
+ try {
347
+ StringBuilder rs1 = GuiPacket(ss, "34100", list1);
348
+ Thread.sleep(5000);
349
+ if (rs1 != null) {
350
+ try {
351
+ String[] temp = rs1.toString().split("");
352
+
353
+ ObjectMapper mapper = new ObjectMapper();
354
+ Map<String, Object> carMap = null;
355
+ int h = 0;
356
+ for (String string : temp) {
357
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
358
+ });
359
+ h = (int) carMap.get("h");
360
+ if (h == Integer.parseInt("34100")) {
361
+ break;
362
+ }
363
+ }
364
+
365
+ List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("team");
366
+ long idhero = 0;
367
+
368
+ Tqtk.sendMessage("qd " + ss.getStringName());
369
+
370
+ if (carMap1 != null && carMap1.size() > 0) {
371
+ Object object = carMap1.get(0);
372
+ idhero = (long) ((Map<Object, Object>) object).get("teamid");
373
+ list2.set(0, Long.toString(idhero));
374
+
375
+ rs1 = GuiPacket(ss, "34102", list2);
376
+ Thread.sleep(5000);
377
+ }
378
+ } catch (Exception e) {
379
+ throw new JsonException();
380
+ }
381
+
382
+ }
383
+ } catch (Exception ex) {
384
+ if (!(ex instanceof JsonException)) {
385
+ System.out.println("loi qd " + ss.getStringName() + ex.getMessage());
386
+ } else {
387
+ System.out.println("loi qd json" + ss.getStringName() + ex.getMessage());
388
+ }
389
+
390
+ }
391
+ }
392
+
393
+ public void DanhQuanDoan1() {
394
+ if (ss != null && ss.getStringName().equals("[email protected]")) {
395
+ // danh quan doan duong binh
396
+ List<String> list1 = new ArrayList<>();
397
+ list1.add(0, "900016");
398
+ // list1.add(1, "4:0;1");
399
+
400
+ List<String> list2 = new ArrayList<>();
401
+ list2.add(0, "0");
402
+
403
+ try {
404
+ StringBuilder rs1 = GuiPacket(ss, "34100", list1);
405
+ Thread.sleep(5000);
406
+ if (rs1 != null) {
407
+ try {
408
+ String[] temp = rs1.toString().split("");
409
+
410
+ ObjectMapper mapper = new ObjectMapper();
411
+ Map<String, Object> carMap = null;
412
+ int h = 0;
413
+ for (String string : temp) {
414
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
415
+ });
416
+ h = (int) carMap.get("h");
417
+ if (h == Integer.parseInt("34100")) {
418
+ break;
419
+ }
420
+ }
421
+
422
+ List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("team");
423
+ long idhero = 0;
424
+
425
+ Tqtk.sendMessage("qd " + ss.getStringName());
426
+
427
+ if (carMap1 != null && carMap1.size() > 0) {
428
+ Object object = carMap1.get(0);
429
+ idhero = (long) ((Map<Object, Object>) object).get("teamid");
430
+ list2.set(0, Long.toString(idhero));
431
+
432
+ rs1 = GuiPacket(ss, "34102", list2);
433
+ Thread.sleep(5000);
434
+ }
435
+ } catch (Exception e) {
436
+ throw new JsonException();
437
+ }
438
+
439
+ }
440
+ } catch (Exception ex) {
441
+ if (!(ex instanceof JsonException)) {
442
+ System.out.println("loi qd " + ss.getStringName() + ex.getMessage());
443
+ } else {
444
+ System.out.println("loi qd json" + ss.getStringName() + ex.getMessage());
445
+ }
446
+
447
+ }
448
+ }
449
+ }
450
+
451
+ public void DanhQuanDoan2() {
452
+
453
+ if (ss != null && ss.getStringName().equals("[email protected]")) {
454
+ // danh quan doan duong binh
455
+ List<String> list1 = new ArrayList<>();
456
+ list1.add(0, "900015");
457
+ List<String> list2 = new ArrayList<>();
458
+ list2.add(0, "0");
459
+
460
+ try {
461
+ StringBuilder rs1 = GuiPacket(ss, "34100", list1);
462
+ Thread.sleep(5000);
463
+ if (rs1 != null) {
464
+ try {
465
+ String[] temp = rs1.toString().split("");
466
+
467
+ ObjectMapper mapper = new ObjectMapper();
468
+ Map<String, Object> carMap = null;
469
+ int h = 0;
470
+ for (String string : temp) {
471
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
472
+ });
473
+ h = (int) carMap.get("h");
474
+ if (h == Integer.parseInt("34100")) {
475
+ break;
476
+ }
477
+ }
478
+
479
+ List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("team");
480
+ long idhero = 0;
481
+
482
+ Tqtk.sendMessage("qd " + ss.getStringName());
483
+
484
+ if (carMap1 != null && carMap1.size() > 0) {
485
+ Object object = carMap1.get(0);
486
+ idhero = (long) ((Map<Object, Object>) object).get("teamid");
487
+ list2.set(0, Long.toString(idhero));
488
+
489
+ rs1 = GuiPacket(ss, "34102", list2);
490
+ Thread.sleep(5000);
491
+ }
492
+ } catch (Exception e) {
493
+ throw new JsonException();
494
+ }
495
+
496
+ }
497
+ } catch (Exception ex) {
498
+ if (!(ex instanceof JsonException)) {
499
+ System.out.println("loi qd " + ss.getStringName() + ex.getMessage());
500
+ } else {
501
+ System.out.println("loi qd json" + ss.getStringName() + ex.getMessage());
502
+ }
503
+
504
+ }
505
+
506
+ }
507
+
508
+ }
509
+
510
+ public void DanhQuanDoan3() {
511
+
512
+ if ((ss != null && ss.getStringName().contains("@gmail.com") && !ss.getStringName().equals("[email protected]")) || ss != null && ss.getStringName().contains("itf.edu.vn")) {
513
+ // danh quan doan duong binh
514
+ List<String> list1 = new ArrayList<>();
515
+ list1.add(0, "900013");
516
+ List<String> list2 = new ArrayList<>();
517
+ list2.add(0, "0");
518
+
519
+ try {
520
+ StringBuilder rs1 = GuiPacket(ss, "34100", list1);
521
+ Thread.sleep(5000);
522
+ if (rs1 != null) {
523
+ try {
524
+ String[] temp = rs1.toString().split("");
525
+
526
+ ObjectMapper mapper = new ObjectMapper();
527
+ Map<String, Object> carMap = null;
528
+ int h = 0;
529
+ for (String string : temp) {
530
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
531
+ });
532
+ h = (int) carMap.get("h");
533
+ if (h == Integer.parseInt("34100")) {
534
+ break;
535
+ }
536
+ }
537
+
538
+ List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("team");
539
+ long idhero = 0;
540
+
541
+ Tqtk.sendMessage("qd " + ss.getStringName());
542
+
543
+ if (carMap1 != null && carMap1.size() > 0) {
544
+ Object object = carMap1.get(0);
545
+ idhero = (long) ((Map<Object, Object>) object).get("teamid");
546
+ list2.set(0, Long.toString(idhero));
547
+
548
+ rs1 = GuiPacket(ss, "34102", list2);
549
+ Thread.sleep(5000);
550
+ }
551
+ } catch (Exception e) {
552
+ throw new JsonException();
553
+ }
554
+
555
+ }
556
+ } catch (Exception ex) {
557
+ if (!(ex instanceof JsonException)) {
558
+ System.out.println("loi qd " + ss.getStringName() + ex.getMessage());
559
+ } else {
560
+ System.out.println("loi qd json" + ss.getStringName() + ex.getMessage());
561
+ }
562
+
563
+ }
564
+
565
+ }
566
+
567
+ }
568
+
569
+ public void ThuThue() {
570
+ // danh quan doan vu van thi toc
571
+ List<String> list1 = new ArrayList<>();
572
+ list1.add(0, "0");
573
+ list1.add(1, "0");
574
+ List<String> list2 = new ArrayList<>();
575
+ list2.add(0, "0");
576
+
577
+ try {
578
+ StringBuilder rs1 = GuiPacket(ss, "12401", list1);
579
+ Thread.sleep(5000);
580
+ if (rs1 != null) {
581
+ try {
582
+ String[] temp = rs1.toString().split("");
583
+
584
+ ObjectMapper mapper = new ObjectMapper();
585
+ Map<String, Object> carMap = null;
586
+ int h = 0;
587
+ for (String string : temp) {
588
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
589
+ });
590
+ h = (int) carMap.get("h");
591
+ if (h == Integer.parseInt("12401")) {
592
+ break;
593
+ }
594
+ }
595
+
596
+ Map<String, Object> carMap1 = (Map<String, Object>) ((Map<String, Object>) carMap.get("m")).get("larrydto");
597
+
598
+ Tqtk.sendMessage("thuthue " + ss.getStringName());
599
+
600
+ if (carMap1 != null) {
601
+ String optdisc1 = (String) carMap1.get("optdisc1");
602
+ String optdisc2 = (String) carMap1.get("optdisc2");
603
+
604
+ List<String> cauhoi = Util.docFileCauHoiThuThue("thu_thue_dan_tam.txt");
605
+
606
+ for (String item : cauhoi) {
607
+ if (optdisc1.contains(item)) {
608
+ list2.set(0, "1");
609
+ rs1 = GuiPacket(ss, "12406", list2);
610
+ Thread.sleep(5000);
611
+ break;
612
+ } else if (optdisc2.contains(item)) {
613
+ list2.set(0, "2");
614
+ rs1 = GuiPacket(ss, "12406", list2);
615
+ Thread.sleep(5000);
616
+ break;
617
+ } else {
618
+ list2.set(0, "1");
619
+ rs1 = GuiPacket(ss, "12406", list2);
620
+ Thread.sleep(5000);
621
+ break;
622
+ }
623
+ }
624
+
625
+ }
626
+ } catch (Exception e) {
627
+ throw new JsonException();
628
+ }
629
+
630
+ }
631
+ } catch (Exception ex) {
632
+ if (!(ex instanceof JsonException)) {
633
+ System.out.println("loi qd " + ss.getStringName() + ex.getMessage());
634
+ } else {
635
+ System.out.println("loi qd json" + ss.getStringName() + ex.getMessage());
636
+ }
637
+
638
+ }
639
+ }
640
+
641
+ public void ChiemRuong() {
642
+ // danh quan doan vu van thi toc
643
+ List<String> list1 = new ArrayList<>();
644
+ List<String> list2 = new ArrayList<>();
645
+ list2.add(0, "0");
646
+
647
+ try {
648
+ StringBuilder rs1 = GuiPacket(ss, "31103", null);
649
+ Thread.sleep(5000);
650
+ if (rs1 != null) {
651
+ try {
652
+ String[] temp = rs1.toString().split("");
653
+
654
+ ObjectMapper mapper = new ObjectMapper();
655
+ Map<String, Object> carMap = null;
656
+ int h = 0;
657
+ for (String string : temp) {
658
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
659
+ });
660
+ h = (int) carMap.get("h");
661
+ if (h == Integer.parseInt("31103")) {
662
+ break;
663
+ }
664
+ }
665
+ synchronized (tqtk.Tqtk.listruong) {
666
+ tqtk.Tqtk.listruong = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("resource");
667
+
668
+ Tqtk.sendMessage("chiem ruong " + ss.getStringName());
669
+ Object playerId = 0;
670
+ int resourceid = 0;
671
+ if (tqtk.Tqtk.listruong != null) {
672
+ for (Object object : tqtk.Tqtk.listruong) {
673
+ playerId = ((Map<Object, Object>) object).get("playerid");
674
+ resourceid = (int) ((Map<Object, Object>) object).get("resourceid");
675
+ if (playerId instanceof Integer) {
676
+ break;
677
+ }
678
+ }
679
+ }
680
+ list2.set(0, Integer.toString(resourceid));
681
+ rs1 = GuiPacket(ss, "31104", list2);
682
+ Thread.sleep(5000);
683
+ }
684
+ } catch (Exception e) {
685
+ throw new JsonException();
686
+ }
687
+
688
+ }
689
+ } catch (Exception ex) {
690
+ if (!(ex instanceof JsonException)) {
691
+ System.out.println("loi qd " + ss.getStringName() + ex.getMessage());
692
+ } else {
693
+ System.out.println("loi qd json" + ss.getStringName() + ex.getMessage());
694
+ }
695
+
696
+ }
697
+ }
698
+
699
+ public void FarmDo() {
700
+ if (false && ss != null && ss.getStringName().equals("[email protected]")) {
701
+ // danh map ngo
702
+ List<String> list1 = new ArrayList<>();
703
+ list1.add(0, "2817");
704
+ list1.add(1, "0");
705
+
706
+ try {
707
+ StringBuilder rs1 = GuiPacket(ss, "33101", list1);
708
+ Thread.sleep(5000);
709
+
710
+ } catch (Exception ex) {
711
+ System.out.println("loi FarmDo " + ss.getStringName() + ex.getMessage());
712
+ }
713
+ } else if (ss != null && ss.getStringName().contains("@gmail.com") && !ss.getStringName().equals("[email protected]")) {
714
+ // danh lu bo
715
+ List<String> list1 = new ArrayList<>();
716
+ list1.add(0, "2216");
717
+ list1.add(1, "0");
718
+
719
+ try {
720
+ StringBuilder rs1 = GuiPacket(ss, "33101", list1);
721
+ Thread.sleep(5000);
722
+ list1.set(0, "2529");
723
+ GuiPacket(ss, "33101", list1);
724
+ Thread.sleep(5000);
725
+
726
+ } catch (Exception ex) {
727
+ System.out.println("loi FarmDo " + ss.getStringName() + ex.getMessage());
728
+ }
729
+ }
730
+
731
+ }
732
+
733
+ public void NangItem() throws IOException, UnknownHostException, InterruptedException, Exception {
734
+ List<String> list1 = new ArrayList<>();
735
+ list1.add(0, "0");
736
+ list1.add(1, "0");
737
+ list1.add(2, "30");
738
+ try {
739
+ Thread.sleep(5000);
740
+ StringBuilder rs1 = GuiPacket(ss, "39301", list1);
741
+ if (rs1 != null && rs1.toString() != "") {
742
+ try {
743
+ String[] temp = rs1.toString().split("");
744
+
745
+ ObjectMapper mapper = new ObjectMapper();
746
+ Map<String, Object> carMap = null;
747
+ int h = 0;
748
+ for (String string : temp) {
749
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
750
+ });
751
+ h = (int) carMap.get("h");
752
+ if (h == Integer.parseInt("39301")) {
753
+ break;
754
+ }
755
+ }
756
+ List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("equip");
757
+ Object Magic = (Object) ((Map<String, Object>) carMap.get("m")).get("magic");
758
+ int Upgradecdusable = (int) ((Map<String, Object>) carMap.get("m")).get("upgradecdusable");
759
+ int lv = 0;
760
+ String name = "";
761
+ Integer storeid = 0;
762
+ String generalname = "";
763
+ Tqtk.sendMessage("nang item " + ss.getStringName());
764
+ for (Object object : carMap1) {
765
+ lv = (int) ((Map<Object, Object>) object).get("equipAllLevel");
766
+ name = (String) ((Map<Object, Object>) object).get("equipname");
767
+ storeid = (Integer) ((Map<Object, Object>) object).get("storeid");
768
+ generalname = (String) ((Map<Object, Object>) object).get("generalname");
769
+ Tqtk.sendMessage(lv + " " + name + " " + storeid + " " + generalname);
770
+ list1.set(0, Integer.toString(storeid));
771
+ list1.set(2, Magic.toString());
772
+ if (generalname != null) {
773
+ if ((ss != null)) {
774
+ // if ((int) Magic > 87 && "武田信虎".equals(generalname)) {
775
+ if ((int) Magic > 87 && "武田信虎".equals(generalname)) {
776
+ rs1 = GuiPacket(ss, "39302", list1);
777
+ Thread.sleep(5000);
778
+ }
779
+ else if (Upgradecdusable == 1 && (int) Magic > 87 && "織田信行 --".equals(generalname) && lv <= 80) {
780
+ rs1 = GuiPacket(ss, "39302", list1);
781
+ Thread.sleep(5000);
782
+ }
783
+ else if (Upgradecdusable == 1 && (int) Magic > 87 && "井伊直盛 --".equals(generalname) && lv <= 80) {
784
+ rs1 = GuiPacket(ss, "39302", list1);
785
+ Thread.sleep(5000);
786
+ } else if (Upgradecdusable == 1 && (int) Magic > 87 && "Y Tịch ".equals(generalname) && lv <= 80) {
787
+ rs1 = GuiPacket(ss, "39302", list1);
788
+ Thread.sleep(5000);
789
+ } else if (Upgradecdusable == 1 && (int) Magic > 87 && "Lưu Biểu ".equals(generalname) && lv <= 80) {
790
+ rs1 = GuiPacket(ss, "39302", list1);
791
+ Thread.sleep(5000);
792
+
793
+ }
794
+ }
795
+
796
+ }
797
+ }
798
+ } catch (Exception e) {
799
+ throw new JsonException();
800
+ }
801
+ } else {
802
+ dangNhapLayThongTin();
803
+ GuiPacketDeLogin();
804
+ }
805
+ } catch (Exception ex) {
806
+ if (!(ex instanceof JsonException)) {
807
+ System.out.println("NangItem " + ss.getStringName() + ex.getMessage());
808
+ dangNhapLayThongTin();
809
+ GuiPacketDeLogin();
810
+ } else {
811
+ System.out.println("NangItem json " + ss.getStringName() + ex.getMessage());
812
+ }
813
+
814
+ }
815
+
816
+ }
817
+
818
+ public void GianKhoan() {
819
+ List<String> list1 = new ArrayList<>();
820
+ list1.add("3");
821
+ list1.add("101");
822
+ List<String> list2 = new ArrayList<>();
823
+ list2.add("3");
824
+ list2.add("101");
825
+ list2.add("0");
826
+ list2.add("0");
827
+ // lay phan thuong khoan
828
+ try {
829
+ StringBuilder rs = GuiPacket(ss, "62007", list1);
830
+ Thread.sleep(5000);
831
+ if (rs != null) {
832
+ if (!rs.toString().contains("Đang khai thác")) {
833
+ Tqtk.sendMessage("gian khoan " + ss.getStringName());
834
+ // bat dau khoan
835
+ GuiPacket(ss, "62006", list2);
836
+ }
837
+ } else {
838
+
839
+ }
840
+
841
+ } catch (Exception ex) {
842
+ System.out.println(ex.getMessage());
843
+ }
844
+ }
845
+
846
+ public void CapNhatThongTin() {
847
+
848
+ try {
849
+ // packet cap nhat thong tin lien tuc tu server
850
+ Thread.sleep(5000);
851
+ GuiPacketKhongKQ(ss, "10100", null);
852
+ // packet cap nhat thong tin lien tuc tu server
853
+ Thread.sleep(5000);
854
+ GuiPacketKhongKQ(ss, "11102", null);
855
+ Thread.sleep(5000);
856
+ GuiPacketKhongKQ(ss, "52103", null);
857
+ Thread.sleep(5000);
858
+ GuiPacketKhongKQ(ss, "10108", null);
859
+ Thread.sleep(5000);
860
+ GuiPacketKhongKQ(ss, "20101", null);
861
+ Thread.sleep(5000);
862
+ List<String> list1 = new ArrayList<>();
863
+ list1.add(0, "1");
864
+ StringBuilder rs1 = GuiPacket(ss, "12200", list1);
865
+ list1 = null;
866
+ } catch (Exception ex) {
867
+ System.out.println(ex.getMessage());
868
+ }
869
+ }
870
+
871
+ public void dangNhapLayThongTin() throws Exception {
872
+ Util u = new Util();
873
+ this.ss = LayThongTinSession.getSessionEntity(ss.getStringName(), ss.getPass(), 22, u);
874
+ Socket socket = new Socket();
875
+ socket.connect(new InetSocketAddress(InetAddress.getByName(ss.getIp()), ss.getPorts()), 7000);
876
+ if (ss.getSocket() != null) {
877
+ ss.getSocket().close();
878
+ }
879
+ ss.setSocket(socket);
880
+ }
881
+
882
+ @Override
883
+ public void run() {
884
+ try {
885
+ dangNhapLayThongTin();
886
+ GuiPacketDeLogin();
887
+
888
+ while (true) {
889
+
890
+ // MuaLinh();
891
+ // DanhQuanDoan1();
892
+ // DanhQuanDoan2();
893
+ // DanhQuanDoan3();
894
+ NangItem();
895
+ // TruyNa();
896
+ LuyenTuong();
897
+ NangNha();
898
+ NangKiNang();
899
+ // GianKhoan();
900
+ //FarmDo();
901
+ // ThuThue();
902
+ // ChiemRuong();
903
+ // CapNhatThongTin();
904
+ Thread.sleep(55 * 1000);
905
+ }
906
+ } catch (Exception ex) {
907
+ System.out.println("all " + ss.getStringName() + ex.getMessage());
908
+ }
909
+ }
910
+
911
+ }
src/main/java/tqtk/XuLy/XuLyPacket.java ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package tqtk.XuLy;
7
+
8
+ import java.io.BufferedWriter;
9
+ import java.io.DataOutputStream;
10
+ import java.io.IOException;
11
+ import java.io.InputStream;
12
+ import java.io.OutputStreamWriter;
13
+ import java.net.Socket;
14
+ import java.net.UnknownHostException;
15
+ import java.util.List;
16
+ import tqtk.Entity.SessionEntity;
17
+ import tqtk.Utils.Util;
18
+
19
+ /**
20
+ *
21
+ * @author Alex
22
+ */
23
+ public class XuLyPacket {
24
+
25
+ public static void GuiPacketKhongKQ(SessionEntity ss, String code, List<String> list) throws UnknownHostException, IOException, InterruptedException {
26
+ BufferedWriter wr = null;
27
+ try {
28
+ String message = Util.TaoMsg(code, list, ss);
29
+ Thread.sleep(2 * 1000);
30
+ wr = new BufferedWriter(new OutputStreamWriter(ss.getSocket().getOutputStream(), "UTF8"));
31
+ wr.write(message);
32
+ wr.flush();
33
+ } catch (Exception e) {
34
+ System.out.println(e.getMessage());
35
+ // if (e.getMessage().contains("socket write error")) {
36
+ ss.resetSocket();
37
+ // }
38
+ }
39
+
40
+ }
41
+
42
+ public static StringBuilder GuiPacket(SessionEntity ss, String code, List<String> list) throws UnknownHostException, IOException, InterruptedException {
43
+ BufferedWriter wr = null;
44
+ StringBuilder rp = null;
45
+ String message = "";
46
+ try {
47
+ message = Util.TaoMsg(code, list, ss);
48
+ Thread.sleep(3 * 1000);
49
+ wr = new BufferedWriter(new OutputStreamWriter(ss.getSocket().getOutputStream(), "UTF8"));
50
+ wr.write(message);
51
+ wr.flush();
52
+
53
+ rp = new StringBuilder("");
54
+ if (ss.getSocket().isConnected()) {
55
+ Thread.sleep(3 * 1000);
56
+ InputStream instr = ss.getSocket().getInputStream();
57
+ int buffSize = ss.getSocket().getReceiveBufferSize();
58
+ if (buffSize > 0) {
59
+ byte[] buff = new byte[buffSize];
60
+ int ret_read = instr.read(buff);
61
+ if (ret_read != -1) {
62
+ rp.append(new String(buff, 0, ret_read));
63
+ }
64
+ }
65
+ }
66
+ return rp;
67
+ } catch (Exception e) {
68
+ System.out.println(e.getMessage());
69
+
70
+ // if (e.getMessage().contains("socket write error")) {
71
+ // }
72
+ return null;
73
+ }
74
+
75
+ }
76
+ }
src/main/java/tqtk/XuLy/login/LayThongTinSession.java ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package tqtk.XuLy.login;
7
+
8
+ import java.io.BufferedReader;
9
+ import java.io.BufferedWriter;
10
+ import java.io.DataOutputStream;
11
+ import java.io.IOException;
12
+ import java.io.InputStream;
13
+ import java.io.InputStreamReader;
14
+ import java.io.OutputStreamWriter;
15
+ import tqtk.Utils.Util;
16
+ import java.net.CookieManager;
17
+ import java.net.HttpURLConnection;
18
+ import java.net.InetAddress;
19
+ import java.net.InetSocketAddress;
20
+ import java.net.Socket;
21
+ import java.net.UnknownHostException;
22
+ import java.util.ArrayList;
23
+ import java.util.List;
24
+ import java.util.logging.Level;
25
+ import java.util.logging.Logger;
26
+ import tqtk.Entity.SessionEntity;
27
+ import static tqtk.Tqtk.sendMessage;
28
+
29
+ /**
30
+ *
31
+ * @author Alex
32
+ */
33
+ public class LayThongTinSession {
34
+
35
+ private static List<SessionEntity> ListSession = new ArrayList<>();
36
+
37
+ public static synchronized SessionEntity getSessionEntity(String user, String pass, int id, Util u) throws Exception {
38
+ // login va lay thong tin session
39
+ u.setCookie(u.msCookieManager);
40
+ // String html = u.test2("http://api.sengokugifu.jp/home/login/login?Uname=32572016266&userid=32572016266&GameId=2001&ServerId=s17&Time=1673956339&al=1&from=mixi&siteurl=&Sign=1da179d1f5c90a6dfcf76f8a5a15139c");
41
+ String html = u.test2("http://api.sengokugifu.jp/home/login/login?Uname=32572016266&userid=32572016266&GameId=2001&ServerId=s17&Time=1674435608&al=1&from=mixi&siteurl=&Sign=26e75a5bcb87e01104bef31dbe32d0ce");
42
+
43
+ html = u.test1(html);
44
+
45
+ String ip = Util.getInfoSocket(html, "ip");
46
+ String ports = Util.getInfoSocket(html, "ports");
47
+ String sessionKey = Util.getInfoSocket(html, "sessionKey");
48
+ String userID = Util.getInfoSocket(html, "userID");
49
+ SessionEntity ss = new SessionEntity();
50
+ ss.setIp(ip);
51
+ ss.setPorts(Integer.parseInt(ports));
52
+ ss.setSessionKey(sessionKey);
53
+ ss.setUserId(userID);
54
+ ss.setStringName(user);
55
+ u.setCookie(null);
56
+ return ss;
57
+ }
58
+
59
+ public static List<SessionEntity> getListSession() {
60
+ return ListSession;
61
+ }
62
+
63
+ }
src/main/java/tqtk/exception/JsonException.java ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package tqtk.exception;
7
+
8
+ /**
9
+ *
10
+ * @author Alex
11
+ */
12
+ public class JsonException extends Exception{
13
+
14
+ }