JFX AHHHHHHH

This commit is contained in:
Steven Tracey 2023-05-24 16:17:28 -04:00
parent 608b64d035
commit fdef1145a5
13 changed files with 150 additions and 102 deletions

View File

@ -31,5 +31,10 @@
<option name="name" value="maven3" />
<option name="url" value="https://europe-maven.pkg.dev/jxbrowser/releases" />
</remote-repository>
<remote-repository>
<option name="id" value="maven3" />
<option name="name" value="maven3" />
<option name="url" value="https://maven.lenni0451.net/releases" />
</remote-repository>
</component>
</project>

View File

@ -4,7 +4,7 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -1,12 +1,30 @@
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'org.beryx.jlink' version '2.12.0'
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'edu.sc.seis.launch4j' version '2.5.1'
}
application {
applicationName = 'JAML'
mainModule = 'tech.nevets.jaml'
mainClass = 'tech.nevets.jaml.JAML'
}
javafx {
version = "17.0.7"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
java {
modularity.inferModulePath = true
}
group 'tech.nevets.jaml'
version '0.8.3'
def build = 'dev'
mainClassName = 'tech.nevets.jaml.JAML'
repositories {
mavenCentral()
@ -16,20 +34,27 @@ repositories {
maven {
url 'https://repo.nevets.tech/repository/maven-public'
}
}
sourceCompatibility = targetCompatibility = '17'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
maven{
url 'https://maven.lenni0451.net/releases'
}
}
dependencies {
implementation 'me.carleslc.Simple-YAML:Simple-Yaml:1.8'
implementation('me.carleslc.Simple-YAML:Simple-Yaml:1.8.4') {
exclude group: 'me.carleslc.Simple-YAML'
}
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'net.arikia.dev:drpc:1.0'
implementation 'commons-io:commons-io:2.11.0'
//implementation 'com.microsoft.azure.msal4j:1.11.3'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.2.1'
implementation 'net.raphimc:MinecraftAuth:2.1.3'
}
jlink {
options = ['--strip-debug', '--compress', '2', '--no-header-file', '--no-man-pages']
launcher {
name = 'jaml'
}
}
shadowJar {

View File

@ -0,0 +1,10 @@
module tech.nevets.jaml {
requires javafx.fxml;
requires javafx.controls;
requires java.desktop;
requires com.google.gson;
requires org.apache.httpcomponents.httpclient;
requires java.net.http;
requires Simple.Yaml;
requires MinecraftAuth;
}

View File

@ -1,6 +1,7 @@
package tech.nevets.jaml;
import tech.nevets.jaml.gui.GuiHandler;
import tech.nevets.jaml.gui.GuiManager;
import java.nio.file.Path;
@ -10,13 +11,13 @@ public class JAML {
public static final String VERSION = "0.8.2";
public static void main(String[] args) {
//GuiHandler.startup();
GuiHandler.startup();
GuiManager.main(args);
DiscordRP.start();
DiscordRP.update("", "");
guiHandler = new GuiHandler();
//guiHandler = new GuiHandler();
}
}
}

View File

@ -14,6 +14,7 @@ import java.io.InputStreamReader;
import java.util.ArrayList;
public class Launcher {
private String userName;
private int jdkVersion;
private int memoryAmount;
private String garbageCollection;
@ -22,7 +23,14 @@ public class Launcher {
//TODO add progressbar for launch progress
//TODO add console output option
public Launcher() {
public Launcher() {}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserName() {
return userName;
}
public void setJdkVersion(int jdkVersion) {
@ -90,7 +98,7 @@ public class Launcher {
}
}
public static ArrayList<String> parseCommand(int jdkVersion, int memoryAmount, String version, String garbageCollection) {
public ArrayList<String> parseCommand(int jdkVersion, int memoryAmount, String version, String garbageCollection) {
StringBuilder sb = new StringBuilder();
if (new File(JAML.path + "/cache/" + version + ".json").exists()) {
String[] libs = CacheUtils.getCache(version);
@ -134,7 +142,7 @@ public class Launcher {
cmd.add("-cp");
cmd.add(sb.toString());
cmd.add("net.minecraft.client.main.Main");
cmd.add("--username " + "SteveO718" + " --version " + version + " --gameDir . --assetsDir assets --assetIndex 1.18 --uuid 0f28983a46ce33b1aed45cdc95bf44c3 --accessToken 00000000000000000000000000000000 --clientId 0000 --xuid 0000 --userType mojang --versionType release");
cmd.add("--username " + userName + " --version " + version + " --gameDir . --assetsDir assets --assetIndex 1.18 --uuid 0f28983a46ce33b1aed45cdc95bf44c3 --accessToken 00000000000000000000000000000000 --clientId 0000 --xuid 0000 --userType mojang --versionType release");
return cmd;
}

View File

@ -1,87 +1,42 @@
package tech.nevets.jaml.auth;
import tech.nevets.jaml.util.DataCompressor;
import tech.nevets.jaml.util.HttpUtils;
import net.raphimc.mcauth.MinecraftAuth;
import net.raphimc.mcauth.step.java.StepMCProfile;
import net.raphimc.mcauth.step.msa.StepMsaDeviceCode;
import net.raphimc.mcauth.util.MicrosoftConstants;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.impl.client.CloseableHttpClient;
import javax.swing.*;
public class AuthRequests {
public static DataCompressor initGet() {
try {
URI liveLogin = new URI("https://login.live.com/oauth20_authorize.srf?client_id=000000004C12AE6F&redirect_uri=https://login.live.com/oauth20_desktop.srf&scope=service::user.auth.xboxlive.com::MBI_SSL&display=touch&response_type=token&locale=en");
Map<String, String> headers = new HashMap<>();
String response = HttpUtils.get(liveLogin, headers);
String urlPost = "";
String value = "";
System.out.println("Response: " + response);
String[] cutResponse = response.split("<");
for (String cut : cutResponse) {
if (cut.contains("urlPost")) {
urlPost = cut;
}
if (cut.contains("value")) {
value = cut;
}
}
while (urlPost.indexOf(",urlPost:") < urlPost.indexOf("',at:true")) {
urlPost = urlPost.substring(urlPost.indexOf(",urlPost:") + 10, urlPost.indexOf("',at:true"));
}
while (value.indexOf("value=\"") < value.indexOf("\"/>',")) {
value = value.substring(value.indexOf("value=\"") + 7, value.indexOf("\"/>',"));
}
System.out.println("Param 1: " + urlPost);
System.out.println("Param 2: " + value);
return new DataCompressor(urlPost, value);
} catch (URISyntaxException e) {
e.printStackTrace();
return new DataCompressor();
}
public static void main(String[] args) {
msLogin();
}
public static String loginMicrosoft() {
DataCompressor urlPostPlusValue = initGet();
String urlPost = urlPostPlusValue.getKey();
String value = urlPostPlusValue.getValue();
String accountEmail = "SVTracey9@gmail.com";
String accountPassword = "Dolly1000!!";
try {
Map<String, String> headers = new HashMap<>();
Map<String,String> data = new HashMap<>();
data.put("login", accountEmail);
data.put("loginfmt", accountEmail);
data.put("passwd", accountPassword);
data.put("PPFT", value);
String response = HttpUtils.post(new URI(urlPost), headers, data);
System.out.println(response);
return "";
} catch (URISyntaxException e) {
public static void msLogin() {
StepMCProfile.MCProfile mcProfile;
try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
mcProfile = MinecraftAuth.JAVA_DEVICE_CODE_LOGIN.getFromInput(httpClient, new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCode -> {
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
try {
Desktop.getDesktop().browse(new URI(msaDeviceCode.verificationUri()));
} catch (IOException | URISyntaxException e) {
throw new RuntimeException(e);
}
JOptionPane.showMessageDialog(null, "Code: " + msaDeviceCode.userCode(), "Microsoft Verification Code", JOptionPane.PLAIN_MESSAGE);
}
}));
} catch (Exception e) {
System.out.println("Error Logging in...");
e.printStackTrace();
return "";
}
}
public static void loginMSApi() {
// FileUtils.writeStringToFile(new File(JAML.path + ""));
}
}

View File

@ -0,0 +1,21 @@
package tech.nevets.jaml.gui;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import java.net.URL;
import java.util.ResourceBundle;
public class FXHomeGui implements Initializable {
@FXML
private Label label;
@Override
public void initialize(URL location, ResourceBundle resources) {
String javaVersion = System.getProperty("java.version");
String javafxVersion = System.getProperty("javafx.version");
label.setText("Hello, JavaFX " + javafxVersion + "\nRunning on Java " + javaVersion + ".");
}
}

View File

@ -0,0 +1,24 @@
package tech.nevets.jaml.gui;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class GuiManager extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("home.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("stylesheet.css").toExternalForm());
stage.setTitle("JAML");
stage.setScene(scene);
stage.show();
}
}

View File

@ -112,18 +112,6 @@ public class StartupGui extends JFrame {
}
private static void sleep() {
try {
Thread.sleep(500);
} catch (InterruptedException ignored) {
}
}
public static void setCurrentTask(String currentTask) {
currentTaskLabel.setText(currentTask);
}
public static void makeDirs() {
if (System.getenv("JAML_HOME") == null) {
JAML.path = Path.of(System.getenv("APPDATA") + "\\.jaml\\");

View File

@ -20,6 +20,7 @@ public class HomePanel extends JPanel {
launchButton.setBounds(512, 619, 196, 51);
launchButton.addActionListener(al -> {
Launcher launch = new Launcher();
launch.setUserName("SteveO718");
launch.setJdkVersion(17);
launch.setMemoryAmount(6144);
launch.setGarbageCollection("zgc");

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.control.Label?>
<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="tech.nevets.jaml.gui.FXHomeGui">
<children>
<Label fx:id="label" text="Label" />
</children>
</StackPane>