Config generates in a specified path
This commit is contained in:
parent
6a2986f45e
commit
3dae87396f
1
.gitignore
vendored
1
.gitignore
vendored
@ -139,3 +139,4 @@ fabric.properties
|
|||||||
# Android studio 3.1+ serialized cache file
|
# Android studio 3.1+ serialized cache file
|
||||||
.idea/caches/build_file_checksums.ser
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
config.yml
|
@ -16,5 +16,10 @@
|
|||||||
<option name="name" value="MavenRepo" />
|
<option name="name" value="MavenRepo" />
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://jitpack.io" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
45
build.gradle
45
build.gradle
@ -1,55 +1,38 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'application'
|
id 'application'
|
||||||
id 'org.openjfx.javafxplugin' version '0.0.10'
|
|
||||||
id 'org.beryx.jlink' version '2.24.1'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'tech.nevets.jaml'
|
group 'tech.nevets.jaml'
|
||||||
version '1.0-SNAPSHOT'
|
version '0.1.0'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url 'https://jitpack.io'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = '17'
|
sourceCompatibility = targetCompatibility = '17'
|
||||||
targetCompatibility = '17'
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.encoding = 'UTF-8'
|
options.encoding = 'UTF-8'
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainModule = 'tech.nevets.jaml.jaml'
|
mainModule = 'tech.nevets.jaml'
|
||||||
mainClass = 'tech.nevets.jaml.jaml.JAML'
|
mainClass = 'tech.nevets.jaml.JAML'
|
||||||
}
|
|
||||||
|
|
||||||
javafx {
|
|
||||||
version = '17.0.1'
|
|
||||||
modules = ['javafx.controls', 'javafx.fxml', 'javafx.web']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation('org.controlsfx:controlsfx:11.1.0')
|
implementation 'me.carleslc.Simple-YAML:Simple-Yaml:1.7.3'
|
||||||
implementation('com.dlsc.formsfx:formsfx-core:11.3.2') {
|
implementation 'com.google.code.gson:gson:2.9.0'
|
||||||
exclude(group: 'org.openjfx')
|
|
||||||
}
|
|
||||||
implementation('org.kordamp.ikonli:ikonli-javafx:12.2.0')
|
|
||||||
implementation('org.kordamp.bootstrapfx:bootstrapfx-core:0.4.0')
|
|
||||||
implementation('eu.hansolo:tilesfx:11.48') {
|
|
||||||
exclude(group: 'org.openjfx')
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jlink {
|
jar {
|
||||||
imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip")
|
manifest {
|
||||||
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
|
attributes(
|
||||||
launcher {
|
'Main-Class': 'tech.nevets.jaml.JAML'
|
||||||
name = 'app'
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jlinkZip {
|
|
||||||
group = 'distribution'
|
|
||||||
}
|
|
4
config.yml
Normal file
4
config.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# If true, will print out all the messages
|
||||||
|
verbose: false
|
||||||
|
# Jaml version, don't change it!
|
||||||
|
version: 0.1.0
|
@ -1,14 +0,0 @@
|
|||||||
module tech.nevets.jaml.jaml {
|
|
||||||
requires javafx.controls;
|
|
||||||
requires javafx.fxml;
|
|
||||||
requires javafx.web;
|
|
||||||
|
|
||||||
requires org.controlsfx.controls;
|
|
||||||
requires com.dlsc.formsfx;
|
|
||||||
requires org.kordamp.ikonli.javafx;
|
|
||||||
requires org.kordamp.bootstrapfx.core;
|
|
||||||
requires eu.hansolo.tilesfx;
|
|
||||||
|
|
||||||
opens tech.nevets.jaml.jaml to javafx.fxml;
|
|
||||||
exports tech.nevets.jaml.jaml;
|
|
||||||
}
|
|
43
src/main/java/tech/nevets/jaml/Config.java
Normal file
43
src/main/java/tech/nevets/jaml/Config.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package tech.nevets.jaml;
|
||||||
|
|
||||||
|
import org.simpleyaml.configuration.file.YamlFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
private static final YamlFile ymlFile = new YamlFile(JAML.path + "\\config.yml");
|
||||||
|
|
||||||
|
public static void loadConfig() {
|
||||||
|
try {
|
||||||
|
if (!ymlFile.exists()) {
|
||||||
|
System.out.println("Config file not found, creating new one...");
|
||||||
|
ymlFile.createNewFile(true);
|
||||||
|
System.out.println("Config file created!");
|
||||||
|
} else {
|
||||||
|
System.out.println("Loading Config file...");
|
||||||
|
ymlFile.loadWithComments();
|
||||||
|
System.out.println("Config file loaded!");
|
||||||
|
}
|
||||||
|
} catch (final Exception e) {
|
||||||
|
System.out.println("Error while loading config file!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
ymlFile.addDefault("launcher.path","default");
|
||||||
|
ymlFile.setComment("launcher.path","Path to JAML files\n" + "default: %appdata%\\.jaml\\");
|
||||||
|
ymlFile.addDefault("launcher.verbose", false);
|
||||||
|
ymlFile.setComment("launcher.verbose", "If true, will print out all the messages");
|
||||||
|
ymlFile.addDefault("launcher.version", "0.1.0");
|
||||||
|
ymlFile.setComment("launcher.version", "Jaml version, don't change it!");
|
||||||
|
|
||||||
|
try {
|
||||||
|
ymlFile.save();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static YamlFile getConfig() {
|
||||||
|
return ymlFile;
|
||||||
|
}
|
||||||
|
}
|
37
src/main/java/tech/nevets/jaml/JAML.java
Normal file
37
src/main/java/tech/nevets/jaml/JAML.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package tech.nevets.jaml;
|
||||||
|
|
||||||
|
import org.simpleyaml.configuration.file.YamlFile;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public class JAML {
|
||||||
|
public static YamlFile config;
|
||||||
|
public static Path path;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
makeDir();
|
||||||
|
Config.loadConfig();
|
||||||
|
config = Config.getConfig();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void makeDir() {
|
||||||
|
if (config == null) {
|
||||||
|
path = Path.of(System.getenv("APPDATA") + "\\.jaml\\");
|
||||||
|
} else {
|
||||||
|
if (config.getString("launcher.path") == "default") {
|
||||||
|
path = Path.of(System.getenv("APPDATA") + "\\.jaml\\");
|
||||||
|
} else {
|
||||||
|
path = Path.of(config.getString("launcher.path"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!path.toFile().exists()) {
|
||||||
|
path.toFile().mkdirs();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("Invalid path, please check your config.yml and try again");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
src/main/java/tech/nevets/jaml/Profiles.java
Normal file
22
src/main/java/tech/nevets/jaml/Profiles.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package tech.nevets.jaml;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public class Profiles {
|
||||||
|
|
||||||
|
public static void createProfile(String email, String hashedPassword, Path javaPath, Path gamePath, String version, Boolean onlineMode, String username) {
|
||||||
|
GsonBuilder builder = new GsonBuilder();
|
||||||
|
builder.setPrettyPrinting();
|
||||||
|
Gson gson = builder.create();
|
||||||
|
|
||||||
|
//TODO Create and save profiles
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadProfile() {
|
||||||
|
//TODO Load Saved Profiles
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +0,0 @@
|
|||||||
package tech.nevets.jaml.jaml;
|
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
|
|
||||||
public class Controller {
|
|
||||||
@FXML
|
|
||||||
private Label welcomeText;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
protected void onHelloButtonClick() {
|
|
||||||
welcomeText.setText("Welcome to JavaFX Application!");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package tech.nevets.jaml.jaml;
|
|
||||||
|
|
||||||
import javafx.application.Application;
|
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class JAML extends Application {
|
|
||||||
@Override
|
|
||||||
public void start(Stage stage) throws IOException {
|
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(JAML.class.getResource("hello-view.fxml"));
|
|
||||||
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
|
|
||||||
stage.setTitle("Hello!");
|
|
||||||
stage.setScene(scene);
|
|
||||||
stage.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
launch();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
|
||||||
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml"
|
|
||||||
fx:controller="tech.nevets.jaml.jaml.Controller">
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
|
|
||||||
</padding>
|
|
||||||
|
|
||||||
<Label fx:id="welcomeText"/>
|
|
||||||
<Button text="Hello!" onAction="#onHelloButtonClick"/>
|
|
||||||
</VBox>
|
|
Loading…
Reference in New Issue
Block a user