Commit 6bd222e7 authored by superblaubeere27's avatar superblaubeere27

1.3 RELEASE

parent 8bef8001
......@@ -261,6 +261,10 @@ public class LiquidLauncher {
new Thread(() -> {
boolean launched = false;
menuInterface.launchButton.setEnabled(false);
menuInterface.progress1.setMaximum(7);
// Loading LiquidBounce #1
menuInterface.progress1.setString("Loading LiquidBounce... (1/7)");
menuInterface.progress1.setValue(1);
try {
LauncherFolderTree tree = getLauncherFolderTree(clientBuild);
tree.mkdirs();
......@@ -284,7 +288,9 @@ public class LiquidLauncher {
if (!tree.getLiquidBounceFile().exists())
throw new LaunchException("Failed to install LiquidBounce");
// Loading forge #2
menuInterface.progress1.setString("Loading forge... (2/7)");
menuInterface.progress1.setValue(2);
if (!tree.getForgeJar().exists())
NetworkUtils.downloadWithProgressBarUpdate(ResourceBundle.getBundle("tanslations").getString("waiting"), clientBuild.getForgeVersion(), tree.getForgeJar(), menuInterface.progress, "Downloading forge...");
......@@ -294,11 +300,16 @@ public class LiquidLauncher {
forgeFile.close();
}
// Loading Minecraft #3
menuInterface.progress1.setString("Loading Minecraft... (3/7)");
menuInterface.progress1.setValue(3);
if (!tree.getMinecraftJson().exists()) {
menuInterface.progress.setString("Loading minecraft JSON...");
final String minecraftJsonDownload = getMCJson(clientBuild.getMinecraftVersion());
NetworkUtils.downloadWithProgressBarUpdate(ResourceBundle.getBundle("tanslations").getString("waiting"), minecraftJsonDownload, tree.getMinecraftJson(), menuInterface.progress, "Downloading client JSON...");
menuInterface.progress.setString(ResourceBundle.getBundle("tanslations").getString("waiting"));
// menuInterface.progress1.setString("Waiting... (0/7)");
}
if (!tree.getMinecraftJar().exists()) {
......@@ -312,6 +323,10 @@ public class LiquidLauncher {
}
}
// Loading mods #4
menuInterface.progress1.setString("Loading mods... (4/7)");
menuInterface.progress1.setValue(4);
if (tree.getModsFolder().exists()) {
tree.getModsFolder().delete();
tree.getModsFolder().mkdirs();
......@@ -343,11 +358,22 @@ public class LiquidLauncher {
final LibraryManager libraryManager = LibraryManager.loadLibraries(obj.get("libraries").getAsJsonArray(), mcJ.get("libraries").getAsJsonArray());
final File natives = new File(tree.getOtherFolder(), "natives");
natives.mkdirs();
// Updating Libraries #5
menuInterface.progress1.setString("Updating libraries... (5/7)");
menuInterface.progress1.setValue(5);
libraryManager.updateLibraries(natives, tree.getLibraryFolder());
// Updating Assets #6
menuInterface.progress1.setString("Updating assets... (6/7)");
menuInterface.progress1.setValue(6);
assetManager.checkAssetsForVersion(mcJ.get("assets").getAsString());
// Files.copy(tree.getOptifineFile(), new File(tree.getModsFolder(), "optifine.jar"));
// Launching #7
menuInterface.progress1.setString("Launching... (7/7)");
menuInterface.progress1.setValue(7);
menuInterface.progress1.setString("Updating libraries... (5/7)");
menuInterface.progress1.setValue(5);
Files.copy(tree.getLiquidBounceFile(), new File(tree.getModsFolder(), "liquidbounce.jar"));
StringBuilder libraries = new StringBuilder();
libraries.append(libraryManager.getCPList(tree.getLibraryFolder()));
......@@ -421,6 +447,7 @@ public class LiquidLauncher {
JOptionPane.showMessageDialog(menuInterface, "Failed to launch client: " + e, "Failed to launch client", JOptionPane.WARNING_MESSAGE);
} finally {
menuInterface.progress.setString(ResourceBundle.getBundle("tanslations").getString("waiting"));
menuInterface.progress1.setString("Waiting... (0/7)");
menuInterface.launchButton.setEnabled(!launched);
}
}, "Launch thread").start();
......@@ -510,9 +537,11 @@ public class LiquidLauncher {
private void addProcessListener(final GameProcess execute) {
new Thread(() -> {
menuInterface.progress.setMaximum(100);
menuInterface.progress1.setMaximum(100);
while (execute.getProcess().isAlive()) {
try {
menuInterface.progress.setIndeterminate(true);
menuInterface.progress1.setIndeterminate(true);
Thread.sleep(30); // Better Performance
} catch (InterruptedException e) {
e.printStackTrace();
......@@ -523,6 +552,9 @@ public class LiquidLauncher {
menuInterface.progress.setString(ResourceBundle.getBundle("tanslations").getString("waiting"));
menuInterface.progress.setValue(0);
menuInterface.progress.setIndeterminate(false);
menuInterface.progress1.setString("Waiting... (0/7)");
menuInterface.progress1.setValue(0);
menuInterface.progress1.setIndeterminate(false);
}).start();
}
......
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="net.ccbluex.LiquidLauncher.ui.MenuInterface">
<grid id="27dc6" binding="payne" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="payne" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="617" height="486"/>
<xy x="20" y="20" width="617" height="499"/>
</constraints>
<properties/>
<border type="none"/>
......@@ -592,7 +592,7 @@
</tabbedpane>
<component id="715ac" class="javax.swing.JButton" binding="launchButton" default-binding="true">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="tanslations" key="launch"/>
......@@ -600,13 +600,22 @@
</component>
<component id="4adfe" class="javax.swing.JProgressBar" binding="progress">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<string resource-bundle="tanslations" key="waiting"/>
<stringPainted value="true"/>
</properties>
</component>
<component id="44aa2" class="javax.swing.JProgressBar" binding="progress1">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<string value="Waiting... (0/7)"/>
<stringPainted value="true"/>
</properties>
</component>
</children>
</grid>
<buttonGroups>
......
......@@ -31,6 +31,7 @@ import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.*;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.ResourceBundle;
......@@ -56,6 +57,7 @@ public class MenuInterface extends JFrame {
public JProgressBar progress;
public JTextField jvmPath;
public ArrayList<Alt> alts = new ArrayList<>();
public JProgressBar progress1;
private DefaultListModel<String> altListModel;
private JTabbedPane tabbedPane1;
private JPanel payne;
......@@ -381,6 +383,7 @@ public class MenuInterface extends JFrame {
statusLabel.setText(LOGGING_IN);
LiquidLauncher.liquidLauncher.account = alts.get(altList.getSelectedIndex()).login();
statusLabel.setText(String.format(LOGGED_IN, alts.get(altList.getSelectedIndex()).getName()));
updateAltList();
} catch (Exception e1) {
statusLabel.setText(LOGIN_FAILED);
LiquidLauncher.report(e1);
......@@ -485,8 +488,110 @@ public class MenuInterface extends JFrame {
LiquidLauncher.info("The alt was copied to clipboard");
});
clearButton1.addActionListener(e -> {
System.out.println(JOptionPane.showConfirmDialog(MenuInterface.this, "Are you sure you want to delete all the alts?"));
if (JOptionPane.showConfirmDialog(MenuInterface.this, "Are you sure you want to delete all the alts?", "Confirm", JOptionPane.YES_NO_OPTION) == 0) {
alts.clear();
updateAltList();
}
});
synchonizeWithLiquidBounceButton.addActionListener(e -> {
try {
File accountsFile = new File(LiquidLauncher.liquidLauncher.getLauncherFolderTree(LiquidLauncher.liquidLauncher.getClientBuild(minecraftVersion.getSelectedItem(), clientVersion.getSelectedItem())).getLiquidBounceFolder(), "accounts.json");
JsonArray jsonArray = new JsonParser().parse(new InputStreamReader(new FileInputStream(accountsFile))).getAsJsonArray();
for (JsonElement element :
jsonArray) {
String str = element.getAsString();
if (!str.contains(":") || str.endsWith(":")) {
continue;
}
alts.add(new Alt(str.split(":")[0], str.split(":")[1], str.split(":")[2]));
}
updateAltList();
JsonArray array = new JsonArray();
for (Alt alt :
alts) {
array.add(String.format("%s:%s:%s", alt.getUsername(), alt.getPassword(), alt.getName()));
}
Files.write(array.toString().getBytes(), accountsFile);
} catch (Throwable ex) {
LiquidLauncher.report(ex);
}
});
importButton2.addActionListener(e -> {
try {
String fileName = Utils.chooseFile(null, MenuInterface.this, new FileFilter() {
@Override
public boolean accept(File f) {
return true;
}
@Override
public String getDescription() {
return "Alt list file (E-Mail:Password)";
}
});
if (fileName != null) {
int imported = 0;
int failed = 0;
int ignored = 0;
java.util.List<String> lines = Files.readLines(new File(fileName), Charset.forName("UTF-8"));
// System.out.println(lines);
for (String line : lines) {
String raw = line.trim();
if (raw.startsWith("//") || raw.startsWith("#")) {
ignored++;
continue;
}
if (countChars(raw, ':') != 1 || raw.endsWith(":")) {
failed++;
continue;
}
String split[] = raw.split(":");
Alt alt = new Alt(split[0], split[1], "NAME NOT RESOLVED");
alts.add(alt);
imported++;
}
updateAltList();
LiquidLauncher.info(String.format("%s alts were imported, %s ignored, %s failed", imported, ignored, failed));
}
} catch (Exception e1) {
LiquidLauncher.report(e1);
}
});
exportButton1.addActionListener(e -> {
try {
String file = Utils.chooseFileToSave(null, MenuInterface.this, new FileFilter() {
@Override
public boolean accept(File f) {
return true;
}
@Override
public String getDescription() {
return "Alt list file (E-Mail:Password)";
}
});
if (file != null) {
String s = "";
for (Alt alt :
alts) {
s += String.format("%s:%s\n", alt.getUsername(), alt.getPassword());
}
Files.write(s.getBytes(), new File(file));
LiquidLauncher.info(alts.size() + " alts were exported.");
}
} catch (Exception e1) {
LiquidLauncher.report(e1);
}
});
}
private int countChars(String raw, char c) {
int count = 0;
for (char c1 : raw.toCharArray()) {
if (c == c1) count++;
}
return count;
}
public void updateAltList() {
......@@ -654,7 +759,7 @@ public class MenuInterface extends JFrame {
*/
private void $$$setupUI$$$() {
payne = new JPanel();
payne.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
payne.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
tabbedPane1 = new JTabbedPane();
payne.add(tabbedPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null, 0, false));
newsPanel = new JPanel();
......@@ -872,11 +977,15 @@ public class MenuInterface extends JFrame {
panel6.add(clearButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
launchButton = new JButton();
this.$$$loadButtonText$$$(launchButton, ResourceBundle.getBundle("tanslations").getString("launch"));
payne.add(launchButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
payne.add(launchButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
progress = new JProgressBar();
progress.setString(ResourceBundle.getBundle("tanslations").getString("waiting"));
progress.setStringPainted(true);
payne.add(progress, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
payne.add(progress, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
progress1 = new JProgressBar();
progress1.setString("Waiting... (0/7)");
progress1.setStringPainted(true);
payne.add(progress1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}
/**
......
......@@ -66,6 +66,7 @@ public class Alt {
public AuthenticationUtils.AuthenticationResponse login() throws Exception {
response = isCracked() ? AuthenticationUtils.login(username) : AuthenticationUtils.login(username, password);
if (response == null) throw new IOException("Failed to login!");
name = response.getName();
return response;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment