Advertisement
Guest User

Untitled

a guest
Jul 11th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.81 KB | None | 0 0
  1. /* */ package pl.zyczu.minecraft.launcher;
  2. /* */
  3. /* */ import java.io.BufferedInputStream;
  4. /* */ import java.io.BufferedReader;
  5. /* */ import java.io.DataInputStream;
  6. /* */ import java.io.File;
  7. /* */ import java.io.FileInputStream;
  8. /* */ import java.io.FileOutputStream;
  9. /* */ import java.io.InputStream;
  10. /* */ import java.io.InputStreamReader;
  11. /* */ import java.io.OutputStream;
  12. /* */ import java.net.URL;
  13. /* */ import java.net.URLConnection;
  14. /* */ import java.util.Iterator;
  15. /* */ import java.util.LinkedList;
  16. /* */ import java.util.Random;
  17. /* */ import javax.crypto.Cipher;
  18. /* */ import javax.crypto.CipherInputStream;
  19. /* */ import javax.crypto.SecretKey;
  20. /* */ import javax.crypto.SecretKeyFactory;
  21. /* */ import javax.crypto.spec.PBEKeySpec;
  22. /* */ import javax.crypto.spec.PBEParameterSpec;
  23. /* */ import javax.swing.JOptionPane;
  24. /* */ import pl.zyczu.minecraft.launcher.repo.RepositoryManager;
  25. /* */ import pl.zyczu.util.Filesystem;
  26. /* */ import pl.zyczu.util.Logger;
  27. /* */ import pl.zyczu.util.SHA1;
  28. /* */
  29. /* */ public class NetworkService
  30. /* */ implements Runnable
  31. /* */ {
  32. /* */ private Minecraft mc;
  33. /* 36 */ public static ServiceStatus status = ServiceStatus.UNKNOWN;
  34. /* 37 */ public static String statusFile = null;
  35. /* 38 */ public static Thread subThread = null;
  36. /* */
  37. /* */ public NetworkService(Minecraft m) {
  38. /* 41 */ this.mc = m;
  39. /* */ }
  40. /* */
  41. /* */ public void run()
  42. /* */ {
  43. /* */ try
  44. /* */ {
  45. /* 48 */ subThread = new Thread(new Runnable()
  46. /* */ {
  47. /* */ public void run() {
  48. /* */ try {
  49. /* 52 */ LinkedList doPobrania = new LinkedList();
  50. /* */
  51. /* 54 */ NetworkService.status = ServiceStatus.CONNECTING;
  52. /* */
  53. /* 56 */ Minecraft.log.log("NetworkService", "Trwa aktualizowanie repozytoriów");
  54. /* 57 */ URL alt = new URL("http://l7.minecraft.zyczu.pl/update.php?version=10");
  55. /* 58 */ URLConnection conn = alt.openConnection();
  56. /* 59 */ NetworkService.status = ServiceStatus.SYNCING;
  57. /* 60 */ BufferedReader flrd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  58. /* */
  59. /* 62 */ boolean ok = false;
  60. /* */ String line;
  61. /* 63 */ while ((line = flrd.readLine()) != null)
  62. /* */ {
  63. /* */ String line;
  64. /* 64 */ if (line.contains("LISONHAX_OUTDATED_LAUNCHER")) {
  65. /* 65 */ JOptionPane.showMessageDialog(null, "Masz starą wersję launchera! Ściągnij najnowszy launcher ze strony: minecraft.zyczu.pl");
  66. /* 66 */ System.exit(0);
  67. /* 67 */ } else if (line.contains("OKOKOK")) {
  68. /* 68 */ ok = true; } else {
  69. /* 69 */ if (line.length() <= 2)
  70. /* */ continue;
  71. /* 71 */ if (ok) {
  72. /* */ try {
  73. /* 73 */ String[] n = line.split("\\|");
  74. /* 74 */ File f = new File(Minecraft.getWorkingDirectory(), "repo/" + n[0]);
  75. /* 75 */ if ((f.exists()) && (SHA1.getFileHash(f).equals(n[1]))) continue;
  76. /* 76 */ doPobrania.add(n[0]);
  77. /* */ }
  78. /* */ catch (Exception e) {
  79. /* 79 */ JOptionPane.showMessageDialog(null, "Bład serwera: " + line);
  80. /* 80 */ System.exit(1);
  81. /* */ }
  82. /* */ }
  83. /* */ else {
  84. /* 84 */ JOptionPane.showMessageDialog(null, "Bład serwera: " + line);
  85. /* 85 */ System.exit(0);
  86. /* */ }
  87. /* */ }
  88. /* */ }
  89. /* 88 */ flrd.close();
  90. /* */
  91. /* 90 */ if (doPobrania.size() > 0) {
  92. /* 91 */ NetworkService.status = ServiceStatus.DOWNLOADING;
  93. /* */
  94. /* 93 */ Iterator it = doPobrania.iterator();
  95. /* 94 */ while (it.hasNext()) {
  96. /* 95 */ String pliczek = (String)it.next();
  97. /* 96 */ Minecraft.log.log("Download", "Pobieranie pliku " + pliczek);
  98. /* 97 */ NetworkService.statusFile = pliczek;
  99. /* 98 */ URL url = new URL("http://l7.minecraft.zyczu.pl/" + pliczek);
  100. /* 99 */ URLConnection cn = url.openConnection();
  101. /* 100 */ InputStream fb = cn.getInputStream();
  102. /* 101 */ OutputStream out = new FileOutputStream(new File(Minecraft.getWorkingDirectory(), "repo/" + pliczek));
  103. /* 102 */ byte[] buf = new byte[1024];
  104. /* 103 */ int przeczytano = -1;
  105. /* 104 */ while ((przeczytano = fb.read(buf)) != -1) {
  106. /* 105 */ out.write(buf, 0, przeczytano);
  107. /* */ }
  108. /* 107 */ fb.close();
  109. /* 108 */ out.close();
  110. /* */ }
  111. /* */ } else {
  112. /* 111 */ Minecraft.log.log("NetworkService", "Repozytoria są aktualne");
  113. /* */ }
  114. /* */ } catch (Exception e) {
  115. /* 114 */ Minecraft.log.severe("Straszny błąd przy aktualizacji!");
  116. /* 115 */ e.printStackTrace();
  117. /* */ }
  118. /* */ }
  119. /* */ });
  120. /* 119 */ subThread.start();
  121. /* 120 */ while (subThread.isAlive()) {
  122. /* 121 */ Thread.sleep(20L);
  123. /* */ }
  124. /* */
  125. /* 124 */ status = ServiceStatus.INTERPRETING;
  126. /* */
  127. /* 126 */ long start = System.currentTimeMillis();
  128. /* */
  129. /* 128 */ RepositoryManager repositoryManager = RepositoryManager.getInstance();
  130. /* 129 */ repositoryManager.setup(Minecraft.getWorkingDirectory());
  131. /* */
  132. /* 131 */ long stop = System.currentTimeMillis();
  133. /* */
  134. /* 133 */ Minecraft.log.log("Debug", "Analiza repozytorium zajęła " + (stop - start) + " ms");
  135. /* */
  136. /* 135 */ if (Properties.getInstance().get("firstrun", "true").equalsIgnoreCase("true")) {
  137. /* 136 */ status = ServiceStatus.FIRSTRUN_INIT;
  138. /* 137 */ Properties.getInstance().set("firstrun", "false");
  139. /* */
  140. /* 139 */ File minecraftLauncherByZyczu = new File(Minecraft.getWorkingDirectory().getParent(), ".zyczulauncher");
  141. /* 140 */ File minecraftSP_exe = new File(Minecraft.getWorkingDirectory().getParent(), ".minecraft");
  142. /* */
  143. /* 142 */ if (minecraftLauncherByZyczu.exists()) {
  144. /* 143 */ status = ServiceStatus.UPDATE_ZYCZU;
  145. /* 144 */ Thread.sleep(500L);
  146. /* */ try {
  147. /* 146 */ File oldConfig = new File(minecraftLauncherByZyczu, "default.properties");
  148. /* 147 */ java.util.Properties legacyProperties = new java.util.Properties();
  149. /* 148 */ legacyProperties.load(new BufferedInputStream(new FileInputStream(oldConfig)));
  150. /* 149 */ if (!legacyProperties.getProperty("quitbtn", "tak").equalsIgnoreCase("tak")) {
  151. /* 150 */ Properties.getInstance().set("wyjdz", "false");
  152. /* */ }
  153. /* 152 */ legacyProperties = null;
  154. /* */ } catch (Exception e) {
  155. /* 154 */ Minecraft.log.warning("Nie udało się przywrócić ustawień przycisku Wyjdź z Gry!");
  156. /* */ }
  157. /* */ try {
  158. /* 157 */ String password = "passwordfile";
  159. /* 158 */ Random random = new Random(43287234L);
  160. /* 159 */ byte[] salt = new byte[8];
  161. /* 160 */ random.nextBytes(salt);
  162. /* 161 */ PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
  163. /* 162 */ SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec(password.toCharArray()));
  164. /* 163 */ Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
  165. /* 164 */ cipher.init(2, pbeKey, pbeParamSpec);
  166. /* 165 */ File lastLogin = new File(minecraftLauncherByZyczu, "lastlogin");
  167. /* */ DataInputStream dis;
  168. /* */ DataInputStream dis;
  169. /* 167 */ if (cipher != null)
  170. /* 168 */ dis = new DataInputStream(new CipherInputStream(new FileInputStream(lastLogin), cipher));
  171. /* */ else {
  172. /* 170 */ dis = new DataInputStream(new FileInputStream(lastLogin));
  173. /* */ }
  174. /* 172 */ Properties.getInstance().set("nick", dis.readUTF());
  175. /* 173 */ dis.close();
  176. /* */ } catch (Exception e) {
  177. /* 175 */ Minecraft.log.warning("Nie udało się przywrócić nicku z MinecraftLauncherByZyczu_v3_2_0.jar");
  178. /* */ }
  179. /* 177 */ Filesystem.removeDirectory(minecraftLauncherByZyczu);
  180. /* 178 */ } else if (minecraftSP_exe.exists()) {
  181. /* 179 */ status = ServiceStatus.UPDATE_MINECRAFTSP_EXE;
  182. /* 180 */ Thread.sleep(500L);
  183. /* */ try {
  184. /* 182 */ String password = "passwordfile";
  185. /* 183 */ Random random = new Random(43287234L);
  186. /* 184 */ byte[] salt = new byte[8];
  187. /* 185 */ random.nextBytes(salt);
  188. /* 186 */ PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
  189. /* 187 */ SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec(password.toCharArray()));
  190. /* 188 */ Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
  191. /* 189 */ cipher.init(2, pbeKey, pbeParamSpec);
  192. /* 190 */ File lastLogin = new File(minecraftSP_exe, "lastlogin");
  193. /* */ DataInputStream dis;
  194. /* */ DataInputStream dis;
  195. /* 192 */ if (cipher != null)
  196. /* 193 */ dis = new DataInputStream(new CipherInputStream(new FileInputStream(lastLogin), cipher));
  197. /* */ else {
  198. /* 195 */ dis = new DataInputStream(new FileInputStream(lastLogin));
  199. /* */ }
  200. /* 197 */ Properties.getInstance().set("nick", dis.readUTF());
  201. /* 198 */ dis.close();
  202. /* 199 */ lastLogin.delete();
  203. /* */ } catch (Exception e) {
  204. /* 201 */ Minecraft.log.warning("Nie udało się przywrócić nicku z MinecraftSP.exe");
  205. /* */ }
  206. /* */ }
  207. /* */
  208. /* */ }
  209. /* */
  210. /* 207 */ status = ServiceStatus.READY;
  211. /* */ }
  212. /* */ catch (Exception e) {
  213. /* 210 */ Minecraft.log.log("NetworkService", "Wystąpił bład " + e.toString());
  214. /* 211 */ e.printStackTrace();
  215. /* */ }
  216. /* */ }
  217. /* */ }
  218.  
  219. /* Location: C:\Users\vilain\Desktop\gowno\zyczu-mc.jar
  220. * Qualified Name: pl.zyczu.minecraft.launcher.NetworkService
  221. * JD-Core Version: 0.6.0
  222. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement