PageRenderTime 26ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/sources/minecraft/net/minecraft/src/GuiZombieWorldSlot.java

https://gitlab.com/BGCX261/zombie-craft-svn-to-git
Java | 274 lines | 201 code | 30 blank | 43 comment | 27 complexity | 67f78459bdf2cc93eb301561e5d42d95 MD5 | raw file
  1. package net.minecraft.src;
  2. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
  3. // Jad home page: http://www.kpdus.com/jad.html
  4. // Decompiler options: packimports(3) braces deadcode
  5. import javax.crypto.*;
  6. import javax.crypto.spec.*;
  7. import java.security.spec.*;
  8. import java.io.*;
  9. import java.util.*;
  10. import java.util.zip.*;
  11. import java.net.URL;
  12. import java.security.*;
  13. import net.minecraft.client.Minecraft;
  14. import java.security.MessageDigest;
  15. class GuiZombieWorldSlot extends GuiWorldSlot
  16. {
  17. public GuiZombieWorldSlot(GuiSelectWorld guiselectworld)
  18. {
  19. super(guiselectworld);
  20. selectWorldGui = guiselectworld;
  21. }
  22. static public boolean deleteDirectory(File path) {
  23. if(path.exists() && path.isDirectory()) {
  24. File[] files = path.listFiles();
  25. for(int i=0; i<files.length; i++) {
  26. if(files[i].isDirectory()) {
  27. deleteDirectory(files[i]);
  28. }
  29. else {
  30. files[i].delete();
  31. }
  32. }
  33. return( path.delete() );
  34. } else {
  35. return false;
  36. }
  37. }
  38. protected void func_22247_a(int i, boolean flag)
  39. {
  40. GuiSelectWorld.func_22089_a(field_22266_a, i);
  41. boolean flag1 = GuiSelectWorld.func_22086_b(field_22266_a) >= 0 && GuiSelectWorld.func_22086_b(field_22266_a) < func_22249_a();
  42. if(flag && flag1)
  43. {
  44. // Create encrypter/decrypter class
  45. zz encrypter = new zz("Zombiecraft is tasty!");
  46. // Encrypt
  47. //String encrypted = encrypter.encrypt("Don't tell anybody!");
  48. //Strings to encrypt
  49. //System.out.println(encrypter.encrypt("zcmaps"));
  50. //System.out.println(encrypter.encrypt("zctemp"));
  51. //System.out.println(encrypter.encrypt(".zip"));
  52. //System.out.println(encrypter.encrypt("region"));
  53. //System.out.println(encrypter.encrypt("r.0.0.mcr"));
  54. //System.out.println(encrypter.encrypt("http://modzilla.zymichost.com/store/haspaid.php?user="));
  55. //System.out.println(encrypter.encrypt("&mapid="));
  56. //System.out.println(encrypter.encrypt("&md5="));
  57. //Encrypted results
  58. //xToToq+1sng=
  59. //rKRSisSMbCk=
  60. //AvnvRdcU3oU=
  61. //be5RyWQXzcM=
  62. //aTm7Jt3UYMdB9O1sF4IfgQ==
  63. //Png6B83+j+VGJz6H3AxK25wpR4rQde5Uzynd1mtqxW7BWQ7LHW29TUvjgCry0uDj5/Ohs8xLmAY=
  64. //Xp6gmzWvEFk=
  65. //BCUegjYEKn0=
  66. // Decrypt
  67. //encrypter.decrypt("BCUegjYEKn0=")
  68. String zipname = ((ZombieSaveRecord)selectWorldGui.func_22090_a(selectWorldGui).get(i)).getZipname();
  69. File file3 = new File(Minecraft.getMinecraftDir(), encrypter.decrypt("xToToq+1sng="));
  70. File file2 = new File(file3, zipname);
  71. deleteDirectory(new File(file3, zipname.substring(0,zipname.lastIndexOf(encrypter.decrypt("AvnvRdcU3oU=")))));
  72. File file = new File(Minecraft.getMinecraftDir(), encrypter.decrypt("rKRSisSMbCk="));
  73. File unzipDir = new File(file, zipname.substring(0,zipname.lastIndexOf(encrypter.decrypt("AvnvRdcU3oU="))));
  74. recursiveUnzip(file2,unzipDir);
  75. try
  76. {
  77. File mapFile = new File(new File(unzipDir,encrypter.decrypt("be5RyWQXzcM=")),encrypter.decrypt("aTm7Jt3UYMdB9O1sF4IfgQ=="));
  78. InputStream is = new FileInputStream(mapFile);
  79. long length = mapFile.length();
  80. //System.out.println(length);
  81. if (length > Integer.MAX_VALUE) {
  82. System.out.println("File is too large");
  83. return;
  84. }
  85. byte[] bytes = new byte[(int)length];
  86. int offset = 0;
  87. int numRead = 0;
  88. while (offset < bytes.length
  89. && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
  90. offset += numRead;
  91. }
  92. if (offset < bytes.length) {
  93. throw new IOException("Could not completely read file "+mapFile.getName());
  94. }
  95. //System.out.println(bytes[bytes.length-1]);
  96. is.close();
  97. try {
  98. } catch (Exception e) {
  99. }
  100. try
  101. {
  102. String md5 = getMD5Checksum(file2);
  103. String md5list[] = { "e756fb7619439c7e89f74e134fa79b10", "528abaa8d8cd03a3fe8b1735e4dd592e", "" };
  104. for (i = 0; i < md5list.length; i++) {
  105. if (md5.equals(md5list[i])) {
  106. selectZombieWorld(zipname.substring(0,zipname.lastIndexOf(encrypter.decrypt("AvnvRdcU3oU="))));
  107. return;
  108. }
  109. }
  110. URL url = new URL((new StringBuilder()).append(encrypter.decrypt("Png6B83+j+VGJz6H3AxK25wpR4rQde5Uzynd1mtqxW7BWQ7LHW29TUvjgCry0uDj5/Ohs8xLmAY=")).append(ModLoader.getMinecraftInstance().session.username).append(encrypter.decrypt("Xp6gmzWvEFk=")).append(bytes[bytes.length-1]).append(encrypter.decrypt("BCUegjYEKn0=")).append(md5).toString());
  111. //System.out.println(url);
  112. BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openStream()));
  113. String s1 = bufferedreader.readLine();
  114. bufferedreader.close();
  115. if(s1.equals("true"))
  116. {
  117. selectZombieWorld(zipname.substring(0,zipname.lastIndexOf(encrypter.decrypt("AvnvRdcU3oU="))));
  118. //Premium
  119. } else
  120. {
  121. Minecraft mc = ModLoader.getMinecraftInstance();
  122. mc.displayGuiScreen(new GuiNotPremium(selectWorldGui));
  123. //Not premium
  124. }
  125. }
  126. catch(Exception exception)
  127. {
  128. exception.printStackTrace();
  129. }
  130. } catch (Exception ex) { ex.printStackTrace(); }
  131. }
  132. }
  133. public void selectZombieWorld(String s)
  134. {
  135. Minecraft mc = ModLoader.getMinecraftInstance();
  136. mc.displayGuiScreen(null);
  137. if(selected)
  138. {
  139. return;
  140. }
  141. selected = true;
  142. mc.playerController = new PlayerControllerSP(mc);
  143. //System.out.println(s);
  144. mc.startWorld(s, s, 0L);
  145. mc.displayGuiScreen(null);
  146. }
  147. protected void func_22242_a(int i, int j, int k, int l, Tessellator tessellator)
  148. {
  149. ZombieSaveRecord zombiesaverecord = (ZombieSaveRecord)selectWorldGui.func_22090_a(selectWorldGui).get(i);
  150. selectWorldGui.drawString(selectWorldGui.fontRenderer, zombiesaverecord.getText(), j + 2, k + 1, 0xffffff);
  151. selectWorldGui.drawString(selectWorldGui.fontRenderer, zombiesaverecord.getSubText(), j + 2, k + 12, 0x808080);
  152. selectWorldGui.drawString(selectWorldGui.fontRenderer, zombiesaverecord.getSubText2(), j + 2, k + 12 + 10, 0x808080);
  153. }
  154. private final static int BUFFER = 10241024;
  155. private void cleanUp(InputStream in) throws Exception{
  156. in.close();
  157. }
  158. private void cleanUp(OutputStream out) throws Exception{
  159. out.flush();
  160. out.close();
  161. }
  162. public static byte[] createChecksum(File file) throws Exception
  163. {
  164. InputStream fis = new FileInputStream(file);
  165. byte[] buffer = new byte[1024];
  166. MessageDigest complete = MessageDigest.getInstance("MD5");
  167. int numRead;
  168. do {
  169. numRead = fis.read(buffer);
  170. if (numRead > 0) {
  171. complete.update(buffer, 0, numRead);
  172. }
  173. } while (numRead != -1);
  174. fis.close();
  175. return complete.digest();
  176. }
  177. // see this How-to for a faster way to convert
  178. // a byte array to a HEX string
  179. public static String getMD5Checksum(File file) throws Exception {
  180. byte[] b = createChecksum(file);
  181. String result = "";
  182. for (int i=0; i < b.length; i++) {
  183. result +=
  184. Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 );
  185. }
  186. return result;
  187. }
  188. public File recursiveUnzip(File inFile, File outFolder)
  189. {
  190. try
  191. {
  192. createFolder(outFolder, true);
  193. BufferedOutputStream out = null;
  194. ZipInputStream in = new ZipInputStream(new BufferedInputStream(new FileInputStream(inFile)));
  195. ZipEntry entry;
  196. while((entry = in.getNextEntry()) != null)
  197. {
  198. //System.out.println("Extracting: " + entry);
  199. int count;
  200. byte data[] = new byte[BUFFER];
  201. // write the files to the disk
  202. File newFile = new File(outFolder.getPath() + "/" + entry.getName());
  203. Stack<File> pathStack = new Stack<File>();
  204. File newNevigate = newFile.getParentFile();
  205. while(newNevigate != null){
  206. pathStack.push(newNevigate);
  207. newNevigate = newNevigate.getParentFile();
  208. }
  209. //create all the path directories
  210. while(!pathStack.isEmpty()){
  211. File createFile = pathStack.pop();
  212. createFolder(createFile, true);
  213. }
  214. if(!entry.isDirectory()){
  215. out = new BufferedOutputStream(
  216. new FileOutputStream(newFile),BUFFER);
  217. while ((count = in.read(data,0,BUFFER)) != -1){
  218. out.write(data,0,count);
  219. }
  220. cleanUp(out);
  221. //recursively unzip files
  222. //if(entry.getName().toLowerCase().endsWith(".zip")){
  223. // String zipFilePath = outFolder.getPath() + "/" + entry.getName();
  224. // this.recursiveUnzip(new File(zipFilePath), new File(zipFilePath.substring(0, zipFilePath.length()-4)));
  225. //}
  226. }else{
  227. //this.createFolder(new File(outFolder,entry.getName()), true);
  228. }
  229. }
  230. cleanUp(in);
  231. return outFolder;
  232. }catch(Exception e){
  233. e.printStackTrace();
  234. return inFile;
  235. }
  236. }
  237. private void createFolder(File folder, boolean isDirectory){
  238. if(isDirectory){
  239. folder.mkdir();
  240. }
  241. }
  242. private GuiSelectWorld selectWorldGui;
  243. private boolean selected;
  244. }