Periodic Update
This commit is contained in:
parent
1733b43270
commit
89a9976c32
10
.idea/inspectionProfiles/Project_Default.xml
Normal file
10
.idea/inspectionProfiles/Project_Default.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<Languages>
|
||||||
|
<language minSize="49" name="Java" />
|
||||||
|
</Languages>
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
@ -2,7 +2,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/LauncherExe/LauncherExe.iml" filepath="$PROJECT_DIR$/LauncherExe/LauncherExe.iml" />
|
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
7
LauncherExe/Cargo.lock
generated
7
LauncherExe/Cargo.lock
generated
@ -1,7 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
version = 3
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "LauncherExe"
|
|
||||||
version = "0.1.0"
|
|
@ -1,8 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "LauncherExe"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="GENERAL_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$/..">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
@ -1,16 +0,0 @@
|
|||||||
use std::process::Command;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
|
|
||||||
let mut cmd = Command::new("java");
|
|
||||||
cmd.arg("-jar");
|
|
||||||
cmd.arg("JAML.jar");
|
|
||||||
|
|
||||||
match cmd.output() {
|
|
||||||
Ok(output) => {
|
|
||||||
},
|
|
||||||
Err(e) => {
|
|
||||||
println!("{}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'tech.nevets.jaml'
|
group 'tech.nevets.jaml'
|
||||||
version '0.4.0'
|
version '0.4.1'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -26,6 +26,7 @@ dependencies {
|
|||||||
implementation 'me.carleslc.Simple-YAML:Simple-Yaml:1.7.3'
|
implementation 'me.carleslc.Simple-YAML:Simple-Yaml:1.7.3'
|
||||||
implementation 'com.google.code.gson:gson:2.9.0'
|
implementation 'com.google.code.gson:gson:2.9.0'
|
||||||
implementation 'net.arikia.dev:drpc:1.0'
|
implementation 'net.arikia.dev:drpc:1.0'
|
||||||
|
implementation 'commons-io:commons-io:2.11.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
|
@ -5,17 +5,17 @@ import org.simpleyaml.configuration.file.YamlFile;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
private static final YamlFile ymlFile = new YamlFile(JAML.path + "\\config.yml");
|
private static final YamlFile YML_FILE = new YamlFile(JAML.path + "\\config.yml");
|
||||||
|
|
||||||
public static void loadConfig() {
|
public static void loadConfig() {
|
||||||
try {
|
try {
|
||||||
if (!ymlFile.exists()) {
|
if (!YML_FILE.exists()) {
|
||||||
System.out.println("Config file not found, creating new one...");
|
System.out.println("Config file not found, creating new one...");
|
||||||
ymlFile.createNewFile(true);
|
YML_FILE.createNewFile(true);
|
||||||
System.out.println("Config file created!");
|
System.out.println("Config file created!");
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Loading Config file...");
|
System.out.println("Loading Config file...");
|
||||||
ymlFile.loadWithComments();
|
YML_FILE.loadWithComments();
|
||||||
System.out.println("Config file loaded!");
|
System.out.println("Config file loaded!");
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
@ -23,25 +23,55 @@ public class Config {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
ymlFile.addDefault("java.jdk8", "");
|
YML_FILE.setComment("java",
|
||||||
ymlFile.addDefault("java.jdk16", "");
|
"\n"
|
||||||
ymlFile.addDefault("java.jdk17", "");
|
+ " JJJJJJJJJJJ AAA MMMMMMMM MMMMMMMM LLLLLLLLLLL \n"
|
||||||
ymlFile.addDefault("launcher.default-profile", "default");
|
+ " J:::::::::J A:::A M:::::::M M:::::::M L:::::::::L \n"
|
||||||
ymlFile.addDefault("launcher.path","default");
|
+ " J:::::::::J A:::::A M::::::::M M::::::::M L:::::::::L \n"
|
||||||
ymlFile.setComment("launcher.path","Path to JAML files\n" + "default: " + JAML.path.toString());
|
+ " JJ:::::::JJ A:::::::A M:::::::::M M:::::::::M LL:::::::LL \n"
|
||||||
ymlFile.addDefault("launcher.verbose", false);
|
+ " J:::::J A:::::::::A M::::::::::M M::::::::::M L:::::L \n"
|
||||||
ymlFile.setComment("launcher.verbose", "If true, will print out all the messages");
|
+ " J:::::J A:::::A:::::A M:::::::::::M M:::::::::::M L:::::L \n"
|
||||||
ymlFile.addDefault("launcher.version", "0.1.0");
|
+ " J:::::J A:::::A A:::::A M:::::::M::::M M::::M:::::::M L:::::L \n"
|
||||||
ymlFile.setComment("launcher.version", "Jaml version, don't change it!");
|
+ " J:::::j A:::::A A:::::A M::::::M M::::M M::::M M::::::M L:::::L \n"
|
||||||
|
+ " J:::::J A:::::A A:::::A M::::::M M::::M::::M M::::::M L:::::L \n"
|
||||||
|
+ " JJJJJJJ J:::::J A:::::AAAAAAAAA:::::A M::::::M M:::::::M M::::::M L:::::L \n"
|
||||||
|
+ " J:::::J J:::::J A:::::::::::::::::::::A M::::::M M:::::M M::::::M L:::::L \n"
|
||||||
|
+ " J::::::J J::::::J A:::::AAAAAAAAAAAAA:::::A M::::::M MMMMM M::::::M L:::::L LLLLLL\n"
|
||||||
|
+ " J:::::::JJJ:::::::J A:::::A A:::::A M::::::M M::::::M LL:::::::LLLLLLLLL:::::L\n"
|
||||||
|
+ " JJ:::::::::::::JJ A:::::A A:::::A M::::::M M::::::M L::::::::::::::::::::::L\n"
|
||||||
|
+ " JJ:::::::::JJ A:::::A A:::::A M::::::M M::::::M L::::::::::::::::::::::L\n"
|
||||||
|
+ " JJJJJJJJJ AAAAAAA AAAAAAA MMMMMMMM MMMMMMMM LLLLLLLLLLLLLLLLLLLLLLLL\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
YML_FILE.addDefault("java.jdk8", "");
|
||||||
|
YML_FILE.setComment("java.jdk8", "Set these to the bin directory of each JDK version");
|
||||||
|
YML_FILE.addDefault("java.jdk16", "");
|
||||||
|
YML_FILE.addDefault("java.jdk17", "");
|
||||||
|
YML_FILE.addDefault("launcher.default-profile", "default");
|
||||||
|
YML_FILE.setComment("launcher.default-profile", "Set's the profile that will be loaded automatically");
|
||||||
|
YML_FILE.addDefault("launcher.path","default");
|
||||||
|
YML_FILE.setComment("launcher.path","Path to JAML files\n" + "default: " + JAML.path.toString());
|
||||||
|
YML_FILE.addDefault("launcher.first-launch", true);
|
||||||
|
YML_FILE.setComment("launcher.first-launch", "Do Not Change, will regenerate files");
|
||||||
|
YML_FILE.addDefault("launcher.verbose", false);
|
||||||
|
YML_FILE.setComment("launcher.verbose", "If true, will print out all the messages");
|
||||||
|
YML_FILE.addDefault("launcher.version", "0.1.0");
|
||||||
|
YML_FILE.setComment("launcher.version", "Jaml version, don't change it!");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ymlFile.save();
|
YML_FILE.save();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static YamlFile getConfig() {
|
public static YamlFile getConfig() {
|
||||||
return ymlFile;
|
return YML_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void reloadConfig() {
|
||||||
|
CONFIG = getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static YamlFile CONFIG = getConfig();
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,14 @@ import net.arikia.dev.drpc.DiscordRPC;
|
|||||||
import net.arikia.dev.drpc.DiscordRichPresence;
|
import net.arikia.dev.drpc.DiscordRichPresence;
|
||||||
|
|
||||||
public class DiscordRP {
|
public class DiscordRP {
|
||||||
//TODO Make this actually work
|
private static boolean running = true;
|
||||||
|
private static long created = 0;
|
||||||
|
|
||||||
private boolean running = true;
|
public static void start() {
|
||||||
private long created = 0;
|
created = System.currentTimeMillis();
|
||||||
|
|
||||||
public void start() {
|
DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler(user -> {
|
||||||
this.created = System.currentTimeMillis();
|
System.out.println("Welcome " + user.username + "#" + user.discriminator + "!");
|
||||||
|
|
||||||
DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> {
|
|
||||||
System.out.println("Welcome " + user.username + "#" + user.discriminator + ".");
|
|
||||||
update("Starting...", "");
|
update("Starting...", "");
|
||||||
}).build();
|
}).build();
|
||||||
|
|
||||||
@ -28,12 +26,12 @@ public class DiscordRP {
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public static void shutdown() {
|
||||||
running = false;
|
running = false;
|
||||||
DiscordRPC.discordShutdown();
|
DiscordRPC.discordShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(String firstLine, String secondLine) {
|
public static void update(String firstLine, String secondLine) {
|
||||||
DiscordRichPresence.Builder b = new DiscordRichPresence.Builder(secondLine);
|
DiscordRichPresence.Builder b = new DiscordRichPresence.Builder(secondLine);
|
||||||
b.setBigImage("large", "");
|
b.setBigImage("large", "");
|
||||||
b.setDetails(firstLine);
|
b.setDetails(firstLine);
|
||||||
|
16
src/main/java/tech/nevets/jaml/FirstLaunch.java
Normal file
16
src/main/java/tech/nevets/jaml/FirstLaunch.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package tech.nevets.jaml;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class FirstLaunch {
|
||||||
|
public FirstLaunch() {
|
||||||
|
System.out.println("First Launch!");
|
||||||
|
|
||||||
|
Config.CONFIG.set("launcher.first-launch", false);
|
||||||
|
try {
|
||||||
|
Config.CONFIG.save();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,36 +1,47 @@
|
|||||||
package tech.nevets.jaml;
|
package tech.nevets.jaml;
|
||||||
|
|
||||||
|
import net.arikia.dev.drpc.DiscordRPC;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.simpleyaml.configuration.file.YamlFile;
|
import org.simpleyaml.configuration.file.YamlFile;
|
||||||
import tech.nevets.jaml.gui.GuiHandler;
|
import tech.nevets.jaml.gui.GuiHandler;
|
||||||
|
import tech.nevets.jaml.util.VersionFetcher;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
public class JAML {
|
public class JAML {
|
||||||
public static YamlFile config;
|
public static YamlFile config = Config.CONFIG;
|
||||||
public static Path path;
|
public static Path path;
|
||||||
public static DiscordRP drp = new DiscordRP();
|
|
||||||
public static GuiHandler guiHandler;
|
public static GuiHandler guiHandler;
|
||||||
public static Profile activeProfile;
|
public static Profile activeProfile;
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
DiscordRP.start();
|
||||||
makeDirs();
|
makeDirs();
|
||||||
Config.loadConfig();
|
Config.loadConfig();
|
||||||
config = Config.getConfig();
|
DiscordRP.update("", "");
|
||||||
|
guiHandler = new GuiHandler();
|
||||||
|
|
||||||
|
Launch.main(new String[]{});
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// System.out.println(VersionFetcher.getLatestVersion("release"));
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Profiles pfs = new Profiles();
|
activeProfile = Profiles.loadProfile(config.getString("launcher.default-profile"));
|
||||||
activeProfile = pfs.loadProfile(config.getString("launcher.default-profile"));
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Unable to load default profile: " + e.getMessage());
|
System.out.println("Unable to load default profile: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
drp.start();
|
|
||||||
|
|
||||||
guiHandler = new GuiHandler();
|
|
||||||
|
|
||||||
drp.shutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void makeDirs() {
|
private static void makeDirs() {
|
||||||
@ -69,5 +80,29 @@ public class JAML {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Path dataPath = Path.of(path + "\\data\\");
|
||||||
|
if (!dataPath.toFile().exists()) {
|
||||||
|
dataPath.toFile().mkdirs();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
copyAssets();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copyAssets() throws IOException, URISyntaxException {
|
||||||
|
URL resource = JAML.class.getResource("/assets/");
|
||||||
|
File assets = Paths.get(resource.toURI()).toFile();
|
||||||
|
|
||||||
|
if (!Path.of(path + "\\data\\").toFile().exists()) {
|
||||||
|
FileUtils.copyDirectory(assets, new File(path + "\\assets\\"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,18 +1,70 @@
|
|||||||
package tech.nevets.jaml;
|
package tech.nevets.jaml;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Launch {
|
public class Launch {
|
||||||
public static void launch() {
|
|
||||||
String[] command = {"echo", "Hello, World!"};
|
public static void main(String[] args) {
|
||||||
ProcessBuilder builder = new ProcessBuilder(command);
|
|
||||||
builder.directory(new File(JAML.path + "\\process"));
|
|
||||||
try {
|
try {
|
||||||
Process process = builder.start();
|
new Launch(parseCommand(17, 4096, "-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M "), true);
|
||||||
} catch (IOException ex) {
|
} catch (IOException e) {
|
||||||
ex.printStackTrace();
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Launch(ArrayList<String> commandArray, boolean printConsole) throws IOException {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
for (String commandString : commandArray) {
|
||||||
|
sb.append(commandString);
|
||||||
|
sb.append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
String command = sb.toString();
|
||||||
|
|
||||||
|
System.out.println(command);
|
||||||
|
|
||||||
|
Process process = Runtime.getRuntime().exec(command);
|
||||||
|
|
||||||
|
if (printConsole) {
|
||||||
|
printResults(process);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<String> parseCommand(int jdkVersion, int memoryAmount, String garbageCollection) {
|
||||||
|
ArrayList<String> cmd = new ArrayList<String>();
|
||||||
|
if (jdkVersion == 8) {
|
||||||
|
cmd.add(("\"" + Config.CONFIG.getString("java.jdk8") + "\\javaw.exe\""));
|
||||||
|
} else if (jdkVersion == 16) {
|
||||||
|
cmd.add(("\"" + Config.CONFIG.getString("java.jdk16") + "\\javaw.exe\""));
|
||||||
|
} else if (jdkVersion == 17) {
|
||||||
|
cmd.add(("\"" + Config.CONFIG.getString("java.jdk17") + "\\java.exe\""));
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.add(("-Xmx" + memoryAmount + "M"));
|
||||||
|
cmd.add(("-Xms" + memoryAmount + "M"));
|
||||||
|
cmd.add((garbageCollection));
|
||||||
|
cmd.add("-Dlog4j2.formatMsgNoLookups=true -Dlog4j.configurationFile=assets\\log_configs\\client-1.12.xml");
|
||||||
|
cmd.add("-Djava.library.path=versions\\1.18.1\\natives\" \"-cp\" \"libraries\\com\\mojang\\blocklist\\1.0.6\\blocklist-1.0.6.jar;libraries\\com\\mojang\\patchy\\2.1.6\\patchy-2.1.6.jar;libraries\\com\\github\\oshi\\oshi-core\\5.8.2\\oshi-core-5.8.2.jar;libraries\\net\\java\\dev\\jna\\jna\\5.9.0\\jna-5.9.0.jar;libraries\\net\\java\\dev\\jna\\jna-platform\\5.9.0\\jna-platform-5.9.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.14.1\\log4j-slf4j18-impl-2.14.1.jar;libraries\\com\\ibm\\icu\\icu4j\\69.1\\icu4j-69.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.0.26\\datafixerupper-4.0.26.jar;libraries\\com\\google\\code\\gson\\gson\\2.8.8\\gson-2.8.8.jar;libraries\\com\\mojang\\authlib\\3.2.38\\authlib-3.2.38.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.14.1\\log4j-api-2.14.1.jar;libraries\\org\\apache\\logging\\log4j\\log4j-core\\2.14.1\\log4j-core-2.14.1.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.11.3\\text2speech-1.11.3.jar;versions\\1.18.1\\1.18.1.jar\"");
|
||||||
|
cmd.add("net.minecraft.client.main.Main");
|
||||||
|
cmd.add("--username Name --version 1.18.1 --gameDir . --assetsDir assets --assetIndex 1.18 --uuid 0f28983a46ce33b1aed45cdc95bf44c3 --accessToken 00000000000000000000000000000000 --clientId 0000 --xuid 0000 --userType mojang --versionType release");
|
||||||
|
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void printResults(Process process) throws IOException {
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
String line = "";
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
System.out.println(line);
|
||||||
}
|
}
|
||||||
System.exit(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,11 +6,11 @@ import java.io.*;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class Profiles {
|
public class Profiles {
|
||||||
private static final Path profilePath = Path.of(JAML.path + "\\profiles\\");
|
private static final Path PROFILE_PATH = Path.of(JAML.path + "\\profiles\\");
|
||||||
|
|
||||||
public static void createProfile(Profile profile) throws IOException {
|
public static void createProfile(Profile profile) throws IOException {
|
||||||
String profileName = profile.getProfileName();
|
String profileName = profile.getProfileName();
|
||||||
Writer writer = new FileWriter(profilePath + "\\" + profileName + ".json");
|
Writer writer = new FileWriter(PROFILE_PATH + "\\" + profileName + ".json");
|
||||||
|
|
||||||
GsonBuilder builder = new GsonBuilder();
|
GsonBuilder builder = new GsonBuilder();
|
||||||
builder.setPrettyPrinting();
|
builder.setPrettyPrinting();
|
||||||
@ -18,12 +18,13 @@ public class Profiles {
|
|||||||
String jsonString = gson.toJson(profile);
|
String jsonString = gson.toJson(profile);
|
||||||
writer.write(jsonString);
|
writer.write(jsonString);
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
|
loadProfile(profileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Profile loadProfile(String profileName) throws FileNotFoundException {
|
public static Profile loadProfile(String profileName) throws FileNotFoundException {
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(profilePath + "\\" + profileName + ".json"));
|
BufferedReader reader = new BufferedReader(new FileReader(PROFILE_PATH + "\\" + profileName + ".json"));
|
||||||
Profile profile = new Gson().fromJson(reader, Profile.class);
|
|
||||||
|
|
||||||
return profile;
|
return new Gson().fromJson(reader, Profile.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
41
src/main/java/tech/nevets/jaml/Version.java
Normal file
41
src/main/java/tech/nevets/jaml/Version.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package tech.nevets.jaml;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class Version {
|
||||||
|
private String id;
|
||||||
|
private String type;
|
||||||
|
private URL url;
|
||||||
|
|
||||||
|
public Version() {}
|
||||||
|
|
||||||
|
public Version(String id, String type, URL url) {
|
||||||
|
this.id = id;
|
||||||
|
this.type = type;
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URL getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(URL url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
}
|
126
src/main/java/tech/nevets/jaml/gui/FirstLaunchGui.java
Normal file
126
src/main/java/tech/nevets/jaml/gui/FirstLaunchGui.java
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
package tech.nevets.jaml.gui;
|
||||||
|
|
||||||
|
import tech.nevets.jaml.FirstLaunch;
|
||||||
|
import tech.nevets.jaml.JAML;
|
||||||
|
import tech.nevets.jaml.Profile;
|
||||||
|
import tech.nevets.jaml.Profiles;
|
||||||
|
import tech.nevets.jaml.util.Encryptor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public class FirstLaunchGui implements Runnable, ActionListener {
|
||||||
|
//TODO Formatting
|
||||||
|
private JFrame frame;
|
||||||
|
private JPanel panel;
|
||||||
|
|
||||||
|
private JTextField emailField;
|
||||||
|
private JPasswordField passwordField;
|
||||||
|
private JTextField gamePathField;
|
||||||
|
private JTextField versionField;
|
||||||
|
private JTextField loaderField;
|
||||||
|
private JTextField offlineModeField;
|
||||||
|
|
||||||
|
public void startGui() {
|
||||||
|
frame = new JFrame("Create First Profile");
|
||||||
|
|
||||||
|
JLabel emailLabel = new JLabel("Email:");
|
||||||
|
emailLabel.setBounds(10, 50, 80, 25);
|
||||||
|
emailField = new JTextField(20);
|
||||||
|
|
||||||
|
JLabel passwordLabel = new JLabel("Password:");
|
||||||
|
passwordLabel.setBounds(100, 50, 165, 25);
|
||||||
|
passwordField = new JPasswordField(20);
|
||||||
|
|
||||||
|
JLabel gamePathLabel = new JLabel("Game Path:");
|
||||||
|
gamePathLabel.setBounds(10, 80, 80, 25);
|
||||||
|
gamePathField = new JTextField(20);
|
||||||
|
|
||||||
|
JButton gamePathButton = new JButton("Choose Path");
|
||||||
|
gamePathButton.setBounds(200, 80, 25, 25);
|
||||||
|
gamePathButton.addActionListener(ae -> {
|
||||||
|
JFileChooser fileChooser = new JFileChooser(System.getenv("APPDATA") + "\\.minecraft\\");
|
||||||
|
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
|
fileChooser.showSaveDialog(null);
|
||||||
|
if (fileChooser.getSelectedFile() == null) { return; }
|
||||||
|
gamePathField.setText(fileChooser.getSelectedFile().toString());
|
||||||
|
fileChooser.setVisible(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
JLabel versionLabel = new JLabel("Version:");
|
||||||
|
versionLabel.setBounds(100, 80, 165, 25);
|
||||||
|
versionField = new JTextField(20);
|
||||||
|
|
||||||
|
JLabel loaderLabel = new JLabel("Loader:");
|
||||||
|
loaderLabel.setBounds(10, 110, 80, 25);
|
||||||
|
loaderField = new JTextField(20);
|
||||||
|
|
||||||
|
JLabel offlineModeLabel = new JLabel("Offline Mode:");
|
||||||
|
offlineModeLabel.setBounds(100, 110, 165, 25);
|
||||||
|
offlineModeField = new JTextField(20);
|
||||||
|
|
||||||
|
JButton button = new JButton("Create Profile");
|
||||||
|
button.addActionListener(this);
|
||||||
|
|
||||||
|
panel = new JPanel();
|
||||||
|
panel.setBorder(BorderFactory.createEmptyBorder(300, 300, 100, 300));
|
||||||
|
panel.setLayout(new GridLayout(0, 1));
|
||||||
|
panel.add(emailLabel);
|
||||||
|
panel.add(emailField);
|
||||||
|
panel.add(passwordLabel);
|
||||||
|
panel.add(passwordField);
|
||||||
|
panel.add(gamePathLabel);
|
||||||
|
panel.add(gamePathField);
|
||||||
|
panel.add(gamePathButton);
|
||||||
|
panel.add(versionLabel);
|
||||||
|
panel.add(versionField);
|
||||||
|
panel.add(loaderLabel);
|
||||||
|
panel.add(loaderField);
|
||||||
|
panel.add(offlineModeLabel);
|
||||||
|
panel.add(offlineModeField);
|
||||||
|
panel.add(button);
|
||||||
|
|
||||||
|
frame.add(panel, BorderLayout.CENTER);
|
||||||
|
frame.setSize(500, 500);
|
||||||
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
frame.setTitle("JAML");
|
||||||
|
frame.setIconImage(new ImageIcon(JAML.path + "\\assets\\icon.png").getImage());
|
||||||
|
frame.pack();
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent ae) {
|
||||||
|
Profile profile = new Profile();
|
||||||
|
profile.setProfileName("default");
|
||||||
|
profile.setEmail(emailField.getText());
|
||||||
|
|
||||||
|
if (passwordField.getPassword().length > 0){
|
||||||
|
profile.setHashedPassword(Encryptor.encrypt(String.valueOf(passwordField.getPassword())).getData());
|
||||||
|
profile.setKey(Encryptor.encrypt(String.valueOf(passwordField.getPassword())).getKey());
|
||||||
|
profile.setSalt(Encryptor.encrypt(String.valueOf(passwordField.getPassword())).getSalt());
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.setGamePath(Path.of(gamePathField.getText()));
|
||||||
|
profile.setVersion(versionField.getText());
|
||||||
|
profile.setLoader(loaderField.getText());
|
||||||
|
profile.setOfflineMode(Boolean.parseBoolean(offlineModeField.getText()));
|
||||||
|
try {
|
||||||
|
Profiles.createProfile(profile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
frame.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
new FirstLaunch();
|
||||||
|
startGui();
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,16 @@
|
|||||||
package tech.nevets.jaml.gui;
|
package tech.nevets.jaml.gui;
|
||||||
|
|
||||||
|
import tech.nevets.jaml.Config;
|
||||||
|
|
||||||
public class GuiHandler {
|
public class GuiHandler {
|
||||||
|
|
||||||
public GuiHandler() {
|
public GuiHandler() {
|
||||||
|
if (Config.CONFIG.getBoolean("launcher.first-launch")) {
|
||||||
|
FirstLaunchGui firstLaunchGui = new FirstLaunchGui();
|
||||||
|
Thread firstLaunchThread = new Thread(firstLaunchGui);
|
||||||
|
firstLaunchThread.start();
|
||||||
|
}
|
||||||
|
|
||||||
HomeGui homeGui = new HomeGui();
|
HomeGui homeGui = new HomeGui();
|
||||||
Thread homeGuiThread = new Thread(homeGui);
|
Thread homeGuiThread = new Thread(homeGui);
|
||||||
homeGuiThread.start();
|
homeGuiThread.start();
|
||||||
|
@ -47,7 +47,7 @@ public class NewProfileGui implements Runnable, ActionListener {
|
|||||||
JButton gamePathButton = new JButton("Choose Path");
|
JButton gamePathButton = new JButton("Choose Path");
|
||||||
gamePathButton.setBounds(200, 80, 25, 25);
|
gamePathButton.setBounds(200, 80, 25, 25);
|
||||||
gamePathButton.addActionListener(ae -> {
|
gamePathButton.addActionListener(ae -> {
|
||||||
JFileChooser fileChooser = new JFileChooser(JAML.path.toString());
|
JFileChooser fileChooser = new JFileChooser(System.getenv("APPDATA") + "\\.minecraft\\");
|
||||||
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
fileChooser.showSaveDialog(null);
|
fileChooser.showSaveDialog(null);
|
||||||
if (fileChooser.getSelectedFile() == null) { return; }
|
if (fileChooser.getSelectedFile() == null) { return; }
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
package tech.nevets.jaml.util;
|
package tech.nevets.jaml.util;
|
||||||
|
|
||||||
public class MultiReturn {
|
public class DataCompressor {
|
||||||
|
|
||||||
private String data;
|
private final String data;
|
||||||
private String key;
|
private final String key;
|
||||||
private String salt;
|
private final String salt;
|
||||||
|
|
||||||
public MultiReturn(String data, String key) {
|
public DataCompressor(String data, String key, String salt) {
|
||||||
this.data = data;
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MultiReturn(String data, String key, String salt) {
|
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.salt = salt;
|
this.salt = salt;
|
@ -13,7 +13,7 @@ import java.util.Random;
|
|||||||
|
|
||||||
public class Encryptor {
|
public class Encryptor {
|
||||||
|
|
||||||
public static MultiReturn encrypt(String textToEncrypt) {
|
public static DataCompressor encrypt(String textToEncrypt) {
|
||||||
String key = generateHash();
|
String key = generateHash();
|
||||||
String salt = generateHash();
|
String salt = generateHash();
|
||||||
String hashedData = null;
|
String hashedData = null;
|
||||||
@ -35,12 +35,12 @@ public class Encryptor {
|
|||||||
System.out.println("Error while encrypting: " + e.getMessage());
|
System.out.println("Error while encrypting: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiReturn pair = new MultiReturn(hashedData, key, salt);
|
DataCompressor pair = new DataCompressor(hashedData, key, salt);
|
||||||
|
|
||||||
return pair;
|
return pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String decrypt(MultiReturn pair) {
|
public static String decrypt(DataCompressor pair) {
|
||||||
String hash = pair.getData();
|
String hash = pair.getData();
|
||||||
String key = pair.getKey();
|
String key = pair.getKey();
|
||||||
String salt = pair.getSalt();
|
String salt = pair.getSalt();
|
||||||
|
58
src/main/java/tech/nevets/jaml/util/SemanticVersioner.java
Normal file
58
src/main/java/tech/nevets/jaml/util/SemanticVersioner.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package tech.nevets.jaml.util;
|
||||||
|
|
||||||
|
public class SemanticVersioner implements Comparable<SemanticVersioner> {
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
public SemanticVersioner(String version) {
|
||||||
|
if (version == null) {
|
||||||
|
throw new IllegalArgumentException("Version cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!version.matches("[0-9]+(\\.[0-9]+)*")) {
|
||||||
|
throw new IllegalArgumentException("Invalid version format");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String get() {
|
||||||
|
return this.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(SemanticVersioner sv) {
|
||||||
|
if(sv == null)
|
||||||
|
return 1;
|
||||||
|
String[] thisParts = this.get().split("\\.");
|
||||||
|
String[] svParts = sv.get().split("\\.");
|
||||||
|
int length = Math.max(thisParts.length, svParts.length);
|
||||||
|
for(int i = 0; i < length; i++) {
|
||||||
|
int thisPart = i < thisParts.length ?
|
||||||
|
Integer.parseInt(thisParts[i]) : 0;
|
||||||
|
int svPart = i < svParts.length ?
|
||||||
|
Integer.parseInt(svParts[i]) : 0;
|
||||||
|
if(thisPart < svPart)
|
||||||
|
return -1;
|
||||||
|
if(thisPart > svPart)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.compareTo((SemanticVersioner) o) == 0;
|
||||||
|
}
|
||||||
|
}
|
29
src/main/java/tech/nevets/jaml/util/VersionFetcher.java
Normal file
29
src/main/java/tech/nevets/jaml/util/VersionFetcher.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package tech.nevets.jaml.util;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import tech.nevets.jaml.JAML;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class VersionFetcher {
|
||||||
|
|
||||||
|
public static JsonObject getList() throws IOException {
|
||||||
|
URL versionManifestUrl = new URL("https://launchermeta.mojang.com/mc/game/version_manifest.json");
|
||||||
|
FileUtils.copyURLToFile(versionManifestUrl, new File(JAML.path + "\\data\\version.json"));
|
||||||
|
|
||||||
|
File versionManifestFile = new File(JAML.path + "\\data\\version.json");
|
||||||
|
|
||||||
|
return new Gson().fromJson(FileUtils.readFileToString(versionManifestFile), JsonObject.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLatestVersion(String branch) throws IOException {
|
||||||
|
JsonObject versionManifestJson = getList();
|
||||||
|
JsonObject latestJsonObject = versionManifestJson.get("latest").getAsJsonObject();
|
||||||
|
|
||||||
|
return latestJsonObject.get(branch).getAsString();
|
||||||
|
}
|
||||||
|
}
|
BIN
src/main/resources/assets/icon.png
Normal file
BIN
src/main/resources/assets/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 210 KiB |
BIN
src/main/resources/assets/jaml.png
Normal file
BIN
src/main/resources/assets/jaml.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 104 KiB |
Loading…
Reference in New Issue
Block a user