Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* */ package pl.zyczu.minecraft.launcher;
- /* */
- /* */ import java.io.BufferedInputStream;
- /* */ import java.io.BufferedReader;
- /* */ import java.io.DataInputStream;
- /* */ import java.io.File;
- /* */ import java.io.FileInputStream;
- /* */ import java.io.FileOutputStream;
- /* */ import java.io.InputStream;
- /* */ import java.io.InputStreamReader;
- /* */ import java.io.OutputStream;
- /* */ import java.net.URL;
- /* */ import java.net.URLConnection;
- /* */ import java.util.Iterator;
- /* */ import java.util.LinkedList;
- /* */ import java.util.Random;
- /* */ import javax.crypto.Cipher;
- /* */ import javax.crypto.CipherInputStream;
- /* */ import javax.crypto.SecretKey;
- /* */ import javax.crypto.SecretKeyFactory;
- /* */ import javax.crypto.spec.PBEKeySpec;
- /* */ import javax.crypto.spec.PBEParameterSpec;
- /* */ import javax.swing.JOptionPane;
- /* */ import pl.zyczu.minecraft.launcher.repo.RepositoryManager;
- /* */ import pl.zyczu.util.Filesystem;
- /* */ import pl.zyczu.util.Logger;
- /* */ import pl.zyczu.util.SHA1;
- /* */
- /* */ public class NetworkService
- /* */ implements Runnable
- /* */ {
- /* */ private Minecraft mc;
- /* 36 */ public static ServiceStatus status = ServiceStatus.UNKNOWN;
- /* 37 */ public static String statusFile = null;
- /* 38 */ public static Thread subThread = null;
- /* */
- /* */ public NetworkService(Minecraft m) {
- /* 41 */ this.mc = m;
- /* */ }
- /* */
- /* */ public void run()
- /* */ {
- /* */ try
- /* */ {
- /* 48 */ subThread = new Thread(new Runnable()
- /* */ {
- /* */ public void run() {
- /* */ try {
- /* 52 */ LinkedList doPobrania = new LinkedList();
- /* */
- /* 54 */ NetworkService.status = ServiceStatus.CONNECTING;
- /* */
- /* 56 */ Minecraft.log.log("NetworkService", "Trwa aktualizowanie repozytoriów");
- /* 57 */ URL alt = new URL("http://l7.minecraft.zyczu.pl/update.php?version=10");
- /* 58 */ URLConnection conn = alt.openConnection();
- /* 59 */ NetworkService.status = ServiceStatus.SYNCING;
- /* 60 */ BufferedReader flrd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- /* */
- /* 62 */ boolean ok = false;
- /* */ String line;
- /* 63 */ while ((line = flrd.readLine()) != null)
- /* */ {
- /* */ String line;
- /* 64 */ if (line.contains("LISONHAX_OUTDATED_LAUNCHER")) {
- /* 65 */ JOptionPane.showMessageDialog(null, "Masz starą wersję launchera! Ściągnij najnowszy launcher ze strony: minecraft.zyczu.pl");
- /* 66 */ System.exit(0);
- /* 67 */ } else if (line.contains("OKOKOK")) {
- /* 68 */ ok = true; } else {
- /* 69 */ if (line.length() <= 2)
- /* */ continue;
- /* 71 */ if (ok) {
- /* */ try {
- /* 73 */ String[] n = line.split("\\|");
- /* 74 */ File f = new File(Minecraft.getWorkingDirectory(), "repo/" + n[0]);
- /* 75 */ if ((f.exists()) && (SHA1.getFileHash(f).equals(n[1]))) continue;
- /* 76 */ doPobrania.add(n[0]);
- /* */ }
- /* */ catch (Exception e) {
- /* 79 */ JOptionPane.showMessageDialog(null, "Bład serwera: " + line);
- /* 80 */ System.exit(1);
- /* */ }
- /* */ }
- /* */ else {
- /* 84 */ JOptionPane.showMessageDialog(null, "Bład serwera: " + line);
- /* 85 */ System.exit(0);
- /* */ }
- /* */ }
- /* */ }
- /* 88 */ flrd.close();
- /* */
- /* 90 */ if (doPobrania.size() > 0) {
- /* 91 */ NetworkService.status = ServiceStatus.DOWNLOADING;
- /* */
- /* 93 */ Iterator it = doPobrania.iterator();
- /* 94 */ while (it.hasNext()) {
- /* 95 */ String pliczek = (String)it.next();
- /* 96 */ Minecraft.log.log("Download", "Pobieranie pliku " + pliczek);
- /* 97 */ NetworkService.statusFile = pliczek;
- /* 98 */ URL url = new URL("http://l7.minecraft.zyczu.pl/" + pliczek);
- /* 99 */ URLConnection cn = url.openConnection();
- /* 100 */ InputStream fb = cn.getInputStream();
- /* 101 */ OutputStream out = new FileOutputStream(new File(Minecraft.getWorkingDirectory(), "repo/" + pliczek));
- /* 102 */ byte[] buf = new byte[1024];
- /* 103 */ int przeczytano = -1;
- /* 104 */ while ((przeczytano = fb.read(buf)) != -1) {
- /* 105 */ out.write(buf, 0, przeczytano);
- /* */ }
- /* 107 */ fb.close();
- /* 108 */ out.close();
- /* */ }
- /* */ } else {
- /* 111 */ Minecraft.log.log("NetworkService", "Repozytoria są aktualne");
- /* */ }
- /* */ } catch (Exception e) {
- /* 114 */ Minecraft.log.severe("Straszny błąd przy aktualizacji!");
- /* 115 */ e.printStackTrace();
- /* */ }
- /* */ }
- /* */ });
- /* 119 */ subThread.start();
- /* 120 */ while (subThread.isAlive()) {
- /* 121 */ Thread.sleep(20L);
- /* */ }
- /* */
- /* 124 */ status = ServiceStatus.INTERPRETING;
- /* */
- /* 126 */ long start = System.currentTimeMillis();
- /* */
- /* 128 */ RepositoryManager repositoryManager = RepositoryManager.getInstance();
- /* 129 */ repositoryManager.setup(Minecraft.getWorkingDirectory());
- /* */
- /* 131 */ long stop = System.currentTimeMillis();
- /* */
- /* 133 */ Minecraft.log.log("Debug", "Analiza repozytorium zajęła " + (stop - start) + " ms");
- /* */
- /* 135 */ if (Properties.getInstance().get("firstrun", "true").equalsIgnoreCase("true")) {
- /* 136 */ status = ServiceStatus.FIRSTRUN_INIT;
- /* 137 */ Properties.getInstance().set("firstrun", "false");
- /* */
- /* 139 */ File minecraftLauncherByZyczu = new File(Minecraft.getWorkingDirectory().getParent(), ".zyczulauncher");
- /* 140 */ File minecraftSP_exe = new File(Minecraft.getWorkingDirectory().getParent(), ".minecraft");
- /* */
- /* 142 */ if (minecraftLauncherByZyczu.exists()) {
- /* 143 */ status = ServiceStatus.UPDATE_ZYCZU;
- /* 144 */ Thread.sleep(500L);
- /* */ try {
- /* 146 */ File oldConfig = new File(minecraftLauncherByZyczu, "default.properties");
- /* 147 */ java.util.Properties legacyProperties = new java.util.Properties();
- /* 148 */ legacyProperties.load(new BufferedInputStream(new FileInputStream(oldConfig)));
- /* 149 */ if (!legacyProperties.getProperty("quitbtn", "tak").equalsIgnoreCase("tak")) {
- /* 150 */ Properties.getInstance().set("wyjdz", "false");
- /* */ }
- /* 152 */ legacyProperties = null;
- /* */ } catch (Exception e) {
- /* 154 */ Minecraft.log.warning("Nie udało się przywrócić ustawień przycisku Wyjdź z Gry!");
- /* */ }
- /* */ try {
- /* 157 */ String password = "passwordfile";
- /* 158 */ Random random = new Random(43287234L);
- /* 159 */ byte[] salt = new byte[8];
- /* 160 */ random.nextBytes(salt);
- /* 161 */ PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
- /* 162 */ SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec(password.toCharArray()));
- /* 163 */ Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
- /* 164 */ cipher.init(2, pbeKey, pbeParamSpec);
- /* 165 */ File lastLogin = new File(minecraftLauncherByZyczu, "lastlogin");
- /* */ DataInputStream dis;
- /* */ DataInputStream dis;
- /* 167 */ if (cipher != null)
- /* 168 */ dis = new DataInputStream(new CipherInputStream(new FileInputStream(lastLogin), cipher));
- /* */ else {
- /* 170 */ dis = new DataInputStream(new FileInputStream(lastLogin));
- /* */ }
- /* 172 */ Properties.getInstance().set("nick", dis.readUTF());
- /* 173 */ dis.close();
- /* */ } catch (Exception e) {
- /* 175 */ Minecraft.log.warning("Nie udało się przywrócić nicku z MinecraftLauncherByZyczu_v3_2_0.jar");
- /* */ }
- /* 177 */ Filesystem.removeDirectory(minecraftLauncherByZyczu);
- /* 178 */ } else if (minecraftSP_exe.exists()) {
- /* 179 */ status = ServiceStatus.UPDATE_MINECRAFTSP_EXE;
- /* 180 */ Thread.sleep(500L);
- /* */ try {
- /* 182 */ String password = "passwordfile";
- /* 183 */ Random random = new Random(43287234L);
- /* 184 */ byte[] salt = new byte[8];
- /* 185 */ random.nextBytes(salt);
- /* 186 */ PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
- /* 187 */ SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec(password.toCharArray()));
- /* 188 */ Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
- /* 189 */ cipher.init(2, pbeKey, pbeParamSpec);
- /* 190 */ File lastLogin = new File(minecraftSP_exe, "lastlogin");
- /* */ DataInputStream dis;
- /* */ DataInputStream dis;
- /* 192 */ if (cipher != null)
- /* 193 */ dis = new DataInputStream(new CipherInputStream(new FileInputStream(lastLogin), cipher));
- /* */ else {
- /* 195 */ dis = new DataInputStream(new FileInputStream(lastLogin));
- /* */ }
- /* 197 */ Properties.getInstance().set("nick", dis.readUTF());
- /* 198 */ dis.close();
- /* 199 */ lastLogin.delete();
- /* */ } catch (Exception e) {
- /* 201 */ Minecraft.log.warning("Nie udało się przywrócić nicku z MinecraftSP.exe");
- /* */ }
- /* */ }
- /* */
- /* */ }
- /* */
- /* 207 */ status = ServiceStatus.READY;
- /* */ }
- /* */ catch (Exception e) {
- /* 210 */ Minecraft.log.log("NetworkService", "Wystąpił bład " + e.toString());
- /* 211 */ e.printStackTrace();
- /* */ }
- /* */ }
- /* */ }
- /* Location: C:\Users\vilain\Desktop\gowno\zyczu-mc.jar
- * Qualified Name: pl.zyczu.minecraft.launcher.NetworkService
- * JD-Core Version: 0.6.0
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement