0.7.0 release

This commit is contained in:
Steven Tracey 2022-04-01 11:41:52 -04:00
parent c1ec34804c
commit aa4a911f0b
16 changed files with 161 additions and 57 deletions

View File

@ -1,13 +1,13 @@
//import edu.sc.seis.launch4j.tasks.Launch4jLibraryTask import edu.sc.seis.launch4j.tasks.Launch4jLibraryTask
plugins { plugins {
id 'java' id 'java'
id 'com.github.johnrengelman.shadow' version '5.2.0' id 'com.github.johnrengelman.shadow' version '5.2.0'
// id 'edu.sc.seis.launch4j' version '2.5.1' id 'edu.sc.seis.launch4j' version '2.5.1'
} }
group 'tech.nevets.jaml' group 'tech.nevets.jaml'
version '0.6.0' version '0.7.0'
def build = 'stable' def build = 'stable'
repositories { repositories {
@ -41,28 +41,19 @@ shadowJar {
} }
} }
//launch4j { launch4j {
// mainClassName = 'tech.nevets.jaml.JAML' mainClassName = 'tech.nevets.jaml.JAML'
// outfile = 'JAML.exe' outfile = 'JAML.exe'
// jarTask = project.tasks.shadowJar jarTask = project.tasks.shadowJar
// fileDescription = 'Just Another Minecraft Launcher' fileDescription = 'Just Another Minecraft Launcher'
// icon = "${projectDir}/src/main/resources/assets/icon.ico"
//} productName = 'JAML'
// version = "$this.version"
//task Build(type: Launch4jLibraryTask) { textVersion = "$this.version"
// mainClassName = 'tech.nevets.jaml.JAML' copyright = "GPL3"
// outfile = 'JAML.exe' companyName = "nevets.tech"
// jarTask = project.tasks.shadowJar downloadUrl = "https://git.nevets.tech/Steven/JAML"
// fileDescription = 'Just Another Minecraft Launcher' bundledJrePath = './jre'
// bundledJre64Bit = true bundledJre64Bit = true
// bundledJrePath = '' bundledJreAsFallback = true
//} }
//
//task winBuild(type: Launch4jLibraryTask) {
// mainClassName = 'tech.nevets.jaml.JAML'
// outfile = 'JAML.exe'
// jarTask = project.tasks.shadowJar
// fileDescription = 'Just Another Minecraft Launcher'
// bundledJre64Bit = true
// bundledJrePath = ''
//}

View File

@ -52,6 +52,8 @@ public class Config {
YML_FILE.setComment("launcher.default-profile", "Set's the profile that will be loaded automatically"); YML_FILE.setComment("launcher.default-profile", "Set's the profile that will be loaded automatically");
YML_FILE.addDefault("launcher.path","default"); YML_FILE.addDefault("launcher.path","default");
YML_FILE.setComment("launcher.path","Path to JAML files\n" + "default: " + JAML.path.toString()); YML_FILE.setComment("launcher.path","Path to JAML files\n" + "default: " + JAML.path.toString());
YML_FILE.addDefault("launcher.keep-open", false);
YML_FILE.setComment("launcher.keep-open", "Keeps the launcher open after launching the game");
YML_FILE.addDefault("launcher.first-launch", true); YML_FILE.addDefault("launcher.first-launch", true);
YML_FILE.setComment("launcher.first-launch", "Do Not Change, will regenerate files"); YML_FILE.setComment("launcher.first-launch", "Do Not Change, will regenerate files");
YML_FILE.addDefault("launcher.verbose", false); YML_FILE.addDefault("launcher.verbose", false);

View File

@ -9,8 +9,8 @@ public class JAML {
public static GuiHandler guiHandler; public static GuiHandler guiHandler;
public static void main(String[] args) { public static void main(String[] args) {
//TODO Create logic to check for first launch without the use of config
//TODO make guiHandler run first with the initial splash screen while backend is starting, then start homeGui when done. (Possibly multithreaded) //TODO make bash script for jenkins to download optimized jre and bundle it with launch4j
GuiHandler.startup(); GuiHandler.startup();

View File

@ -1,5 +1,6 @@
package tech.nevets.jaml; package tech.nevets.jaml;
import tech.nevets.jaml.events.LaunchEvent;
import tech.nevets.jaml.util.ProfileUtils; import tech.nevets.jaml.util.ProfileUtils;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -7,9 +8,9 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
public class Launch { public class Launcher {
public Launch(int jdkVersion, int memoryAmount, String garbageCollection, boolean printConsole) throws IOException { public Launcher(int jdkVersion, int memoryAmount, String garbageCollection, boolean printConsole) throws IOException {
ArrayList<String> commandArray = parseCommand(jdkVersion, memoryAmount, garbageCollection); ArrayList<String> commandArray = parseCommand(jdkVersion, memoryAmount, garbageCollection);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -22,6 +23,9 @@ public class Launch {
System.out.println(command); System.out.println(command);
LaunchEvent e = new LaunchEvent();
e.triggerEvent();
ProcessBuilder process = new ProcessBuilder(); ProcessBuilder process = new ProcessBuilder();
process.directory(ProfileUtils.activeProfile.getGamePath()); process.directory(ProfileUtils.activeProfile.getGamePath());
process.command(command); process.command(command);

View File

@ -0,0 +1,27 @@
package tech.nevets.jaml.events;
import tech.nevets.jaml.Config;
import tech.nevets.jaml.gui.GuiHandler;
import tech.nevets.jaml.listeners.LaunchListener;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
public class LaunchEvent {
private List<LaunchListener> listeners = new ArrayList<>();
public void addListener(LaunchListener eventListener) {
listeners.add(eventListener);
}
public void triggerEvent() {
if (!Config.CONFIG.getBoolean("launcher.keep-open")) {
for (LaunchListener ll : listeners){
for (JFrame frame : GuiHandler.frames) {
ll.hideGui(frame);
}
}
}
}
}

View File

@ -6,6 +6,8 @@ import tech.nevets.jaml.util.ProfileUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -15,6 +17,12 @@ public class FirstLoginGui extends JFrame {
public FirstLoginGui() { public FirstLoginGui() {
setResizable(false); setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
removeFromArray();
}
});
setBounds(100, 100, 360, 330); setBounds(100, 100, 360, 330);
contentPane = new JPanel(); contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
@ -90,4 +98,8 @@ public class FirstLoginGui extends JFrame {
}); });
contentPane.add(button); contentPane.add(button);
} }
private void removeFromArray() {
GuiHandler.removeFromFramesArray(this);
}
} }

View File

@ -1,10 +1,10 @@
package tech.nevets.jaml.gui; package tech.nevets.jaml.gui;
import tech.nevets.jaml.Config; import tech.nevets.jaml.Config;
import tech.nevets.jaml.JAML;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.util.ArrayList;
public class GuiHandler { public class GuiHandler {
@ -12,8 +12,16 @@ public class GuiHandler {
public static final int SCREEN_HEIGHT = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); public static final int SCREEN_HEIGHT = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
private static StartupGui startupFrame; private static StartupGui startupFrame;
public static ArrayList<JFrame> frames = new ArrayList<>();
public GuiHandler() { public GuiHandler() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
e.printStackTrace();
System.out.println("Using default look and feel");
}
if (Config.getConfig().getBoolean("launcher.first-launch")) { if (Config.getConfig().getBoolean("launcher.first-launch")) {
FirstLaunchGui firstLaunchGui = new FirstLaunchGui(); FirstLaunchGui firstLaunchGui = new FirstLaunchGui();
Thread firstLaunchThread = new Thread(firstLaunchGui); Thread firstLaunchThread = new Thread(firstLaunchGui);
@ -22,12 +30,14 @@ public class GuiHandler {
startupFrame.dispose(); startupFrame.dispose();
Thread homeGuiThread = new Thread(() -> { Thread homeGuiThread = new Thread(() -> {
HomeGui frame = new HomeGui(); HomeGui homeFrame = new HomeGui();
frame.setTitle("JAML"); homeFrame.setTitle("JAML");
frame.setIconImage(new ImageIcon(JAML.path + "\\assets\\icon.png").getImage()); homeFrame.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("assets/icon.png")).getImage());
frame.setLocationRelativeTo(null); homeFrame.setLocationRelativeTo(null);
frame.setVisible(true); homeFrame.setVisible(true);
addToFramesArray(homeFrame);
}); });
homeGuiThread.start(); homeGuiThread.start();
@ -39,12 +49,20 @@ public class GuiHandler {
public void startNewProfileGui() { public void startNewProfileGui() {
Thread newProfileGuiThread = new Thread(() -> { Thread newProfileGuiThread = new Thread(() -> {
NewProfileGui frame = new NewProfileGui(); NewProfileGui newProfileFrame = new NewProfileGui();
frame.setTitle("Create New Profile"); newProfileFrame.setTitle("Create New Profile");
frame.setIconImage(new ImageIcon(JAML.path + "\\assets\\icon.png").getImage()); newProfileFrame.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("assets/icon.png")).getImage());
frame.setVisible(true); newProfileFrame.setVisible(true);
addToFramesArray(newProfileFrame);
}); });
newProfileGuiThread.start(); newProfileGuiThread.start();
} }
public static void addToFramesArray(JFrame frame) {
frames.add(frame);
}
public static void removeFromFramesArray(JFrame frame) {
frames.remove(frame);
}
} }

View File

@ -1,15 +1,15 @@
package tech.nevets.jaml.gui; package tech.nevets.jaml.gui;
import tech.nevets.jaml.JAML;
import tech.nevets.jaml.gui.panels.HomePanel; import tech.nevets.jaml.gui.panels.HomePanel;
import tech.nevets.jaml.gui.panels.ProfilePanel; import tech.nevets.jaml.gui.panels.ProfilePanel;
import tech.nevets.jaml.gui.panels.UsersPanel; import tech.nevets.jaml.gui.panels.UsersPanel;
import tech.nevets.jaml.listeners.RightClickListener; import tech.nevets.jaml.listeners.RightClickListener;
import tech.nevets.jaml.util.ImageUtils;
import tech.nevets.jaml.util.ProfileUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class HomeGui extends JFrame { public class HomeGui extends JFrame {
@ -25,6 +25,12 @@ public class HomeGui extends JFrame {
SpringLayout springLayout = new SpringLayout(); SpringLayout springLayout = new SpringLayout();
getContentPane().setLayout(springLayout); getContentPane().setLayout(springLayout);
addMouseListener(new RightClickListener()); addMouseListener(new RightClickListener());
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
removeFromArray();
}
});
tabPanel = new JTabbedPane(); tabPanel = new JTabbedPane();
springLayout.putConstraint(SpringLayout.NORTH, tabPanel, 0, SpringLayout.NORTH, getContentPane()); springLayout.putConstraint(SpringLayout.NORTH, tabPanel, 0, SpringLayout.NORTH, getContentPane());
@ -48,4 +54,8 @@ public class HomeGui extends JFrame {
tabPanel.addMouseListener(new RightClickListener()); tabPanel.addMouseListener(new RightClickListener());
} }
private void removeFromArray() {
GuiHandler.removeFromFramesArray(this);
}
} }

View File

@ -6,6 +6,8 @@ import tech.nevets.jaml.util.ProfileUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -17,7 +19,14 @@ public class NewProfileGui extends JFrame {
setUndecorated(true); setUndecorated(true);
setResizable(false); setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
removeFromArray();
}
});
setBounds(100, 100, 360, 330); setBounds(100, 100, 360, 330);
setLocationRelativeTo(null);
contentPane = new JPanel(); contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane); setContentPane(contentPane);
@ -92,6 +101,10 @@ public class NewProfileGui extends JFrame {
}); });
contentPane.add(button); contentPane.add(button);
} }
private void removeFromArray() {
GuiHandler.removeFromFramesArray(this);
}
} }

View File

@ -13,11 +13,13 @@ import java.nio.file.Path;
public class StartupGui extends JFrame { public class StartupGui extends JFrame {
JPanel contentPane; JPanel contentPane;
private static JLabel currentTaskLabel;
public StartupGui() { public StartupGui() {
setUndecorated(true); setUndecorated(true);
setResizable(false); setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setIconImage(new ImageIcon(getClass().getClassLoader().getResource("assets/icon.png")).getImage());
setSize(GuiHandler.SCREEN_WIDTH / 3, GuiHandler.SCREEN_HEIGHT / 3); setSize(GuiHandler.SCREEN_WIDTH / 3, GuiHandler.SCREEN_HEIGHT / 3);
contentPane = new JPanel(); contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
@ -25,6 +27,10 @@ public class StartupGui extends JFrame {
contentPane.setLayout(null); contentPane.setLayout(null);
setLocationRelativeTo(null); setLocationRelativeTo(null);
currentTaskLabel = new JLabel("");
currentTaskLabel.setBounds(30, 279, 176, 20);
contentPane.add(currentTaskLabel);
int pbWidth = (int) (getWidth() / 1.1); int pbWidth = (int) (getWidth() / 1.1);
int pbHeight = getHeight() / 24; int pbHeight = getHeight() / 24;
int pbX = (getWidth() - pbWidth) / 2; int pbX = (getWidth() - pbWidth) / 2;
@ -52,22 +58,24 @@ public class StartupGui extends JFrame {
progressBar.setProgress(0); progressBar.setProgress(0);
currentTaskLabel.setText("Making Directories...");
makeDirs(); makeDirs();
smoothIncrease(progressBar, 20); smoothIncrease(progressBar, 20);
currentTaskLabel.setText("Loading Config...");
currentTaskLabel.repaint();
Config.loadConfig(); Config.loadConfig();
sleep();
smoothIncrease(progressBar, 40); smoothIncrease(progressBar, 40);
currentTaskLabel.setText("Loading Profiles...");
ProfileUtils.getProfileList(); ProfileUtils.getProfileList();
sleep();
smoothIncrease(progressBar, 60); smoothIncrease(progressBar, 60);
currentTaskLabel.setText("Loading Active Profile...");
ProfileUtils.getActiveProfile(); ProfileUtils.getActiveProfile();
sleep();
smoothIncrease(progressBar, 80); smoothIncrease(progressBar, 80);
currentTaskLabel.setText("Getting Game Loaders...");
LoaderUtils.getLoaders(); LoaderUtils.getLoaders();
sleep(); currentTaskLabel.setText("Done!");
smoothIncrease(progressBar, 100); smoothIncrease(progressBar, 100);
} }
private static void sleep() { private static void sleep() {
@ -78,6 +86,10 @@ public class StartupGui extends JFrame {
} }
} }
public static void setCurrentTask(String currentTask) {
currentTaskLabel.setText(currentTask);
}
private static void makeDirs() { private static void makeDirs() {
if (System.getenv("JAML_HOME") == null) { if (System.getenv("JAML_HOME") == null) {
JAML.path = Path.of(System.getenv("APPDATA") + "\\.jaml\\"); JAML.path = Path.of(System.getenv("APPDATA") + "\\.jaml\\");
@ -134,11 +146,6 @@ public class StartupGui extends JFrame {
int i = pb.getProgress(); int i = pb.getProgress();
while (i <= to) { while (i <= to) {
pb.setProgress(i); pb.setProgress(i);
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
i += 1; i += 1;
} }
} }

View File

@ -38,7 +38,7 @@ public class HomePanel extends JPanel {
JLabel backgroundIcon = new JLabel(""); JLabel backgroundIcon = new JLabel("");
backgroundIcon.setBounds(0, 25, 1264, 542); backgroundIcon.setBounds(0, 25, 1264, 542);
ImageIcon backgroundImg = new ImageIcon(JAML.path + "\\assets\\background.png"); ImageIcon backgroundImg = new ImageIcon(getClass().getClassLoader().getResource("assets/background.png"));
backgroundImg = ImageUtils.resizeIcon(backgroundImg, backgroundIcon.getWidth(), backgroundIcon.getHeight()); backgroundImg = ImageUtils.resizeIcon(backgroundImg, backgroundIcon.getWidth(), backgroundIcon.getHeight());
backgroundIcon.setIcon(backgroundImg); backgroundIcon.setIcon(backgroundImg);
add(backgroundIcon); add(backgroundIcon);

View File

@ -0,0 +1,16 @@
package tech.nevets.jaml.listeners;
import javax.swing.*;
import java.util.EventListener;
public class LaunchListener implements EventListener {
public void hideGui(JFrame frame) {
frame.setVisible(false);
System.out.println("Frame: " + frame.getName() + " was hidden!");
}
public void closeGui(JFrame frame) {
frame.dispose();
System.out.println("Frame: " + frame.getName() + " was closed!");
}
}

View File

@ -2,7 +2,6 @@ package tech.nevets.jaml.listeners;
import tech.nevets.jaml.gui.RightClickGui; import tech.nevets.jaml.gui.RightClickGui;
import java.awt.*;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 706 KiB

View File

@ -0,0 +1,5 @@
```
#!/bin/bash
java -Xms16G -Xmx16G -Dlog4j2.formatMsgNoLookups=true -Dlog4j.configurationFile=assets/log_configs/client-1.12.xml "-DFabricMcEmu= net.minecraft.client.main.Main " "-Djava.library.path=versions/1.18.2/natives" "-cp" "libraries/com/mojang/logging/1.0.0/logging-1.0.0.jar:libraries/com/mojang/blocklist/1.0.10/blocklist-1.0.10.jar:libraries/com/mojang/patchy/2.2.10/patchy-2.2.10.jar:libraries/com/github/oshi/oshi-core/5.8.5/oshi-core-5.8.5.jar:libraries/net/java/dev/jna/jna/5.10.0/jna-5.10.0.jar:libraries/net/java/dev/jna/jna-platform/5.10.0/jna-platform-5.10.0.jar:libraries/org/slf4j/slf4j-api/1.8.0-beta4/slf4j-api-1.8.0-beta4.jar:libraries/org/apache/logging/log4j/log4j-slf4j18-impl/2.17.0/log4j-slf4j18-impl-2.17.0.jar:libraries/com/ibm/icu/icu4j/70.1/icu4j-70.1.jar:libraries/com/mojang/javabridge/1.2.24/javabridge-1.2.24.jar:libraries/net/sf/jopt-simple/jopt-simple/5.0.4/jopt-simple-5.0.4.jar:libraries/io/netty/netty-all/4.1.68.Final/netty-all-4.1.68.Final.jar:libraries/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:libraries/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar:libraries/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar:libraries/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar:libraries/commons-codec/commons-codec/1.15/commons-codec-1.15.jar:libraries/com/mojang/brigadier/1.0.18/brigadier-1.0.18.jar:libraries/com/mojang/datafixerupper/4.1.27/datafixerupper-4.1.27.jar:libraries/com/google/code/gson/gson/2.8.9/gson-2.8.9.jar:libraries/com/mojang/authlib/3.3.39/authlib-3.3.39.jar:libraries/org/apache/commons/commons-compress/1.21/commons-compress-1.21.jar:libraries/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar:libraries/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:libraries/org/apache/httpcomponents/httpcore/4.4.14/httpcore-4.4.14.jar:libraries/it/unimi/dsi/fastutil/8.5.6/fastutil-8.5.6.jar:libraries/org/apache/logging/log4j/log4j-api/2.17.0/log4j-api-2.17.0.jar:libraries/org/apache/logging/log4j/log4j-core/2.17.0/log4j-core-2.17.0.jar:libraries/org/lwjgl/lwjgl/3.2.2/lwjgl-3.2.2.jar:libraries/org/lwjgl/lwjgl-jemalloc/3.2.2/lwjgl-jemalloc-3.2.2.jar:libraries/org/lwjgl/lwjgl-openal/3.2.2/lwjgl-openal-3.2.2.jar:libraries/org/lwjgl/lwjgl-opengl/3.2.2/lwjgl-opengl-3.2.2.jar:libraries/org/lwjgl/lwjgl-glfw/3.2.2/lwjgl-glfw-3.2.2.jar:libraries/org/lwjgl/lwjgl-stb/3.2.2/lwjgl-stb-3.2.2.jar:libraries/org/lwjgl/lwjgl-tinyfd/3.2.2/lwjgl-tinyfd-3.2.2.jar:libraries/com/mojang/text2speech/1.12.4/text2speech-1.12.4.jar:versions/fabric-loader-0.13.3-1.18.2/fabric-loader-0.13.3-1.18.2.jar" net.minecraft.client.Main --username <your username here> --version 1.18.2 --gameDir . --assetsDir assets --assetIndex 1.18 --uuid <your uuid here> --accessToken 00000000000000000000000000000000 --clientId 0000 --xuid 0000 --userType mojang --versionType release
```