This commit is contained in:
2026-10-27 16:23:49 +01:00
commit cb53f21eae
66 changed files with 2452 additions and 0 deletions

BIN
MinecraftSP.jar Normal file

Binary file not shown.

BIN
cfr.jar Normal file

Binary file not shown.

View File

@@ -0,0 +1,97 @@
/*
* Decompiled with CFR 0.152.
*/
package anjocaido.console;
import java.awt.Cursor;
import java.awt.EventQueue;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import javax.swing.DropMode;
import javax.swing.GroupLayout;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class OutputConsole
extends JFrame {
int threadsUsing = 0;
private JScrollPane jScrollPane1;
private JTextArea jTextArea1;
public OutputConsole() {
this.initComponents();
this.jScrollPane1.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener(){
public void adjustmentValueChanged(AdjustmentEvent e) {
e.getAdjustable().setValue(e.getAdjustable().getMaximum());
}
});
this.pack();
this.setVisible(true);
}
private void initComponents() {
this.jScrollPane1 = new JScrollPane();
this.jTextArea1 = new JTextArea();
this.setDefaultCloseOperation(2);
this.setTitle("Error Console");
this.jScrollPane1.setAutoscrolls(true);
this.jScrollPane1.setColumnHeaderView(null);
this.jScrollPane1.setCursor(new Cursor(0));
this.jScrollPane1.setDebugGraphicsOptions(-1);
this.jTextArea1.setColumns(20);
this.jTextArea1.setEditable(false);
this.jTextArea1.setRows(5);
this.jTextArea1.setDropMode(DropMode.INSERT);
this.jScrollPane1.setViewportView(this.jTextArea1);
GroupLayout layout = new GroupLayout(this.getContentPane());
this.getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(this.jScrollPane1, -1, 636, Short.MAX_VALUE).addContainerGap()));
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(this.jScrollPane1, -1, 227, Short.MAX_VALUE).addContainerGap()));
this.pack();
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable(){
public void run() {
new OutputConsole().setVisible(true);
}
});
}
public void appendText(String text) {
this.jTextArea1.append(text);
this.jTextArea1.selectAll();
if (this.threadsUsing <= 0) {
this.waitToDispose();
}
}
public void acquire() {
++this.threadsUsing;
}
public void release() {
--this.threadsUsing;
if (this.threadsUsing <= 0) {
this.waitToDispose();
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public void waitToDispose() {
this.jTextArea1.append("\n\nThreads have Stopped... closing this window in 15 Seconds...\nIf you want to copy this, do it NOW!");
try {
Thread.sleep(15000L);
}
catch (InterruptedException interruptedException) {
}
finally {
this.dispose();
}
}
}

View File

@@ -0,0 +1,204 @@
/*
* Decompiled with CFR 0.152.
*/
package anjocaido.minecraftmanager;
import anjocaido.minecraftmanager.Zipper;
import java.io.File;
import java.util.ArrayList;
import javax.swing.filechooser.FileFilter;
import net.minecraft.MinecraftUtil;
public class BackupUtil {
public static final String WORLD_BACKUP_EXTENSION = "mcworld";
public static final String WORLD_BACKUP_GEN_NAME = "world_backup";
public static final String GAME_BACKUP_EXTENSION = "mcgame";
public static final String GAME_BACKUP_GEN_NAME = "minecraft_backup";
public static final String DATE_TIME_FORMAT = "%1$tY-%1$tm-%1$td_%1$tH-%1$tM-%1$tS";
public static void uninstallGame(boolean includeSaves) {
BackupUtil.deleteFileDir(MinecraftUtil.getBinFolder());
BackupUtil.deleteFileDir(MinecraftUtil.getLoginFile());
BackupUtil.deleteFileDir(MinecraftUtil.getResourcesFolder());
BackupUtil.deleteFileDir(MinecraftUtil.getOptionsFile());
if (includeSaves) {
BackupUtil.deleteFileDir(MinecraftUtil.getSavesFolder());
}
}
public static void backupGame(File zipDestiny, boolean wholegame) {
File[] source;
if (!wholegame) {
ArrayList<File> contents = new ArrayList<File>();
File f = MinecraftUtil.getBinFolder();
if (f.exists()) {
contents.add(f);
}
if ((f = MinecraftUtil.getResourcesFolder()).exists()) {
contents.add(f);
}
if ((f = MinecraftUtil.getLoginFile()).exists()) {
contents.add(f);
}
if ((f = MinecraftUtil.getOptionsFile()).exists()) {
contents.add(f);
}
source = contents.toArray(new File[contents.size()]);
} else {
source = MinecraftUtil.getWorkingDirectory().listFiles();
}
BackupUtil.backupContents(source, zipDestiny, GAME_BACKUP_GEN_NAME, GAME_BACKUP_EXTENSION);
}
public static void restoreGame(File zipSource) {
File destiny = MinecraftUtil.getWorkingDirectory();
BackupUtil.restoreContents(zipSource, destiny, GAME_BACKUP_GEN_NAME);
}
public static File getWorldNFolder(int n) {
File source = new File(MinecraftUtil.getSavesFolder(), "World" + n);
return source;
}
public static void backupWorld(int n, File destZip) {
File source = BackupUtil.getWorldNFolder(n);
BackupUtil.backupFile(source, destZip, WORLD_BACKUP_GEN_NAME, WORLD_BACKUP_EXTENSION);
}
public static void restoreWorld(int n, File zipSource) {
File destiny = BackupUtil.getWorldNFolder(n);
BackupUtil.restoreFile(zipSource, destiny, WORLD_BACKUP_GEN_NAME);
}
public static void backupFile(File source, File zipDestiny, String genericName, String extension) {
File generic = new File(MinecraftUtil.getTempFolder(), genericName);
if (!source.exists()) {
throw new IllegalArgumentException("Source file does not exist: " + source.getName());
}
if (!zipDestiny.getName().endsWith("." + extension)) {
zipDestiny = new File(zipDestiny.getPath() + "." + extension);
}
if (generic.exists()) {
BackupUtil.deleteFileDir(generic);
}
source.renameTo(generic);
Zipper.zipFolder(generic, zipDestiny);
generic.renameTo(source);
}
public static String getExtension(File f) {
String ext = null;
String s = f.getName();
int i = s.lastIndexOf(46);
if (i > 0 && i < s.length() - 1) {
ext = s.substring(i + 1).toLowerCase();
}
return ext;
}
public static boolean deleteFileDir(File dir) {
if (!dir.exists()) {
return false;
}
if (dir.isFile()) {
return dir.delete();
}
if (dir.isDirectory()) {
for (File f : dir.listFiles()) {
BackupUtil.deleteFileDir(f);
}
return dir.delete();
}
return dir.delete();
}
public static void restoreFile(File zipSource, File destiny, String genericName) {
File generic = new File(MinecraftUtil.getTempFolder(), genericName);
if (generic.exists()) {
BackupUtil.deleteFileDir(generic);
}
Zipper.unzipFolder(zipSource, MinecraftUtil.getTempFolder());
if (!generic.exists()) {
throw new IllegalStateException("Wrong content in zip file -> not found: " + generic.getName());
}
if (destiny.exists()) {
BackupUtil.deleteFileDir(destiny);
}
if (destiny.getParentFile() != null && !destiny.getParentFile().exists()) {
destiny.getParentFile().mkdirs();
}
generic.renameTo(destiny);
}
public static void backupContents(File[] folderContents, File zipDestiny, String genericName, String extension) {
for (File content : folderContents) {
if (content.exists()) continue;
throw new IllegalArgumentException("You sent me a folder content that doesnt exist : " + content.getName());
}
if (!zipDestiny.getName().endsWith("." + extension)) {
zipDestiny = new File(zipDestiny.getPath() + "." + extension);
}
Zipper.zipFolders(folderContents, zipDestiny, genericName);
}
public static void restoreContents(File zipSource, File folderDestiny, String genericName) {
File[] generics;
File genericFolder = new File(MinecraftUtil.getTempFolder(), genericName);
if (genericFolder.exists()) {
BackupUtil.deleteFileDir(genericFolder);
}
if (!folderDestiny.exists()) {
folderDestiny.mkdirs();
}
if (!folderDestiny.isDirectory()) {
throw new IllegalArgumentException("The destiny folder must be a directory!");
}
Zipper.unzipFolder(zipSource, MinecraftUtil.getTempFolder());
if (!genericFolder.exists()) {
throw new IllegalStateException("Wrong content in zip file -> not found: " + genericFolder.getName());
}
for (File generic : generics = genericFolder.listFiles()) {
File destiny = new File(folderDestiny, generic.getName());
if (destiny.exists()) {
BackupUtil.deleteFileDir(destiny);
}
generic.renameTo(destiny);
}
}
public static class GameFileFilter
extends FileFilter {
public boolean accept(File f) {
if (f == null) {
return false;
}
if (f.isDirectory()) {
return true;
}
String ext = BackupUtil.getExtension(f);
return ext != null && ext.equalsIgnoreCase(BackupUtil.GAME_BACKUP_EXTENSION);
}
public String getDescription() {
return "Minecraft Game files";
}
}
public static class WorldFileFilter
extends FileFilter {
public boolean accept(File f) {
if (f == null) {
return false;
}
if (f.isDirectory()) {
return true;
}
String ext = BackupUtil.getExtension(f);
return ext != null && ext.equalsIgnoreCase(BackupUtil.WORLD_BACKUP_EXTENSION);
}
public String getDescription() {
return "Minecraft World files";
}
}
}

View File

@@ -0,0 +1,12 @@
/*
* Decompiled with CFR 0.152.
*/
package anjocaido.minecraftmanager;
import anjocaido.minecraftmanager.MinecraftBackupManager;
public class Main {
public static void main(String[] args) {
new MinecraftBackupManager().setVisible(true);
}
}

View File

@@ -0,0 +1,398 @@
/*
* Decompiled with CFR 0.152.
*/
package anjocaido.minecraftmanager;
import anjocaido.minecraftmanager.BackupUtil;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.swing.ButtonGroup;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.LayoutStyle;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import net.minecraft.MinecraftUtil;
public class MinecraftBackupManager
extends JFrame {
private JButton backupgame;
private JCheckBox fullgamebackup;
private JButton jButton1;
private JButton jButton2;
private JButton jButton5;
private JLabel jLabel1;
private JLabel jLabel10;
private JLabel jLabel12;
private JLabel jLabel2;
private JLabel jLabel3;
private JLabel jLabel4;
private JLabel jLabel5;
private JLabel jLabel6;
private JLabel jLabel7;
private JLabel jLabel8;
private JPanel jPanel1;
private JPanel jPanel2;
private JPanel jPanel3;
private JPanel jPanel4;
private JSeparator jSeparator1;
private JTabbedPane jTabbedPane1;
private JCheckBox saveuninstall;
private JButton uninstall;
private JRadioButton world1;
private JRadioButton world2;
private JRadioButton world3;
private JRadioButton world4;
private JRadioButton world5;
private ButtonGroup worldgroup;
public MinecraftBackupManager() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}
catch (ClassNotFoundException ex) {
}
catch (InstantiationException ex) {
}
catch (IllegalAccessException ex) {
}
catch (UnsupportedLookAndFeelException unsupportedLookAndFeelException) {
// empty catch block
}
this.initComponents();
this.refreshButtons();
}
private void initComponents() {
this.worldgroup = new ButtonGroup();
this.jTabbedPane1 = new JTabbedPane();
this.jPanel1 = new JPanel();
this.jPanel3 = new JPanel();
this.world1 = new JRadioButton();
this.world2 = new JRadioButton();
this.world3 = new JRadioButton();
this.world4 = new JRadioButton();
this.world5 = new JRadioButton();
this.jPanel4 = new JPanel();
this.jButton1 = new JButton();
this.jButton2 = new JButton();
this.jLabel3 = new JLabel();
this.jLabel4 = new JLabel();
this.jLabel5 = new JLabel();
this.jLabel6 = new JLabel();
this.jLabel10 = new JLabel();
this.jPanel2 = new JPanel();
this.uninstall = new JButton();
this.saveuninstall = new JCheckBox();
this.backupgame = new JButton();
this.jButton5 = new JButton();
this.jLabel1 = new JLabel();
this.jLabel2 = new JLabel();
this.jLabel7 = new JLabel();
this.fullgamebackup = new JCheckBox();
this.jSeparator1 = new JSeparator();
this.jLabel8 = new JLabel();
this.jLabel12 = new JLabel();
this.setDefaultCloseOperation(2);
this.setTitle("Minecraft Backup Manager (by AnjoCaido)");
this.worldgroup.add(this.world1);
this.world1.setForeground(new Color(255, 0, 0));
this.world1.setText("World 1");
this.worldgroup.add(this.world2);
this.world2.setForeground(new Color(255, 0, 0));
this.world2.setText("World 2");
this.worldgroup.add(this.world3);
this.world3.setForeground(new Color(255, 0, 0));
this.world3.setText("World 3");
this.worldgroup.add(this.world4);
this.world4.setForeground(new Color(255, 0, 0));
this.world4.setText("World 4");
this.worldgroup.add(this.world5);
this.world5.setForeground(new Color(255, 0, 0));
this.world5.setText("World 5");
GroupLayout jPanel3Layout = new GroupLayout(this.jPanel3);
this.jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.world1).addComponent(this.world2).addComponent(this.world3).addComponent(this.world4).addComponent(this.world5)).addContainerGap(-1, Short.MAX_VALUE)));
jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addComponent(this.world1).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.world2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.world3).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.world4).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.world5).addContainerGap(-1, Short.MAX_VALUE)));
this.jButton1.setText("Do Backup");
this.jButton1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
MinecraftBackupManager.this.jButton1ActionPerformed(evt);
}
});
this.jButton2.setText("Restore Backup");
this.jButton2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
MinecraftBackupManager.this.jButton2ActionPerformed(evt);
}
});
GroupLayout jPanel4Layout = new GroupLayout(this.jPanel4);
this.jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup().addContainerGap().addGroup(jPanel4Layout.createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(this.jButton2, GroupLayout.Alignment.LEADING, -1, -1, Short.MAX_VALUE).addComponent(this.jButton1, GroupLayout.Alignment.LEADING, -1, 118, Short.MAX_VALUE)).addContainerGap()));
jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addComponent(this.jButton1).addGap(18, 18, 18).addComponent(this.jButton2).addContainerGap(-1, Short.MAX_VALUE)));
this.jLabel3.setText("Everything will be stored in a Zip format.");
this.jLabel4.setText("But I will use .mcworld extension, cuz that makes me happy.");
this.jLabel5.setText("You can restore any previous world number, to any world number you desire.");
this.jLabel6.setText("Ex: You create a backup of World 2, but then you can restore it to World 1.");
this.jLabel10.setForeground(new Color(255, 0, 0));
this.jLabel10.setText("RED color marks the Worlds you don't have!");
GroupLayout jPanel1Layout = new GroupLayout(this.jPanel1);
this.jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addComponent(this.jPanel3, -2, -1, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addGap(6, 6, 6).addComponent(this.jPanel4, -2, -1, -2)).addComponent(this.jLabel10).addComponent(this.jLabel3))).addComponent(this.jLabel4).addComponent(this.jLabel5).addComponent(this.jLabel6)).addContainerGap(109, Short.MAX_VALUE)));
jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false).addComponent(this.jPanel3, -2, -1, -2).addGroup(jPanel1Layout.createSequentialGroup().addComponent(this.jLabel10).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jPanel4, -2, -1, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, -1, Short.MAX_VALUE).addComponent(this.jLabel3))).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jLabel4).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jLabel5).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jLabel6).addContainerGap()));
this.jTabbedPane1.addTab("Game Saves", this.jPanel1);
this.uninstall.setText("Uninstall Game");
this.uninstall.setEnabled(false);
this.uninstall.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
MinecraftBackupManager.this.uninstallActionPerformed(evt);
}
});
this.saveuninstall.setText("Complete Uninstall (Include Game Saves/Worlds)");
this.saveuninstall.setEnabled(false);
this.backupgame.setText("Backup Game (Binaries)");
this.backupgame.setEnabled(false);
this.backupgame.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
MinecraftBackupManager.this.backupgameActionPerformed(evt);
}
});
this.jButton5.setText("Restore Game");
this.jButton5.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
MinecraftBackupManager.this.jButton5ActionPerformed(evt);
}
});
this.jLabel1.setText("You might want to backup the whole game at least once after it's installed.");
this.jLabel2.setText("Never know when there is an update out there that breaks everything.");
this.jLabel7.setText("Zip format again, but .mcgame extension. It really makes me happy.");
this.fullgamebackup.setText("Entire Folder (Inc. Saves or any other file there)");
this.fullgamebackup.setEnabled(false);
this.fullgamebackup.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
MinecraftBackupManager.this.fullgamebackupActionPerformed(evt);
}
});
GroupLayout jPanel2Layout = new GroupLayout(this.jPanel2);
this.jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addGap(6, 6, 6).addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.jLabel2).addComponent(this.jLabel7).addComponent(this.jLabel1))).addComponent(this.jSeparator1, -1, 551, Short.MAX_VALUE).addGroup(jPanel2Layout.createSequentialGroup().addComponent(this.uninstall).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.saveuninstall)).addGroup(jPanel2Layout.createSequentialGroup().addComponent(this.backupgame).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.fullgamebackup)).addComponent(this.jButton5, -2, 239, -2)).addContainerGap()));
jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.uninstall).addComponent(this.saveuninstall)).addGap(3, 3, 3).addComponent(this.jSeparator1, -2, 10, -2).addGap(18, 18, 18).addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.backupgame).addComponent(this.fullgamebackup)).addGap(18, 18, 18).addComponent(this.jButton5).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jLabel1).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jLabel2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jLabel7).addContainerGap(-1, Short.MAX_VALUE)));
this.jTabbedPane1.addTab("Game Installation", this.jPanel2);
this.jLabel8.setText("by AnjoCaido - v1.1");
this.jLabel12.setText("Backup/Restore take some seconds, wait for \"Done!\".");
GroupLayout layout = new GroupLayout(this.getContentPane());
this.getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(this.jTabbedPane1, GroupLayout.Alignment.LEADING, -1, 563, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addComponent(this.jLabel12).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 137, Short.MAX_VALUE).addComponent(this.jLabel8))).addContainerGap()));
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addComponent(this.jTabbedPane1, -1, 234, Short.MAX_VALUE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel8).addComponent(this.jLabel12)).addContainerGap()));
this.pack();
}
private void uninstallActionPerformed(ActionEvent evt) {
int result = JOptionPane.showConfirmDialog(this, "Are you sure that you want to uninstall Minecraft?\nCan't Undo It! (unless you have backup, hehe)", "Are you sure? (Uninstallation)", 0, 2);
if (result == 1 || result == -1) {
return;
}
BackupUtil.uninstallGame(this.saveuninstall.isSelected());
JOptionPane.showMessageDialog(this, "Done!", "Uninstallation", -1);
this.refreshButtons();
}
private void backupgameActionPerformed(ActionEvent evt) {
JFileChooser save = new JFileChooser();
Calendar now = GregorianCalendar.getInstance();
save.setSelectedFile(new File(String.format("MCGame_" + (this.fullgamebackup.isSelected() ? "Complete_" : "") + "%1$tY-%1$tm-%1$td_%1$tH-%1$tM-%1$tS" + "_Backup." + "mcgame", now)));
save.setFileSelectionMode(0);
save.setFileFilter(new BackupUtil.GameFileFilter());
int result = save.showSaveDialog(this);
if (result != 0) {
return;
}
File f = save.getSelectedFile();
if (f == null) {
return;
}
BackupUtil.backupGame(f, this.fullgamebackup.isSelected());
JOptionPane.showMessageDialog(this, "Done!", "Game Backup", -1);
}
private void jButton5ActionPerformed(ActionEvent evt) {
int result = JOptionPane.showConfirmDialog(this, "Are you sure that you want to restore WHOLE Minecraft?\nIT MIGHT OVERWRITE ALL YOUR DATA\n(if is a complete backup, you'll lose all your actual worlds/saves!)\nMake sure you have your most recent save games backed up before this!", "Are you sure? (Full Game Restoration)", 0, 2);
if (result == 1 || result == -1) {
return;
}
JFileChooser save = new JFileChooser();
save.setFileSelectionMode(0);
save.setFileFilter(new BackupUtil.GameFileFilter());
save.showOpenDialog(this);
File f = save.getSelectedFile();
if (f == null || !f.exists()) {
return;
}
try {
BackupUtil.restoreGame(f);
}
catch (IllegalStateException ex) {
JOptionPane.showMessageDialog(this, "Failed!\nInvalid Zip Contents!\nthe game folder inside must have 'minecraft_backup' as name.", "Game Restoration", 0);
return;
}
JOptionPane.showMessageDialog(this, "Done!", "Game Restoration", -1);
this.refreshButtons();
}
private void jButton1ActionPerformed(ActionEvent evt) {
int world = this.getWorldSelected();
if (world < 0) {
JOptionPane.showMessageDialog(this, "Error. Please Select a World to Backup first!", "World Backup", 0);
return;
}
if (!BackupUtil.getWorldNFolder(world).exists()) {
JOptionPane.showMessageDialog(this, "Sorry, but this world doesn't Exist!", "World Backup", 0);
return;
}
JFileChooser save = new JFileChooser();
Calendar now = GregorianCalendar.getInstance();
save.setFileSelectionMode(0);
save.setSelectedFile(new File(String.format("MCWorld" + world + "_" + "%1$tY-%1$tm-%1$td_%1$tH-%1$tM-%1$tS" + "_Backup." + "mcworld", now)));
save.setFileFilter(new BackupUtil.WorldFileFilter());
int result = save.showSaveDialog(this);
if (result != 0) {
return;
}
File f = save.getSelectedFile();
if (f == null) {
return;
}
BackupUtil.backupWorld(world, f);
JOptionPane.showMessageDialog(this, "Done!", "World Backup", -1);
}
private void jButton2ActionPerformed(ActionEvent evt) {
int result;
int world = this.getWorldSelected();
if (world < 0) {
JOptionPane.showMessageDialog(this, "Error. Please Select a World to Restore first!", "World Restoration", 0);
return;
}
if (BackupUtil.getWorldNFolder(world).exists() && ((result = JOptionPane.showConfirmDialog(this, "Are you sure that you want to overwrite World " + world + "?\n" + "Can't Undo It! (unless you have backup, hehe)", "Are you sure? (World Restoration)", 0, 2)) == 1 || result == -1)) {
return;
}
JFileChooser save = new JFileChooser();
save.setFileSelectionMode(0);
save.setFileFilter(new BackupUtil.WorldFileFilter());
save.showOpenDialog(this);
File f = save.getSelectedFile();
if (f == null) {
return;
}
try {
BackupUtil.restoreWorld(world, f);
}
catch (IllegalStateException ex) {
JOptionPane.showMessageDialog(this, "Failed!\nInvalid Zip Contents!\nthe world folder inside must have 'world_backup' as name.", "World Restoration", 0);
return;
}
JOptionPane.showMessageDialog(this, "Done!", "World Restoration", -1);
this.refreshButtons();
}
private void fullgamebackupActionPerformed(ActionEvent evt) {
if (this.fullgamebackup.isSelected()) {
this.backupgame.setText("Backup Game (Complete)");
} else {
this.backupgame.setText("Backup Game (Binaries)");
}
}
public int getWorldSelected() {
if (this.world1.isSelected()) {
return 1;
}
if (this.world2.isSelected()) {
return 2;
}
if (this.world3.isSelected()) {
return 3;
}
if (this.world4.isSelected()) {
return 4;
}
if (this.world5.isSelected()) {
return 5;
}
return -1;
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable(){
public void run() {
new MinecraftBackupManager().setVisible(true);
}
});
}
private void refreshButtons() {
if (BackupUtil.getWorldNFolder(1).exists()) {
this.world1.setForeground(Color.BLACK);
} else {
this.world1.setForeground(Color.RED);
}
if (BackupUtil.getWorldNFolder(2).exists()) {
this.world2.setForeground(Color.BLACK);
} else {
this.world2.setForeground(Color.RED);
}
if (BackupUtil.getWorldNFolder(3).exists()) {
this.world3.setForeground(Color.BLACK);
} else {
this.world3.setForeground(Color.RED);
}
if (BackupUtil.getWorldNFolder(4).exists()) {
this.world4.setForeground(Color.BLACK);
} else {
this.world4.setForeground(Color.RED);
}
if (BackupUtil.getWorldNFolder(5).exists()) {
this.world5.setForeground(Color.BLACK);
} else {
this.world5.setForeground(Color.RED);
}
if (MinecraftUtil.getBinFolder().exists() || MinecraftUtil.getLoginFile().exists() || MinecraftUtil.getOptionsFile().exists() || MinecraftUtil.getResourcesFolder().exists() || MinecraftUtil.getSavesFolder().exists()) {
this.uninstall.setEnabled(true);
} else {
this.uninstall.setEnabled(false);
}
if (MinecraftUtil.getSavesFolder().exists()) {
this.saveuninstall.setEnabled(true);
} else {
this.saveuninstall.setEnabled(false);
}
if (MinecraftUtil.getBinFolder().exists()) {
this.backupgame.setEnabled(true);
this.fullgamebackup.setEnabled(true);
} else {
this.backupgame.setEnabled(false);
this.fullgamebackup.setEnabled(false);
}
}
}

View File

@@ -0,0 +1,112 @@
/*
* Decompiled with CFR 0.152.
*/
package anjocaido.minecraftmanager;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
public class Zipper {
static final int BUFFER = 2048;
public static boolean zipFolders(File[] srcFolders, File destZipFile) {
return Zipper.zipFolders(srcFolders, destZipFile, "");
}
public static boolean zipFolders(File[] srcFolders, File destZipFile, String inFolderName) {
try {
Object origin = null;
FileOutputStream dest = new FileOutputStream(destZipFile);
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
for (File fileFolder : srcFolders) {
if (Zipper.addToZip(fileFolder.getParentFile().getPath(), inFolderName, fileFolder.getName(), out)) continue;
return false;
}
out.close();
}
catch (Exception e) {
e.printStackTrace();
}
return true;
}
protected static boolean addToZip(String absolutePath, String relativePath, String fileName, ZipOutputStream out) {
File file = new File(absolutePath + File.separator + fileName);
System.out.println("Adding \"" + absolutePath + File.separator + fileName + "\" file");
if (file.isHidden()) {
return true;
}
if (file.isDirectory()) {
absolutePath = absolutePath + File.separator + file.getName();
relativePath = relativePath + File.separator + file.getName();
for (String child : file.list()) {
if (Zipper.addToZip(absolutePath, relativePath, child, out)) continue;
return false;
}
return true;
}
try {
int count;
byte[] data = new byte[2048];
FileInputStream fi = new FileInputStream(file);
BufferedInputStream origin = new BufferedInputStream(fi, 2048);
ZipEntry entry = new ZipEntry(relativePath + File.separator + fileName);
out.putNextEntry(entry);
while ((count = origin.read(data, 0, 2048)) != -1) {
out.write(data, 0, count);
}
origin.close();
}
catch (Exception ex) {
Logger.getLogger(Zipper.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
return true;
}
public static boolean zipFolder(File srcFolder, File destZipFile) {
File[] ar = new File[]{srcFolder};
return Zipper.zipFolders(ar, destZipFile);
}
public static void unzipFolder(File zipFile, File destFolder) {
try {
ZipEntry entry;
BufferedOutputStream dest = null;
FileInputStream fis = new FileInputStream(zipFile);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
while ((entry = zis.getNextEntry()) != null) {
int count;
System.out.println("Extracting: " + entry);
byte[] data = new byte[2048];
File f = new File(destFolder + File.separator + entry.getName());
if (f.getParentFile() != null && !f.getParentFile().exists()) {
f.getParentFile().mkdirs();
}
if (!f.exists()) {
f.createNewFile();
f.getParent();
}
FileOutputStream fos = new FileOutputStream(f);
dest = new BufferedOutputStream(fos, 2048);
while ((count = zis.read(data, 0, 2048)) != -1) {
dest.write(data, 0, count);
}
dest.flush();
dest.close();
}
zis.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,567 @@
/*
* Decompiled with CFR 0.152.
*/
package net.minecraft;
import SevenZip.LzmaAlone;
import java.applet.Applet;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FilePermission;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.JarURLConnection;
import java.net.SocketPermission;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
import java.security.AccessControlException;
import java.security.AccessController;
import java.security.CodeSource;
import java.security.PermissionCollection;
import java.security.PrivilegedExceptionAction;
import java.security.SecureClassLoader;
import java.security.cert.Certificate;
import java.util.Enumeration;
import java.util.Vector;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Pack200;
import net.minecraft.Launcher;
import net.minecraft.MinecraftUtil;
public class GameUpdater
implements Runnable {
public static final int STATE_INIT = 1;
public static final int STATE_DETERMINING_PACKAGES = 2;
public static final int STATE_CHECKING_CACHE = 3;
public static final int STATE_DOWNLOADING = 4;
public static final int STATE_EXTRACTING_PACKAGES = 5;
public static final int STATE_UPDATING_CLASSPATH = 6;
public static final int STATE_SWITCHING_APPLET = 7;
public static final int STATE_INITIALIZE_REAL_APPLET = 8;
public static final int STATE_START_REAL_APPLET = 9;
public static final int STATE_DONE = 10;
public int percentage;
public int currentSizeDownload;
public int totalSizeDownload;
public int currentSizeExtract;
public int totalSizeExtract;
protected URL[] urlList;
private static ClassLoader classLoader;
protected Thread loaderThread;
protected Thread animationThread;
public boolean fatalError;
public String fatalErrorDescription;
protected String subtaskMessage = "";
protected int state = 1;
protected boolean lzmaSupported = false;
protected boolean pack200Supported = false;
protected String[] genericErrorMessage = new String[]{"An error occured while loading the applet.", "Please contact support to resolve this issue.", "<placeholder for error message>"};
protected boolean certificateRefused;
protected String[] certificateRefusedMessage = new String[]{"Permissions for Applet Refused.", "Please accept the permissions dialog to allow", "the applet to continue the loading process."};
protected static boolean natives_loaded;
public boolean forceUpdate = false;
public static final String[] gameFiles;
InputStream[] isp;
URLConnection urlconnectionp;
public void init() {
this.state = 1;
try {
Class.forName("LZMA.LzmaInputStream");
this.lzmaSupported = true;
}
catch (Throwable localThrowable) {
// empty catch block
}
try {
Pack200.class.getSimpleName();
this.pack200Supported = true;
}
catch (Throwable throwable) {
// empty catch block
}
}
private String generateStacktrace(Exception exception) {
StringWriter result = new StringWriter();
PrintWriter printWriter = new PrintWriter(result);
exception.printStackTrace(printWriter);
return ((Object)result).toString();
}
protected String getDescriptionForState() {
switch (this.state) {
case 1: {
return "Initializing loader";
}
case 2: {
return "Determining packages to load";
}
case 3: {
return "Checking cache for existing files";
}
case 4: {
return "Downloading packages";
}
case 5: {
return "Extracting downloaded packages";
}
case 6: {
return "Updating classpath";
}
case 7: {
return "Switching applet";
}
case 8: {
return "Initializing real applet";
}
case 9: {
return "Starting real applet";
}
case 10: {
return "Done loading";
}
}
return "unknown state";
}
protected void loadJarURLs() throws Exception {
this.state = 2;
this.urlList = new URL[gameFiles.length + 1];
URL path = new URL("http://s3.amazonaws.com/MinecraftDownload/");
for (int i = 0; i < gameFiles.length; ++i) {
this.urlList[i] = new URL(path, gameFiles[i]);
}
String osName = System.getProperty("os.name");
String nativeJar = null;
if (osName.startsWith("Win")) {
nativeJar = "windows_natives.jar.lzma";
} else if (osName.startsWith("Linux")) {
nativeJar = "linux_natives.jar.lzma";
} else if (osName.startsWith("Mac")) {
nativeJar = "macosx_natives.jar.lzma";
} else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) {
nativeJar = "solaris_natives.jar.lzma";
} else {
this.fatalErrorOccured("OS (" + osName + ") not supported", null);
}
if (nativeJar == null) {
this.fatalErrorOccured("no lwjgl natives files found", null);
} else {
this.urlList[this.urlList.length - 1] = new URL(path, nativeJar);
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public void run() {
this.init();
this.state = 3;
this.percentage = 5;
try {
this.loadJarURLs();
String path = (String)AccessController.doPrivileged(new PrivilegedExceptionAction(){
public Object run() throws Exception {
return MinecraftUtil.getWorkingDirectory() + File.separator + "bin" + File.separator;
}
});
File dir = new File(path);
if (!dir.exists()) {
dir.mkdirs();
}
int before = this.percentage;
boolean cacheAvailable = false;
if (this.canPlayOffline()) {
cacheAvailable = true;
this.percentage = 90;
}
if (this.forceUpdate || !cacheAvailable) {
if (this.percentage != before) {
this.percentage = before;
}
System.out.println("Path: " + path);
this.downloadJars(path);
this.extractJars(path);
this.extractNatives(path);
this.percentage = 90;
}
this.updateClassPath(dir);
this.state = 10;
}
catch (AccessControlException ace) {
this.fatalErrorOccured(ace.getMessage(), ace);
this.certificateRefused = true;
}
catch (Exception e) {
this.fatalErrorOccured(e.getMessage(), e);
}
finally {
this.loaderThread = null;
}
}
protected void updateClassPath(File dir) throws Exception {
String path;
this.state = 6;
this.percentage = 95;
URL[] urls = new URL[this.urlList.length];
for (int i = 0; i < this.urlList.length; ++i) {
urls[i] = new File(dir, this.getJarName(this.urlList[i])).toURI().toURL();
System.out.println("URL: " + urls[i]);
}
if (classLoader == null) {
classLoader = new URLClassLoader(urls){
protected PermissionCollection getPermissions(CodeSource codesource) {
PermissionCollection perms = null;
try {
Method method = SecureClassLoader.class.getDeclaredMethod("getPermissions", CodeSource.class);
method.setAccessible(true);
perms = (PermissionCollection)method.invoke(this.getClass().getClassLoader(), codesource);
String host = "www.minecraft.net";
if (host != null && host.length() > 0) {
perms.add(new SocketPermission(host, "connect,accept"));
} else {
codesource.getLocation().getProtocol().equals("file");
}
perms.add(new FilePermission("<<ALL FILES>>", "read"));
}
catch (Exception e) {
e.printStackTrace();
}
return perms;
}
};
}
if (!(path = dir.getAbsolutePath()).endsWith(File.separator)) {
path = path + File.separator;
}
this.unloadNatives(path);
System.setProperty("org.lwjgl.librarypath", path + "natives");
System.setProperty("net.java.games.input.librarypath", path + "natives");
natives_loaded = true;
}
private void unloadNatives(String nativePath) {
if (!natives_loaded) {
return;
}
try {
Field field = ClassLoader.class.getDeclaredField("loadedLibraryNames");
field.setAccessible(true);
Vector libs = (Vector)field.get(this.getClass().getClassLoader());
String path = new File(nativePath).getCanonicalPath();
for (int i = 0; i < libs.size(); ++i) {
String s = (String)libs.get(i);
if (!s.startsWith(path)) continue;
libs.remove(i);
--i;
}
}
catch (Exception e) {
e.printStackTrace();
}
}
public Applet createApplet() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
Class<?> appletClass = classLoader.loadClass("net.minecraft.client.MinecraftApplet");
return (Applet)appletClass.newInstance();
}
protected void downloadJars(String path) throws Exception {
this.state = 4;
int[] fileSizes = new int[this.urlList.length];
for (int i = 0; i < this.urlList.length; ++i) {
System.out.println(this.urlList[i]);
URLConnection urlconnection = this.urlList[i].openConnection();
urlconnection.setDefaultUseCaches(false);
if (urlconnection instanceof HttpURLConnection) {
((HttpURLConnection)urlconnection).setRequestMethod("HEAD");
}
fileSizes[i] = urlconnection.getContentLength();
this.totalSizeDownload += fileSizes[i];
}
this.percentage = 10;
int initialPercentage = 10;
byte[] buffer = new byte[65536];
for (int i = 0; i < this.urlList.length; ++i) {
int unsuccessfulAttempts = 0;
int maxUnsuccessfulAttempts = 3;
boolean downloadFile = true;
while (downloadFile) {
int bufferSize;
downloadFile = false;
URLConnection urlconnection = this.urlList[i].openConnection();
if (urlconnection instanceof HttpURLConnection) {
urlconnection.setRequestProperty("Cache-Control", "no-cache");
urlconnection.connect();
}
String currentFile = this.getFileName(this.urlList[i]);
InputStream inputstream = this.getJarInputStream(currentFile, urlconnection);
FileOutputStream fos = new FileOutputStream(path + currentFile);
long downloadStartTime = System.currentTimeMillis();
int downloadedAmount = 0;
int fileSize = 0;
String downloadSpeedMessage = "";
while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) {
fos.write(buffer, 0, bufferSize);
this.currentSizeDownload += bufferSize;
fileSize += bufferSize;
this.percentage = initialPercentage + this.currentSizeDownload * 45 / this.totalSizeDownload;
this.subtaskMessage = "Retrieving: " + currentFile + " " + this.currentSizeDownload * 100 / this.totalSizeDownload + "%";
downloadedAmount += bufferSize;
long timeLapse = System.currentTimeMillis() - downloadStartTime;
if (timeLapse >= 1000L) {
float downloadSpeed = (float)downloadedAmount / (float)timeLapse;
downloadSpeed = (float)((int)(downloadSpeed * 100.0f)) / 100.0f;
downloadSpeedMessage = " @ " + downloadSpeed + " KB/sec";
downloadedAmount = 0;
downloadStartTime += 1000L;
}
this.subtaskMessage = this.subtaskMessage + downloadSpeedMessage;
}
inputstream.close();
fos.close();
if (!(urlconnection instanceof HttpURLConnection) || fileSize == fileSizes[i] || fileSizes[i] <= 0) continue;
if (++unsuccessfulAttempts < maxUnsuccessfulAttempts) {
downloadFile = true;
this.currentSizeDownload -= fileSize;
continue;
}
throw new Exception("failed to download " + currentFile);
}
}
this.subtaskMessage = "";
}
protected InputStream getJarInputStream(String currentFile, URLConnection urlconnection) throws Exception {
InputStream[] is = new InputStream[1];
this.isp = is;
this.urlconnectionp = urlconnection;
for (int j = 0; j < 3 && is[0] == null; ++j) {
Thread t = new Thread(){
public void run() {
try {
GameUpdater.this.isp[0] = GameUpdater.this.urlconnectionp.getInputStream();
}
catch (Exception exception) {
// empty catch block
}
}
};
t.setName("JarInputStreamThread");
t.start();
int iterationCount = 0;
while (is[0] == null && iterationCount++ < 5) {
try {
t.join(1000L);
}
catch (InterruptedException localInterruptedException) {}
}
if (is[0] != null) continue;
try {
t.interrupt();
t.join();
continue;
}
catch (InterruptedException localInterruptedException1) {
// empty catch block
}
}
if (is[0] == null) {
if (currentFile.equals("minecraft.jar")) {
throw new Exception("Unable to download " + currentFile);
}
throw new Exception("Unable to download " + currentFile);
}
return is[0];
}
protected void extractLZMA(String in, String out) throws Exception {
File f = new File(in);
File fout = new File(out);
LzmaAlone.decompress(f, fout);
f.delete();
}
protected void extractPack(String in, String out) throws Exception {
File f = new File(in);
FileOutputStream fostream = new FileOutputStream(out);
JarOutputStream jostream = new JarOutputStream(fostream);
Pack200.Unpacker unpacker = Pack200.newUnpacker();
unpacker.unpack(f, jostream);
jostream.close();
f.delete();
}
protected void extractJars(String path) throws Exception {
this.state = 5;
float increment = 10.0f / (float)this.urlList.length;
for (int i = 0; i < this.urlList.length; ++i) {
this.percentage = 55 + (int)(increment * (float)(i + 1));
String filename = this.getFileName(this.urlList[i]);
if (filename.endsWith(".pack.lzma")) {
this.subtaskMessage = "Extracting: " + filename + " to " + filename.replaceAll(".lzma", "");
this.extractLZMA(path + filename, path + filename.replaceAll(".lzma", ""));
this.subtaskMessage = "Extracting: " + filename.replaceAll(".lzma", "") + " to " + filename.replaceAll(".pack.lzma", "");
this.extractPack(path + filename.replaceAll(".lzma", ""), path + filename.replaceAll(".pack.lzma", ""));
continue;
}
if (filename.endsWith(".pack")) {
this.subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".pack", "");
this.extractPack(path + filename, path + filename.replace(".pack", ""));
continue;
}
if (!filename.endsWith(".lzma")) continue;
this.subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".lzma", "");
this.extractLZMA(path + filename, path + filename.replace(".lzma", ""));
}
}
protected void extractNatives(String path) throws Exception {
JarEntry entry;
File nativeFolder;
this.state = 5;
int initialPercentage = this.percentage;
String nativeJar = this.getJarName(this.urlList[this.urlList.length - 1]);
Certificate[] certificate = Launcher.class.getProtectionDomain().getCodeSource().getCertificates();
if (certificate == null) {
URL location = Launcher.class.getProtectionDomain().getCodeSource().getLocation();
JarURLConnection jurl = (JarURLConnection)new URL("jar:" + location.toString() + "!/net/minecraft/Launcher.class").openConnection();
jurl.setDefaultUseCaches(true);
try {
certificate = jurl.getCertificates();
}
catch (Exception localException) {
// empty catch block
}
}
if (!(nativeFolder = new File(path + "natives")).exists()) {
nativeFolder.mkdir();
}
JarFile jarFile = new JarFile(path + nativeJar, true);
Enumeration<JarEntry> entities = jarFile.entries();
this.totalSizeExtract = 0;
while (entities.hasMoreElements()) {
entry = entities.nextElement();
if (entry.isDirectory() || entry.getName().indexOf(47) != -1) continue;
this.totalSizeExtract = (int)((long)this.totalSizeExtract + entry.getSize());
}
this.currentSizeExtract = 0;
entities = jarFile.entries();
while (entities.hasMoreElements()) {
int bufferSize;
File f;
entry = entities.nextElement();
if (entry.isDirectory() || entry.getName().indexOf(47) != -1 || (f = new File(path + "natives" + File.separator + entry.getName())).exists() && !f.delete()) continue;
InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName()));
FileOutputStream out = new FileOutputStream(path + "natives" + File.separator + entry.getName());
byte[] buffer = new byte[65536];
while ((bufferSize = in.read(buffer, 0, buffer.length)) != -1) {
((OutputStream)out).write(buffer, 0, bufferSize);
this.currentSizeExtract += bufferSize;
this.percentage = initialPercentage + this.currentSizeExtract * 20 / this.totalSizeExtract;
this.subtaskMessage = "Extracting: " + entry.getName() + " " + this.currentSizeExtract * 100 / this.totalSizeExtract + "%";
}
GameUpdater.validateCertificateChain(certificate, entry.getCertificates());
in.close();
((OutputStream)out).close();
}
this.subtaskMessage = "";
jarFile.close();
File f = new File(path + nativeJar);
f.delete();
}
protected static void validateCertificateChain(Certificate[] ownCerts, Certificate[] native_certs) throws Exception {
if (ownCerts == null) {
return;
}
if (native_certs == null) {
throw new Exception("Unable to validate certificate chain. Native entry did not have a certificate chain at all");
}
if (ownCerts.length != native_certs.length) {
throw new Exception("Unable to validate certificate chain. Chain differs in length [" + ownCerts.length + " vs " + native_certs.length + "]");
}
for (int i = 0; i < ownCerts.length; ++i) {
if (ownCerts[i].equals(native_certs[i])) continue;
throw new Exception("Certificate mismatch: " + ownCerts[i] + " != " + native_certs[i]);
}
}
protected String getJarName(URL url) {
String fileName = url.getFile();
if (fileName.contains("?")) {
fileName = fileName.substring(0, fileName.indexOf("?"));
}
if (fileName.endsWith(".pack.lzma")) {
fileName = fileName.replaceAll(".pack.lzma", "");
} else if (fileName.endsWith(".pack")) {
fileName = fileName.replaceAll(".pack", "");
} else if (fileName.endsWith(".lzma")) {
fileName = fileName.replaceAll(".lzma", "");
}
return fileName.substring(fileName.lastIndexOf(47) + 1);
}
protected String getFileName(URL url) {
String fileName = url.getFile();
if (fileName.contains("?")) {
fileName = fileName.substring(0, fileName.indexOf("?"));
}
return fileName.substring(fileName.lastIndexOf(47) + 1);
}
protected void fatalErrorOccured(String error, Exception e) {
e.printStackTrace();
this.fatalError = true;
this.fatalErrorDescription = "Fatal error occured (" + this.state + "): " + error;
System.out.println(this.fatalErrorDescription);
if (e != null) {
System.out.println(this.generateStacktrace(e));
}
}
public boolean canPlayOffline() {
if (!MinecraftUtil.getBinFolder().exists() || !MinecraftUtil.getBinFolder().isDirectory()) {
return false;
}
if (!MinecraftUtil.getNativesFolder().exists() || !MinecraftUtil.getNativesFolder().isDirectory()) {
return false;
}
if (MinecraftUtil.getBinFolder().list().length < gameFiles.length + 1) {
return false;
}
if (MinecraftUtil.getNativesFolder().list().length < 1) {
return false;
}
String[] bins = MinecraftUtil.getBinFolder().list();
for (String necessary : gameFiles) {
boolean isThere = false;
for (String found : bins) {
if (!necessary.equalsIgnoreCase(found)) continue;
isThere = true;
break;
}
if (isThere) continue;
return false;
}
return true;
}
static {
natives_loaded = false;
gameFiles = new String[]{"lwjgl.jar", "jinput.jar", "lwjgl_util.jar", "minecraft.jar"};
}
}

View File

@@ -0,0 +1,236 @@
/*
* Decompiled with CFR 0.152.
*/
package net.minecraft;
import java.applet.Applet;
import java.applet.AppletStub;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.VolatileImage;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import javax.imageio.ImageIO;
import net.minecraft.GameUpdater;
import net.minecraft.LoginForm;
public class Launcher
extends Applet
implements Runnable,
AppletStub {
private static final long serialVersionUID = 1L;
public Map<String, String> customParameters = new HashMap<String, String>();
private GameUpdater gameUpdater;
private boolean gameUpdaterStarted = false;
private Applet applet;
private Image bgImage;
private boolean active = false;
private int context = 0;
private VolatileImage img;
public boolean forceUpdate = false;
public boolean isActive() {
if (this.context == 0) {
this.context = -1;
try {
if (this.getAppletContext() != null) {
this.context = 1;
}
}
catch (Exception exception) {
// empty catch block
}
}
if (this.context == -1) {
return this.active;
}
return super.isActive();
}
public void init(String userName, String sessionId) {
try {
this.bgImage = ImageIO.read(LoginForm.class.getResource("dirt.png")).getScaledInstance(32, 32, 16);
}
catch (IOException e) {
e.printStackTrace();
}
this.customParameters.put("username", userName);
this.customParameters.put("sessionid", sessionId);
this.gameUpdater = new GameUpdater();
this.gameUpdater.forceUpdate = this.forceUpdate;
}
public boolean canPlayOffline() {
return this.gameUpdater.canPlayOffline();
}
public void init() {
if (this.applet != null) {
this.applet.init();
return;
}
this.init(this.getParameter("userName"), this.getParameter("sessionId"));
}
public void start() {
if (this.applet != null) {
this.applet.start();
return;
}
if (this.gameUpdaterStarted) {
return;
}
Thread t = new Thread(){
public void run() {
Launcher.this.gameUpdater.run();
try {
if (!((Launcher)Launcher.this).gameUpdater.fatalError) {
Launcher.this.replace(Launcher.this.gameUpdater.createApplet());
}
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
catch (InstantiationException e) {
e.printStackTrace();
}
catch (IllegalAccessException e) {
e.printStackTrace();
}
}
};
t.setDaemon(true);
t.start();
t = new Thread(){
public void run() {
while (Launcher.this.applet == null) {
Launcher.this.repaint();
try {
Thread.sleep(10L);
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
t.setDaemon(true);
t.start();
this.gameUpdaterStarted = true;
}
public void stop() {
if (this.applet != null) {
this.active = false;
this.applet.stop();
return;
}
}
public void destroy() {
if (this.applet != null) {
this.applet.destroy();
return;
}
}
public void replace(Applet applet) {
this.applet = applet;
applet.setStub(this);
applet.setSize(this.getWidth(), this.getHeight());
this.setLayout(new BorderLayout());
this.add((Component)applet, "Center");
applet.init();
this.active = true;
applet.start();
this.validate();
}
public void update(Graphics g) {
this.paint(g);
}
public void paint(Graphics g2) {
if (this.applet != null) {
return;
}
int w = this.getWidth() / 2;
int h = this.getHeight() / 2;
if (this.img == null || this.img.getWidth() != w || this.img.getHeight() != h) {
this.img = this.createVolatileImage(w, h);
}
Graphics g = this.img.getGraphics();
for (int x = 0; x <= w / 32; ++x) {
for (int y = 0; y <= h / 32; ++y) {
g.drawImage(this.bgImage, x * 32, y * 32, null);
}
}
g.setColor(Color.LIGHT_GRAY);
String msg = "Updating Minecraft";
if (this.gameUpdater.fatalError) {
msg = "Failed to launch";
}
g.setFont(new Font(null, 1, 20));
FontMetrics fm = g.getFontMetrics();
g.drawString(msg, w / 2 - fm.stringWidth(msg) / 2, h / 2 - fm.getHeight() * 2);
g.setFont(new Font(null, 0, 12));
fm = g.getFontMetrics();
msg = this.gameUpdater.getDescriptionForState();
if (this.gameUpdater.fatalError) {
msg = this.gameUpdater.fatalErrorDescription;
}
g.drawString(msg, w / 2 - fm.stringWidth(msg) / 2, h / 2 + fm.getHeight() * 1);
msg = this.gameUpdater.subtaskMessage;
g.drawString(msg, w / 2 - fm.stringWidth(msg) / 2, h / 2 + fm.getHeight() * 2);
if (!this.gameUpdater.fatalError) {
g.setColor(Color.black);
g.fillRect(64, h - 64, w - 128 + 1, 5);
g.setColor(new Color(32768));
g.fillRect(64, h - 64, this.gameUpdater.percentage * (w - 128) / 100, 4);
g.setColor(new Color(0x20A020));
g.fillRect(65, h - 64 + 1, this.gameUpdater.percentage * (w - 128) / 100 - 2, 1);
}
g.dispose();
g2.drawImage(this.img, 0, 0, w * 2, h * 2, null);
}
public void run() {
}
public String getParameter(String name) {
String custom = this.customParameters.get(name);
if (custom != null) {
return custom;
}
try {
return super.getParameter(name);
}
catch (Exception e) {
this.customParameters.put(name, null);
return null;
}
}
public void appletResize(int width, int height) {
}
public URL getDocumentBase() {
try {
return new URL("http://www.youtube.com/user/anjocaido0");
}
catch (MalformedURLException e) {
e.printStackTrace();
return null;
}
}
}

View File

@@ -0,0 +1,106 @@
/*
* Decompiled with CFR 0.152.
*/
package net.minecraft;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import javax.imageio.ImageIO;
import net.minecraft.Launcher;
import net.minecraft.LoginForm;
import net.minecraft.MinecraftUtil;
public class LauncherFrame
extends Frame {
public static final int VERSION = 12;
private static final long serialVersionUID = 1L;
private Launcher launcher;
private LoginForm loginForm;
public boolean forceUpdate = false;
public LauncherFrame() {
super("Minecraft Launcher (by AnjoCaido)");
System.out.println("Hello!");
this.setBackground(Color.BLACK);
this.loginForm = new LoginForm(this);
this.setLayout(new BorderLayout());
this.add((Component)this.loginForm, "Center");
this.loginForm.setPreferredSize(new Dimension(854, 480));
this.pack();
this.setLocationRelativeTo(null);
try {
this.setIconImage(ImageIO.read(LauncherFrame.class.getResource("favicon.png")));
}
catch (IOException e1) {
e1.printStackTrace();
}
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent arg0) {
new Thread(){
public void run() {
try {
Thread.sleep(30000L);
}
catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("FORCING EXIT!");
System.exit(0);
}
}.start();
if (LauncherFrame.this.launcher != null) {
LauncherFrame.this.launcher.stop();
LauncherFrame.this.launcher.destroy();
}
System.exit(0);
}
});
}
public String getFakeResult(String userName) {
return MinecraftUtil.getFakeLatestVersion() + ":35b9fd01865fda9d70b157e244cf801c:" + userName + ":12345:";
}
public void login(String userName) {
String result = this.getFakeResult(userName);
String[] values = result.split(":");
this.launcher = new Launcher();
this.launcher.forceUpdate = this.forceUpdate;
this.launcher.customParameters.put("userName", values[2].trim());
this.launcher.customParameters.put("sessionId", values[3].trim());
this.launcher.init();
this.removeAll();
this.add((Component)this.launcher, "Center");
this.validate();
this.launcher.start();
this.loginForm.loginOk();
this.loginForm = null;
this.setTitle("Minecraft");
}
private void showError(String error) {
this.removeAll();
this.add(this.loginForm);
this.loginForm.setError(error);
this.validate();
}
public boolean canPlayOffline(String userName) {
Launcher launcher2 = new Launcher();
launcher2.init(userName, "12345");
return launcher2.canPlayOffline();
}
public static void main(String[] args) {
LauncherFrame launcherFrame = new LauncherFrame();
launcherFrame.setVisible(true);
}
}

View File

@@ -0,0 +1,308 @@
/*
* Decompiled with CFR 0.152.
*/
package net.minecraft;
import anjocaido.minecraftmanager.MinecraftBackupManager;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Checkbox;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.VolatileImage;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.security.Key;
import java.util.Random;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import javax.imageio.ImageIO;
import net.minecraft.LauncherFrame;
import net.minecraft.MinecraftUtil;
public class LoginForm
extends Panel {
private static final long serialVersionUID = 1L;
private Image bgImage;
private TextField userName = new TextField(20);
private Checkbox forceUpdateBox = new Checkbox("Force Update");
private Button launchButton = new Button("Enter Game");
private Label errorLabel = new Label("", 1);
private Label creditsVersion = new Label("v12.2");
private Button openManager = new Button("Backup Manager");
private LauncherFrame launcherFrame;
private boolean outdated = false;
private VolatileImage img;
public LoginForm(LauncherFrame launcherFrame) {
this.launcherFrame = launcherFrame;
GridBagLayout gbl = new GridBagLayout();
this.setLayout(gbl);
this.add(this.buildLoginPanel());
try {
this.bgImage = ImageIO.read(LoginForm.class.getResource("dirt.png")).getScaledInstance(32, 32, 16);
}
catch (IOException e) {
e.printStackTrace();
}
this.readUsername();
this.launchButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
if (LoginForm.this.forceUpdateBox.getState()) {
((LoginForm)LoginForm.this).launcherFrame.forceUpdate = true;
}
LoginForm.this.launcherFrame.login(LoginForm.this.userName.getText());
}
});
}
private void readUsername() {
try {
File lastLogin = new File(MinecraftUtil.getWorkingDirectory(), "lastlogin");
Cipher cipher = this.getCipher(2, "passwordfile");
DataInputStream dis = cipher != null ? new DataInputStream(new CipherInputStream(new FileInputStream(lastLogin), cipher)) : new DataInputStream(new FileInputStream(lastLogin));
this.userName.setText(dis.readUTF());
dis.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
private void writeUsername() {
try {
File lastLogin = new File(MinecraftUtil.getWorkingDirectory(), "lastlogin");
Cipher cipher = this.getCipher(1, "passwordfile");
DataOutputStream dos = cipher != null ? new DataOutputStream(new CipherOutputStream(new FileOutputStream(lastLogin), cipher)) : new DataOutputStream(new FileOutputStream(lastLogin));
dos.writeUTF(this.userName.getText());
dos.writeUTF("");
dos.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
private Cipher getCipher(int mode, String password) throws Exception {
Random random = new Random(43287234L);
byte[] salt = new byte[8];
random.nextBytes(salt);
PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec(password.toCharArray()));
Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
cipher.init(mode, (Key)pbeKey, pbeParamSpec);
return cipher;
}
public void update(Graphics g) {
this.paint(g);
}
public void paint(Graphics g2) {
int w = this.getWidth() / 2;
int h = this.getHeight() / 2;
if (this.img == null || this.img.getWidth() != w || this.img.getHeight() != h) {
this.img = this.createVolatileImage(w, h);
}
Graphics g = this.img.getGraphics();
for (int x = 0; x <= w / 32; ++x) {
for (int y = 0; y <= h / 32; ++y) {
g.drawImage(this.bgImage, x * 32, y * 32, null);
}
}
g.setColor(Color.LIGHT_GRAY);
String msg = "Minecraft Launcher";
g.setFont(new Font(null, 1, 20));
FontMetrics fm = g.getFontMetrics();
g.drawString(msg, w / 2 - fm.stringWidth(msg) / 2, h / 2 - fm.getHeight() * 2);
g.dispose();
g2.drawImage(this.img, 0, 0, w * 2, h * 2, null);
}
private Panel buildLoginPanel() {
Panel panel = new Panel(){
private static final long serialVersionUID = 1L;
private Insets insets = new Insets(12, 24, 16, 32);
public Insets getInsets() {
return this.insets;
}
public void update(Graphics g) {
this.paint(g);
}
public void paint(Graphics g) {
super.paint(g);
int hOffs = 0;
g.setColor(Color.BLACK);
g.drawRect(0, 0 + hOffs, this.getWidth() - 1, this.getHeight() - 1 - hOffs);
g.drawRect(1, 1 + hOffs, this.getWidth() - 3, this.getHeight() - 3 - hOffs);
g.setColor(Color.WHITE);
g.drawRect(2, 2 + hOffs, this.getWidth() - 5, this.getHeight() - 5 - hOffs);
}
};
panel.setBackground(Color.GRAY);
BorderLayout layout = new BorderLayout();
layout.setHgap(0);
layout.setVgap(8);
panel.setLayout(layout);
GridLayout gl1 = new GridLayout(0, 1);
GridLayout gl2 = new GridLayout(0, 1);
gl1.setVgap(2);
gl2.setVgap(2);
Panel titles = new Panel(gl1);
Panel values = new Panel(gl2);
titles.add(new Label("Username:", 2));
titles.add(new Label("", 2));
values.add(this.userName);
values.add(this.forceUpdateBox);
panel.add((Component)titles, "West");
panel.add((Component)values, "Center");
Panel loginPanel = new Panel(new BorderLayout());
Panel registerPanel = new Panel(new BorderLayout());
try {
Label accountLink;
if (this.outdated) {
accountLink = new Label("You need to update the launcher!"){
private static final long serialVersionUID = 0L;
public void paint(Graphics g) {
super.paint(g);
int x = 0;
int y = 0;
FontMetrics fm = g.getFontMetrics();
int width = fm.stringWidth(this.getText());
int height = fm.getHeight();
if (this.getAlignment() == 0) {
x = 0;
} else if (this.getAlignment() == 1) {
x = this.getBounds().width / 2 - width / 2;
} else if (this.getAlignment() == 2) {
x = this.getBounds().width - width;
}
y = this.getBounds().height / 2 + height / 2 - 1;
g.drawLine(x + 2, y, x + width - 2, y);
}
public void update(Graphics g) {
this.paint(g);
}
};
accountLink.setCursor(Cursor.getPredefinedCursor(12));
accountLink.addMouseListener(new MouseAdapter(){
public void mousePressed(MouseEvent arg0) {
try {
Desktop.getDesktop().browse(new URL("http://www.minecraft.net/download.jsp").toURI());
}
catch (Exception e) {
e.printStackTrace();
}
}
});
accountLink.setForeground(Color.BLUE);
registerPanel.add((Component)accountLink, "West");
registerPanel.add((Component)new Panel(), "Center");
} else {
accountLink = new Label("Need account?"){
private static final long serialVersionUID = 0L;
public void paint(Graphics g) {
super.paint(g);
int x = 0;
int y = 0;
FontMetrics fm = g.getFontMetrics();
int width = fm.stringWidth(this.getText());
int height = fm.getHeight();
if (this.getAlignment() == 0) {
x = 0;
} else if (this.getAlignment() == 1) {
x = this.getBounds().width / 2 - width / 2;
} else if (this.getAlignment() == 2) {
x = this.getBounds().width - width;
}
y = this.getBounds().height / 2 + height / 2 - 1;
g.drawLine(x + 2, y, x + width - 2, y);
}
public void update(Graphics g) {
this.paint(g);
}
};
accountLink.setCursor(Cursor.getPredefinedCursor(12));
accountLink.addMouseListener(new MouseAdapter(){
public void mousePressed(MouseEvent arg0) {
try {
Desktop.getDesktop().browse(new URL("http://www.minecraft.net/register.jsp").toURI());
}
catch (Exception e) {
e.printStackTrace();
}
}
});
accountLink.setForeground(Color.BLUE);
registerPanel.add((Component)this.creditsVersion, "West");
registerPanel.add((Component)new Panel(), "Center");
}
}
catch (Error localError) {
// empty catch block
}
loginPanel.add((Component)registerPanel, "Center");
loginPanel.add((Component)this.launchButton, "East");
Panel anjoPanel = new Panel();
this.openManager.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
new MinecraftBackupManager().setVisible(true);
}
});
anjoPanel.add(this.openManager);
loginPanel.add((Component)anjoPanel, "South");
panel.add((Component)loginPanel, "South");
this.errorLabel.setFont(new Font(null, 2, 16));
this.errorLabel.setForeground(new Color(0x800000));
panel.add((Component)this.errorLabel, "North");
return panel;
}
public void setError(String errorMessage) {
this.removeAll();
this.add(this.buildLoginPanel());
this.errorLabel.setText(errorMessage);
this.validate();
}
public void loginOk() {
this.writeUsername();
}
}

View File

@@ -0,0 +1,149 @@
/*
* Decompiled with CFR 0.152.
*/
package net.minecraft;
import anjocaido.console.OutputConsole;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import net.minecraft.LauncherFrame;
public class MinecraftLauncher {
private static final long MIN_HEAP = 511L;
private static final long RECOMMENDED_HEAP = 1024L;
private static boolean debugMode = false;
public static void main(String[] args) throws Exception {
long heapSizeMegs;
if (args.length > 0 && args[0].contains("debug")) {
debugMode = true;
}
if ((heapSizeMegs = Runtime.getRuntime().maxMemory() / 1024L / 1024L) > 511L) {
LauncherFrame.main(args);
} else {
Process process;
ProcessBuilder pb;
ArrayList<String> params = new ArrayList<String>();
String pathToJar = MinecraftLauncher.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
params.add("javaw");
params.add("-Xms512m");
params.add("-Xmx1024m");
params.add("-Dsun.java2d.noddraw=true");
params.add("-Dsun.java2d.d3d=false");
params.add("-Dsun.java2d.opengl=false");
params.add("-Dsun.java2d.pmoffscreen=false");
params.add("-classpath");
params.add(pathToJar);
params.add("net.minecraft.LauncherFrame");
if (!debugMode) {
try {
pb = new ProcessBuilder(params);
process = pb.start();
if (process == null) {
throw new Exception("!");
}
System.exit(0);
}
catch (IOException ec) {
// empty catch block
}
}
try {
params.set(0, "java");
pb = new ProcessBuilder(params);
process = pb.start();
if (process == null) {
throw new IOException("!");
}
if (debugMode) {
final OutputConsole console = new OutputConsole();
final BufferedReader reader1 = new BufferedReader(new InputStreamReader(process.getErrorStream()));
final BufferedReader reader2 = new BufferedReader(new InputStreamReader(process.getInputStream()));
Thread errorViewer = new Thread(){
BufferedReader reader;
{
this.reader = reader1;
}
public void run() {
boolean terminated = false;
boolean noerrors = true;
String output = "";
console.acquire();
while (!terminated && output != null) {
int exitvalue = Integer.MIN_VALUE;
try {
exitvalue = process.exitValue();
}
catch (IllegalThreadStateException ex) {
try {
output = this.reader.readLine();
System.err.println(output);
console.appendText("\nError: " + output);
}
catch (IOException ex1) {
output = null;
}
}
if (exitvalue == Integer.MIN_VALUE) continue;
terminated = true;
if (exitvalue == 0) continue;
noerrors = false;
}
if (noerrors) {
console.release();
}
}
};
Thread outViewer = new Thread(){
BufferedReader reader;
{
this.reader = reader2;
}
public void run() {
boolean terminated = false;
boolean noerrors = true;
String output = "";
console.acquire();
while (!terminated && output != null) {
int exitvalue = Integer.MIN_VALUE;
try {
exitvalue = process.exitValue();
}
catch (IllegalThreadStateException ex) {
try {
output = this.reader.readLine();
System.out.println(output);
console.appendText("\nOutput: " + output);
}
catch (IOException ex1) {
output = null;
}
}
if (exitvalue == Integer.MIN_VALUE) continue;
terminated = true;
if (exitvalue == 0) continue;
noerrors = false;
}
if (noerrors) {
console.release();
}
}
};
errorViewer.start();
outViewer.start();
}
if (!debugMode) {
System.exit(0);
}
}
catch (IOException e) {
System.out.println("Java couldn't figure out a way to get more memory.\nIf the game crashes, run to the hills!");
LauncherFrame.main(args);
}
}
}
}

View File

@@ -0,0 +1,246 @@
/*
* Decompiled with CFR 0.152.
*/
package net.minecraft;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
public class MinecraftUtil {
private static File workDir = null;
private static File binDir = null;
private static File resourcesDis = null;
private static File optionsFile = null;
private static File lastloginFile = null;
private static File savesDir = null;
private static File tempFolder = null;
private static File nativesFolder = null;
public static File getWorkingDirectory() {
if (workDir == null) {
workDir = MinecraftUtil.getWorkingDirectory("minecraft");
}
return workDir;
}
public static File getBinFolder() {
if (binDir == null) {
binDir = new File(MinecraftUtil.getWorkingDirectory(), "bin");
}
return binDir;
}
public static File getResourcesFolder() {
if (resourcesDis == null) {
resourcesDis = new File(MinecraftUtil.getWorkingDirectory(), "resources");
}
return resourcesDis;
}
public static File getOptionsFile() {
if (optionsFile == null) {
optionsFile = new File(MinecraftUtil.getWorkingDirectory(), "options.txt");
}
return optionsFile;
}
public static File getLoginFile() {
if (lastloginFile == null) {
lastloginFile = new File(MinecraftUtil.getWorkingDirectory(), "lastlogin");
}
return lastloginFile;
}
public static File getSavesFolder() {
if (savesDir == null) {
savesDir = new File(MinecraftUtil.getWorkingDirectory(), "saves");
}
return savesDir;
}
public static File getNativesFolder() {
if (nativesFolder == null) {
nativesFolder = new File(MinecraftUtil.getBinFolder(), "natives");
}
return nativesFolder;
}
public static File getTempFolder() {
if (tempFolder == null) {
tempFolder = new File(System.getProperties().getProperty("java.io.tmpdir"), "MCBKPMNGR");
}
if (!tempFolder.exists()) {
tempFolder.mkdirs();
}
return tempFolder;
}
public static File getWorkingDirectory(String applicationName) {
File workingDirectory;
String userHome = System.getProperty("user.home", ".");
switch (MinecraftUtil.getPlatform().ordinal()) {
case 0:
case 1: {
workingDirectory = new File(userHome, '.' + applicationName + '/');
break;
}
case 2: {
String applicationData = System.getenv("APPDATA");
if (applicationData != null) {
workingDirectory = new File(applicationData, "." + applicationName + '/');
break;
}
workingDirectory = new File(userHome, '.' + applicationName + '/');
break;
}
case 3: {
workingDirectory = new File(userHome, "Library/Application Support/" + applicationName);
break;
}
default: {
workingDirectory = new File(userHome, applicationName + '/');
}
}
if (!workingDirectory.exists() && !workingDirectory.mkdirs()) {
throw new RuntimeException("The working directory could not be created: " + workingDirectory);
}
return workingDirectory;
}
private static OS getPlatform() {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
return OS.windows;
}
if (osName.contains("mac")) {
return OS.macos;
}
if (osName.contains("solaris")) {
return OS.solaris;
}
if (osName.contains("sunos")) {
return OS.solaris;
}
if (osName.contains("linux")) {
return OS.linux;
}
if (osName.contains("unix")) {
return OS.linux;
}
return OS.unknown;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public static String excutePost(String targetURL, String urlParameters) {
HttpURLConnection connection = null;
try {
String str1;
String line;
URL url = new URL(targetURL);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length", Integer.toString(urlParameters.getBytes().length));
connection.setRequestProperty("Content-Language", "en-US");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
StringBuffer response = new StringBuffer();
while ((line = rd.readLine()) != null) {
response.append(line);
response.append('\r');
}
rd.close();
String string = str1 = response.toString();
return string;
}
catch (Exception e) {
e.printStackTrace();
String string = null;
return string;
}
finally {
if (connection != null) {
connection.disconnect();
}
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public static void resetVersion() {
FilterOutputStream dos = null;
try {
File dir = new File(MinecraftUtil.getWorkingDirectory() + File.separator + "bin" + File.separator);
File versionFile = new File(dir, "version");
dos = new DataOutputStream(new FileOutputStream(versionFile));
((DataOutputStream)dos).writeUTF("0");
dos.close();
}
catch (FileNotFoundException ex) {
Logger.getLogger(MinecraftUtil.class.getName()).log(Level.SEVERE, null, ex);
}
catch (IOException ex) {
Logger.getLogger(MinecraftUtil.class.getName()).log(Level.SEVERE, null, ex);
}
finally {
try {
dos.close();
}
catch (IOException ex) {
Logger.getLogger(MinecraftUtil.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public static String getFakeLatestVersion() {
try {
File dir = new File(MinecraftUtil.getWorkingDirectory() + File.separator + "bin" + File.separator);
File file = new File(dir, "version");
DataInputStream dis = new DataInputStream(new FileInputStream(file));
String version = dis.readUTF();
dis.close();
if (version.equals("0")) {
return "1285241960000";
}
return version;
}
catch (IOException ex) {
return "1285241960000";
}
}
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
private static enum OS {
linux,
solaris,
windows,
macos,
unknown;
}
}

3
decompiled/summary.txt Normal file
View File

@@ -0,0 +1,3 @@
Summary for MinecraftSP.jar
Decompiled with CFR 0.152
Exception analysing jar java.lang.NullPointerException

View File

@@ -0,0 +1,7 @@
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 16.3-b01-279 (Apple Inc.)
Main-Class: net.minecraft.MinecraftLauncher
Class-Path:
X-COMMENT: Main-Class will be added automatically by build

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,7 @@
/* AUTOMATICALLY GENERATED ON Tue Apr 16 17:20:59 EDT 2002*/
/* DO NOT EDIT */
grant {
permission java.security.AllPermission;
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB