Update Client

0

Witajcie mam tu Updater clienta , przy kompilacji tego kodu mam błędy
http://imageshack.us/photo/my-images/69/clientkb.png
miałem ich ponad 32 które udało mi się zapobiec a w wyniku tego pojawiły sie nowe te co widać na obrazku
Czy ktoś może mi w tym pomóc

package Mazek27;

import java.awt.Color;
import java.awt.Container;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Toolkit;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.security.CodeSource;
import java.security.ProtectionDomain;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.text.Document;

public class Updater
{
  public JFrame frmUxanCraftUpdater;
  public static JTextPane txtpnDd = new JTextPane();
  public static JProgressBar progressBar = new JProgressBar();
  public static JScrollPane scrollPane = new JScrollPane();
  public static final String sep = System.getProperty("file.separator");
  public static String MCFolder;
  public static String app_path = new File("").getAbsolutePath();

  public static int ver_updater_curr = 3;
  static int ver_updater_new;
  static String updater_url;
  static int ver_modpack_new;
  static String modpack_url;
  public static int step = -1;
  public static int value = 0;
  public static int count = 0;
  static Updater.newthread t;
  static Updater.forcethread t2;
  static boolean terminate = false;

  public static void main(String[] args)
  {
    EventQueue.invokeLater(new Updater$1());
  }

  public Updater()
  {
    initialize();
  }

  public static boolean removeDirectory(File directory)
  {
    if (directory == null)
      return false;
    if (!directory.exists())
      return true;
    if (!directory.isDirectory()) {
      return false;
    }
    String[] list = directory.list();

    if (list != null) {
      for (int i = 0; i < list.length; i++) {
        File entry = new File(directory, list[i]);

        if (entry.isDirectory())
        {
          if (!removeDirectory(entry)) {
            return false;
          }

        }
        else if (!entry.delete()) {
          return false;
        }
      }
    }
    return directory.delete();
  }

  private void initialize()
  {
    frmUxanCraftUpdater = new JFrame();
    frmUxanCraftUpdater.getContentPane().setIgnoreRepaint(true);
    frmUxanCraftUpdater.setIconImage(Toolkit.getDefaultToolkit().getImage(Updater.class.getResource("/resources/idiamonds.png")));
    frmUxanCraftUpdater.getContentPane().setBackground(new Color(8, 7, 7));
    frmUxanCraftUpdater.getContentPane().setForeground(new Color(8, 7, 7));
    frmUxanCraftUpdater.setForeground(Color.BLACK);
    frmUxanCraftUpdater.setTitle("UxanCraft launcher");
    frmUxanCraftUpdater.setResizable(false);
    frmUxanCraftUpdater.setBounds(100, 100, 597, 426);
    frmUxanCraftUpdater.setDefaultCloseOperation(3);
    frmUxanCraftUpdater.getContentPane().setLayout(null);

    progressBar = new JProgressBar();
    progressBar.setBounds(10, 372, 572, 16);
    frmUxanCraftUpdater.getContentPane().add(progressBar);

    JLabel lblNewLabel = new JLabel("");
    lblNewLabel.setIcon(new ImageIcon(Updater.class.getResource("/resources/1.png")));
    lblNewLabel.setBounds(35, 11, 384, 85);
    frmUxanCraftUpdater.getContentPane().add(lblNewLabel);

    JButton btnNewButton = new JButton("Aktualno\u015Bci");
    btnNewButton.addActionListener(new Updater$2(this));

    btnNewButton.setBounds(447, 124, 119, 23);
    frmUxanCraftUpdater.getContentPane().add(btnNewButton);

    JButton btnNewButton_1 = new JButton("Regulamin");
    btnNewButton_1.addActionListener(new Updater$3(this));

    btnNewButton_1.setForeground(Color.RED);
    btnNewButton_1.setBounds(447, 158, 119, 23);
    frmUxanCraftUpdater.getContentPane().add(btnNewButton_1);

    JButton btnNewButton_2 = new JButton("Forum");
    btnNewButton_2.addActionListener(new Updater$4(this));

    btnNewButton_2.setBounds(447, 192, 119, 23);
    frmUxanCraftUpdater.getContentPane().add(btnNewButton_2);

    JButton btnNewButton_3 = new JButton("Rangi VIP");
    btnNewButton_3.addActionListener(new Updater$5(this));

    btnNewButton_3.setBounds(447, 226, 119, 23);
    frmUxanCraftUpdater.getContentPane().add(btnNewButton_3);

    JLabel lblNewLabel_1 = new JLabel("t6.svoice.pl:8099");
    lblNewLabel_1.setFont(new Font("Tahoma", 0, 12));
    lblNewLabel_1.setForeground(Color.ORANGE);
    lblNewLabel_1.setBounds(455, 98, 102, 14);
    frmUxanCraftUpdater.getContentPane().add(lblNewLabel_1);

    JLabel label = new JLabel("");
    label.setIcon(new ImageIcon(Updater.class.getResource("/resources/ts3_logo.png")));
    label.setBounds(450, 8, 99, 92);
    frmUxanCraftUpdater.getContentPane().add(label);

    JButton btnNewButton_5 = new JButton("Uruchom MC");
    btnNewButton_5.setForeground(new Color(0, 102, 0));
    btnNewButton_5.addActionListener(new Updater$7(this));

    btnNewButton_5.setBounds(447, 293, 119, 23);
    frmUxanCraftUpdater.getContentPane().add(btnNewButton_5);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBackground(new Color(8, 7, 7));
    scrollPane.setBounds(21, 97, 406, 257);
    frmUxanCraftUpdater.getContentPane().add(scrollPane);

    txtpnDd = new JTextPane();
    scrollPane.setViewportView(txtpnDd);
    txtpnDd.setEditable(false);
    txtpnDd.setForeground(Color.WHITE);
    txtpnDd.setBackground(new Color(8, 7, 7));

    JButton btnWymuUpdate = new JButton("Wymu\u015B update");
    btnWymuUpdate.addActionListener(new Updater$8(this));

    btnWymuUpdate.setForeground(Color.BLACK);
    btnWymuUpdate.setBounds(446, 326, 120, 23);
    frmUxanCraftUpdater.getContentPane().add(btnWymuUpdate);
  }

  private static void checkVersions() {
    if (System.getProperty("os.name").startsWith("Windows"))
    {
      MCFolder = System.getenv("APPDATA") + sep + ".minecraft";
    } else if (System.getProperty("os.name").startsWith("Mac"))
    {
      MCFolder = System.getProperty("user.home") + sep + "Library" + sep + "Application Support" + sep + "minecraft";
    }
    else
    {
      MCFolder = System.getProperty("user.home") + sep + ".minecraft";
    }

    txtpnDd.setText(txtpnDd.getText() + "Pami\u0119taj, by przed operacj\u0105 wy\u0142\u0105czy\u0107 Minecraft'a!");
    append("Sprawdzanie..");

    checkDel();

    ver_updater_new = -1;
    updater_url = "";
    try {
      URL url1 = new URL("http://idiamonds.sytes.net/updater/updater.txt");
      InputStreamReader input1 = new InputStreamReader(url1.openStream());
      BufferedReader buffer1 = new BufferedReader(input1);
      ver_updater_new = Integer.parseInt(buffer1.readLine());
      updater_url = buffer1.readLine();
      buffer1.close();
      input1.close();
    }
    catch (Exception localException)
    {
    }
    if (ver_updater_new > ver_updater_curr) {
      performUpdaterUpdate();
    }

    ver_modpack_new = -1;
    modpack_url = "";
    try {
      URL url2 = new URL("http://idiamonds.sytes.net/updater/modpack.txt");
      InputStreamReader input2 = new InputStreamReader(url2.openStream());
      BufferedReader buffer2 = new BufferedReader(input2);
      ver_modpack_new = Integer.parseInt(buffer2.readLine());
      modpack_url = buffer2.readLine();
      buffer2.close();
      input2.close();
    }
    catch (Exception localException1)
    {
    }
    int version = -1;
    File ver = new File(MCFolder + sep + "ver");

    if (!ver.exists()) version = -1; else
      try
      {
        BufferedReader buffer_m = new BufferedReader(new FileReader(ver));
        version = Integer.parseInt(buffer_m.readLine());
        buffer_m.close();
      }
      catch (Exception localException2)
      {
      }
    if (version == -1) { performModsUpdate(1);
    } else if (ver_modpack_new > version) { performModsUpdate(0);
    } else {
      progressBar.setValue(100);
      append("Wersje mod\u00F3w aktualne, uruchamiam gr\u0119..");
      runMC();
    }
    progressBar.setValue(100);
  }

  private static void performUpdaterUpdate()
  {
    append("Znaleziono now\u0105 wersj\u0119 updatera! Pobieranie..");
    String newName = "";

    String[] split = updater_url.split("/");
    newName = split[(split.length - 1)];
    try
    {
      downloadFile(updater_url, newName);
    }
    catch (Exception localException1) {
    }
    try {
      File jarFile = new File(
        Updater.class.getProtectionDomain()
        .getCodeSource().getLocation().toURI());

      if (!jarFile.getName().equalsIgnoreCase("bin"))
        toDel(jarFile.getName());
    }
    catch (Exception localException2)
    {
    }
    String[] run = { "java", "-jar", newName };
    try {
      Runtime.getRuntime().exec(run);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    System.exit(0);
  }

  private static void performModsUpdate(int newbie)
  {
    if (newbie == 1) {
      append("To twoja pierwsza instalacja! Pobieranie mod\u00F3w..");
    }
    else if (newbie == 2)
      append("Wymuszam reinstalacj\u0119 mod\u00F3w..");
    else {
      append("Znaleziono now\u0105 wersj\u0119 modpacka! Pobieranie..");
    }

    try
    {
      File dir = new File(MCFolder + sep + "mods");
      removeDirectory(dir);
    } catch (Exception localException) {
    }
    try {
      URL url3 = new URL(modpack_url);
      InputStreamReader input3 = new InputStreamReader(url3.openStream());
      BufferedReader buffer3 = new BufferedReader(input3);
      String line = null;
      count = Integer.parseInt(buffer3.readLine());
      step = 0;
      value = 0;

      while ((line = buffer3.readLine()) != null) {
        String[] split = line.split("!");

        String filename = null;

        if (split[0].equalsIgnoreCase("newb")) {
          if (newbie == 1)
          {
            String[] split2 = split[1].split("/");
            filename = split2[(split2.length - 1)];

            String link = split[1];
            String path = MCFolder + sep + filename;
            downloadFile(link, path);
          }

        }
        else if (split[0].equalsIgnoreCase("null"))
        {
          String[] split2 = split[1].split("/");
          filename = split2[(split2.length - 1)];

          String link = split[1];
          String path = MCFolder + sep + filename;
          downloadFile(link, path);
        }
        else if (split[0].equalsIgnoreCase("del")) {
          String path = MCFolder + split[1].replaceAll("/", sep);

          File todel = new File(path);
          if (todel.exists()) {
            todel.delete();
          }

        }
        else
        {
          String[] split2 = split[1].split("/");
          filename = split2[(split2.length - 1)];

          String link = split[1];
          String path = MCFolder + sep + split[0] + sep + filename;

          File dir = new File(MCFolder + sep + split[0]);
          if (!dir.exists()) dir.mkdir();

          if (!filename.equalsIgnoreCase("minecraft.jar")) {
            append(filename + "..");
          }
          downloadFile(link, path);
        }

        step += 1;
        value = 100 * step / count;
        if (value > 100) value = 100;
        progressBar.setValue(value);
      }

      buffer3.close();
      input3.close();
    }
    catch (Exception localException1)
    {
    }
    File ver = new File(MCFolder + sep + "ver");
    try {
      if (!ver.exists()) ver.createNewFile();
      BufferedWriter output = new BufferedWriter(new FileWriter(ver));
      output.write(Integer.toString(ver_modpack_new));
      output.close();
    }
    catch (Exception localException2) {
    }
    append("Zainstalowano! Uruchamiam gr\u0119..");
    runMC();
  }

  private static void toDel(String filename) {
    File txt = new File(app_path + sep + "to_remove.txt");
    try {
      BufferedWriter output = new BufferedWriter(new FileWriter(txt));
      output.write(filename);
      output.close();
    }
    catch (Exception localException) {
    }
  }

  private static void downloadFile(String link, String filename) throws MalformedURLException, IOException {
    URL url = new URL(link);
    URLConnection conn = url.openConnection();
    InputStream is = conn.getInputStream();
    long max = conn.getContentLength();
    BufferedOutputStream fOut = new BufferedOutputStream(new FileOutputStream(new File(filename)));
    byte[] buffer = new byte[32768];
    int bytesRead = 0;
    int in = 0;
    while ((bytesRead = is.read(buffer)) != -1) {
      in += bytesRead;
      fOut.write(buffer, 0, bytesRead);
      if (step <= -1) continue; progressBar.setValue((int)(value + 100 * in / max / count));
    }
    fOut.flush();
    fOut.close();
    is.close();
  }

  private static void checkDel()
  {
    File txt = new File(app_path + sep + "to_remove.txt");
    if (txt.exists())
    {
      try {
        BufferedReader buffer = new BufferedReader(new FileReader(txt));
        File del = new File(app_path + sep + buffer.readLine());
        del.delete();
        buffer.close();
      } catch (Exception localException) {
      }
      txt.delete();
    }
  }

  private static void runMC()
  {
    File m = new File("Minecraft.exe");
    File mSP = new File("MinecraftSP.exe");
    File mJAR = new File("minecraft.jar");
    String[] win = { "cmd.exe", "/C", "Minecraft.exe" };
    String[] win2 = { "cmd.exe", "/C", "MinecraftSP.exe" };
    String[] lin = { "java", "-jar", "Minecraft.jar" };

    if (m.exists()) {
      try {
        Runtime.getRuntime().exec(win);
      } catch (Exception localException) {
      }
    } else if (mSP.exists()) {
      try {
        Runtime.getRuntime().exec(win2);
      } catch (Exception localException1) {
      }
    } else if (mJAR.exists()) {
      try {
        Runtime.getRuntime().exec(lin);
      } catch (Exception localException2) {
      }
    } else {
      JOptionPane.showMessageDialog(null, "Nie znaleziono klienta! Prosz\u0119 umie\u015Bci\u0107 plik Minecraft.exe w tym samym folderze, co updater.");
      return;
    }
    terminate = true;
    wait(7000);
    if (terminate)
      System.exit(0); 
  }

  public static void wait(int n) {
    long t0 = System.currentTimeMillis();
    long t1;
    do t1 = System.currentTimeMillis();

    while (t1 - t0 < n);
  }

  public static void append(String text) {
    txtpnDd.setText(txtpnDd.getText() + "\n" + text);
    txtpnDd.setCaretPosition(txtpnDd.getDocument().getLength());
  }
}
0

A co to jest Updater$1 itd? Nie widzę tutaj deklaracji takich klas. Zwykle pliki Cośtam$Numer.class są anonimowymi klasami wewnętrznymi, taka jest konwencja stosowana przez kompilator javac. Na pewno nie powinieneś się odwoływać do anonimowych klas po nazwie.

Tak w ogóle to ten kod to wynik dekompilacji?

0

tak jest to dekompilacja , gdyż chce przerobic tego clienta a co do tych anonimowych klas to mam oddzielne tak jakby kliki tych klas które sa odwoływane w tym pliku .

1 użytkowników online, w tym zalogowanych: 0, gości: 1