Periodic update
This commit is contained in:
parent
f994a5a419
commit
c52f8b0b95
@ -1,16 +1,14 @@
|
|||||||
package tech.nevets.jaml.util;
|
package tech.nevets.jaml;
|
||||||
|
|
||||||
import org.simpleyaml.configuration.file.YamlFile;
|
import org.simpleyaml.configuration.file.YamlFile;
|
||||||
import tech.nevets.jaml.JAML;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
private static final YamlFile YML_FILE = new YamlFile(JAML.path + "\\config.yml");
|
private static final YamlFile YML_FILE = new YamlFile(JAML.path + "\\config.yml");
|
||||||
// private static final YamlFile YML_FILE = new YamlFile("C:\\Users\\svtra\\AppData\\Roaming\\.jaml");
|
|
||||||
|
|
||||||
public static void loadConfig() {
|
public static void loadConfig() {
|
||||||
YML_FILE.setConfigurationFile("C:\\Users\\svtra\\AppData\\Roaming\\.jaml\\config.yml");
|
YML_FILE.setConfigurationFile(JAML.path + "\\config.yml");
|
||||||
try {
|
try {
|
||||||
if (!YML_FILE.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...");
|
@ -1,4 +1,4 @@
|
|||||||
package tech.nevets.jaml.util;
|
package tech.nevets.jaml;
|
||||||
|
|
||||||
import net.arikia.dev.drpc.DiscordEventHandlers;
|
import net.arikia.dev.drpc.DiscordEventHandlers;
|
||||||
import net.arikia.dev.drpc.DiscordRPC;
|
import net.arikia.dev.drpc.DiscordRPC;
|
@ -1,16 +1,11 @@
|
|||||||
package tech.nevets.jaml;
|
package tech.nevets.jaml;
|
||||||
|
|
||||||
import org.simpleyaml.configuration.file.YamlFile;
|
|
||||||
import tech.nevets.jaml.gui.GuiHandler;
|
import tech.nevets.jaml.gui.GuiHandler;
|
||||||
import tech.nevets.jaml.util.Config;
|
import tech.nevets.jaml.util.*;
|
||||||
import tech.nevets.jaml.util.DiscordRP;
|
|
||||||
import tech.nevets.jaml.util.LoaderUtils;
|
|
||||||
import tech.nevets.jaml.util.ProfileUtils;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class JAML {
|
public class JAML {
|
||||||
//public static YamlFile config = Config.getConfig();
|
|
||||||
public static Path path;
|
public static Path path;
|
||||||
public static GuiHandler guiHandler;
|
public static GuiHandler guiHandler;
|
||||||
|
|
||||||
@ -24,6 +19,7 @@ public class JAML {
|
|||||||
DiscordRP.update("", "");
|
DiscordRP.update("", "");
|
||||||
guiHandler = new GuiHandler();
|
guiHandler = new GuiHandler();
|
||||||
|
|
||||||
|
|
||||||
// try {
|
// try {
|
||||||
// System.out.println(VersionFetcher.getLatestVersion("release"));
|
// System.out.println(VersionFetcher.getLatestVersion("release"));
|
||||||
// } catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
@ -72,5 +68,14 @@ public class JAML {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Path skinsPath = Path.of(path + "\\data\\skins\\");
|
||||||
|
if (!skinsPath.toFile().exists()) {
|
||||||
|
skinsPath.toFile().mkdirs();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,6 @@
|
|||||||
package tech.nevets.jaml.util;
|
package tech.nevets.jaml;
|
||||||
|
|
||||||
|
import tech.nevets.jaml.util.ProfileUtils;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -1,10 +1,9 @@
|
|||||||
package tech.nevets.jaml.gui;
|
package tech.nevets.jaml.gui;
|
||||||
|
|
||||||
import tech.nevets.jaml.util.FirstLaunch;
|
import tech.nevets.jaml.init.FirstLaunch;
|
||||||
import tech.nevets.jaml.JAML;
|
import tech.nevets.jaml.JAML;
|
||||||
import tech.nevets.jaml.objects.Profile;
|
import tech.nevets.jaml.objects.Profile;
|
||||||
import tech.nevets.jaml.util.ProfileUtils;
|
import tech.nevets.jaml.util.ProfileUtils;
|
||||||
import tech.nevets.jaml.util.Encryptor;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
93
src/main/java/tech/nevets/jaml/gui/FirstLoginGui.java
Normal file
93
src/main/java/tech/nevets/jaml/gui/FirstLoginGui.java
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
package tech.nevets.jaml.gui;
|
||||||
|
|
||||||
|
import tech.nevets.jaml.objects.Profile;
|
||||||
|
import tech.nevets.jaml.util.LoaderUtils;
|
||||||
|
import tech.nevets.jaml.util.ProfileUtils;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class FirstLoginGui extends JFrame {
|
||||||
|
private JPanel contentPane;
|
||||||
|
|
||||||
|
public FirstLoginGui() {
|
||||||
|
setResizable(false);
|
||||||
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
setBounds(100, 100, 360, 330);
|
||||||
|
contentPane = new JPanel();
|
||||||
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
setContentPane(contentPane);
|
||||||
|
contentPane.setLayout(null);
|
||||||
|
|
||||||
|
JLabel profileNameLabel = new JLabel("Profile Name:");
|
||||||
|
profileNameLabel.setBounds(10, 14, 84, 31);
|
||||||
|
contentPane.add(profileNameLabel);
|
||||||
|
JTextField profileNameField = new JTextField(20);
|
||||||
|
profileNameField.setBounds(94, 18, 231, 23);
|
||||||
|
contentPane.add(profileNameField);
|
||||||
|
|
||||||
|
JLabel gamePathLabel = new JLabel("Game Path:");
|
||||||
|
gamePathLabel.setBounds(10, 56, 84, 31);
|
||||||
|
contentPane.add(gamePathLabel);
|
||||||
|
|
||||||
|
JButton gamePathButton = new JButton("...");
|
||||||
|
gamePathButton.setBounds(302, 60, 23, 23);
|
||||||
|
JTextField gamePathField = new JTextField(20);
|
||||||
|
gamePathField.setBounds(94, 60, 209, 23);
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
contentPane.add(gamePathField);
|
||||||
|
contentPane.add(gamePathButton);
|
||||||
|
|
||||||
|
JLabel versionLabel = new JLabel("Version:");
|
||||||
|
versionLabel.setBounds(10, 98, 84, 31);
|
||||||
|
contentPane.add(versionLabel);
|
||||||
|
JTextField versionField = new JTextField(20);
|
||||||
|
versionField.setBounds(94, 102, 231, 23);
|
||||||
|
contentPane.add(versionField);
|
||||||
|
|
||||||
|
JLabel loaderLabel = new JLabel("Loader:");
|
||||||
|
loaderLabel.setBounds(10, 140, 84, 31);
|
||||||
|
contentPane.add(loaderLabel);
|
||||||
|
|
||||||
|
JComboBox loaderDropdown = new JComboBox(LoaderUtils.loaders);
|
||||||
|
loaderDropdown.setBounds(94, 144, 231, 23);
|
||||||
|
contentPane.add(loaderDropdown);
|
||||||
|
|
||||||
|
JLabel offlineModeLabel = new JLabel("Offline Mode:");
|
||||||
|
offlineModeLabel.setBounds(10, 182, 84, 31);
|
||||||
|
contentPane.add(offlineModeLabel);
|
||||||
|
JCheckBox offlineModeBox = new JCheckBox("");
|
||||||
|
offlineModeBox.setBounds(94, 185, 21, 23);
|
||||||
|
contentPane.add(offlineModeBox);
|
||||||
|
|
||||||
|
JButton button = new JButton("Create Profile");
|
||||||
|
button.setBounds(64, 234, 217, 37);
|
||||||
|
button.addActionListener(al -> {
|
||||||
|
Profile profile = new Profile();
|
||||||
|
profile.setProfileName(profileNameField.getText());
|
||||||
|
|
||||||
|
profile.setGamePath(new File(gamePathField.getText()));
|
||||||
|
profile.setVersion(versionField.getText());
|
||||||
|
profile.setLoader(loaderDropdown.getSelectedItem().toString());
|
||||||
|
profile.setOfflineMode(offlineModeBox.isSelected());
|
||||||
|
try {
|
||||||
|
ProfileUtils.createProfile(profile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
ProfileUtils.getProfileList();
|
||||||
|
|
||||||
|
this.dispose();
|
||||||
|
});
|
||||||
|
contentPane.add(button);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package tech.nevets.jaml.gui;
|
package tech.nevets.jaml.gui;
|
||||||
|
|
||||||
import tech.nevets.jaml.util.Config;
|
import tech.nevets.jaml.Config;
|
||||||
import tech.nevets.jaml.JAML;
|
import tech.nevets.jaml.JAML;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -10,11 +10,10 @@ import javax.swing.border.EmptyBorder;
|
|||||||
|
|
||||||
public class HomeGui extends JFrame {
|
public class HomeGui extends JFrame {
|
||||||
|
|
||||||
//private JPanel contentPane;
|
|
||||||
private JTabbedPane tabPanel;
|
private JTabbedPane tabPanel;
|
||||||
private JPanel homePanel;
|
private JPanel homePanel;
|
||||||
|
private JPanel userPanel;
|
||||||
//private JPanel contentPane;
|
private JPanel profilePanel;
|
||||||
|
|
||||||
public HomeGui() {
|
public HomeGui() {
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
@ -8,13 +8,13 @@ import javax.swing.*;
|
|||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class NewProfileGui extends JFrame {
|
public class NewProfileGui extends JFrame {
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
|
|
||||||
public NewProfileGui() {
|
public NewProfileGui() {
|
||||||
|
setUndecorated(true);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setBounds(100, 100, 360, 330);
|
setBounds(100, 100, 360, 330);
|
||||||
@ -90,7 +90,6 @@ public class NewProfileGui extends JFrame {
|
|||||||
|
|
||||||
this.dispose();
|
this.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
contentPane.add(button);
|
contentPane.add(button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package tech.nevets.jaml.gui.panels;
|
|
||||||
|
|
||||||
import tech.nevets.jaml.JAML;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class BackgroundPanel extends JPanel {
|
|
||||||
@Override
|
|
||||||
protected void paintComponent(Graphics g) {
|
|
||||||
super.paintComponent(g);
|
|
||||||
ImageIcon img = new ImageIcon(JAML.path + "\\assets\\background.png");
|
|
||||||
g.drawImage(img.getImage(), 0, 0, this.getWidth(), this.getHeight(), null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
package tech.nevets.jaml.util;
|
package tech.nevets.jaml.init;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import tech.nevets.jaml.Config;
|
||||||
import tech.nevets.jaml.JAML;
|
import tech.nevets.jaml.JAML;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
@ -9,6 +9,22 @@ public class User {
|
|||||||
private String key;
|
private String key;
|
||||||
private String salt;
|
private String salt;
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUuid(UUID uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAccessToken() {
|
public String getAccessToken() {
|
||||||
return accessToken;
|
return accessToken;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package tech.nevets.jaml.util;
|
|||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import tech.nevets.jaml.Config;
|
||||||
import tech.nevets.jaml.JAML;
|
import tech.nevets.jaml.JAML;
|
||||||
import tech.nevets.jaml.objects.Profile;
|
import tech.nevets.jaml.objects.Profile;
|
||||||
|
|
||||||
|
48
src/main/java/tech/nevets/jaml/util/SkinFetcher.java
Normal file
48
src/main/java/tech/nevets/jaml/util/SkinFetcher.java
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package tech.nevets.jaml.util;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import tech.nevets.jaml.JAML;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.http.HttpClient;
|
||||||
|
import java.net.http.HttpRequest;
|
||||||
|
import java.net.http.HttpResponse;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SkinFetcher {
|
||||||
|
|
||||||
|
public static File getSkinImage() {
|
||||||
|
try {
|
||||||
|
URL imageUrl = new URL("https://minotar.net/armor/body/" + UserUtils.getActiveUser().getUuid().toString() + "/400.png");
|
||||||
|
FileUtils.copyURLToFile(imageUrl, new File(JAML.path + "\\data\\skins\\" + UserUtils.getActiveUser().getUuid() + "-rendered.png"));
|
||||||
|
return new File(JAML.path + "\\data\\skins\\" + UserUtils.getActiveUser().getUuid() + "-rendered.png");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void uploadSkinImage(File skin) {
|
||||||
|
Map<Object, Object> data = new HashMap<>();
|
||||||
|
data.put("username", "abc");
|
||||||
|
data.put("password", "123");
|
||||||
|
data.put("custom", "secret");
|
||||||
|
data.put("ts", System.currentTimeMillis());
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// HttpClient client = HttpClient.newHttpClient();
|
||||||
|
// HttpRequest request = HttpRequest.newBuilder()
|
||||||
|
// .POST(buildFormDataFromMap(data))
|
||||||
|
// .uri("https://authserver.mojang.com")
|
||||||
|
// .build();
|
||||||
|
// HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||||
|
//
|
||||||
|
// String data = response.body();
|
||||||
|
// } catch (IOException | InterruptedException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +0,0 @@
|
|||||||
package tech.nevets.jaml.util;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
public class SkinUtils {
|
|
||||||
|
|
||||||
public static File getSkinImage() {
|
|
||||||
try {
|
|
||||||
URL imageUrl = new URL("https://minotar.net/armor/body/");
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
23
src/main/java/tech/nevets/jaml/util/UserUtils.java
Normal file
23
src/main/java/tech/nevets/jaml/util/UserUtils.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package tech.nevets.jaml.util;
|
||||||
|
|
||||||
|
import tech.nevets.jaml.objects.User;
|
||||||
|
|
||||||
|
public class UserUtils {
|
||||||
|
private static User activeUser;
|
||||||
|
|
||||||
|
public static void createUser() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static User getUser() {
|
||||||
|
return new User();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setActiveUser(User user) {
|
||||||
|
activeUser = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static User getActiveUser() {
|
||||||
|
return activeUser;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user