diff --git a/.gradle/6.1/executionHistory/executionHistory.bin b/.gradle/6.1/executionHistory/executionHistory.bin
index 25c0344..9e84ba1 100644
Binary files a/.gradle/6.1/executionHistory/executionHistory.bin and b/.gradle/6.1/executionHistory/executionHistory.bin differ
diff --git a/.gradle/6.1/executionHistory/executionHistory.lock b/.gradle/6.1/executionHistory/executionHistory.lock
index 228a394..35d2aa8 100644
Binary files a/.gradle/6.1/executionHistory/executionHistory.lock and b/.gradle/6.1/executionHistory/executionHistory.lock differ
diff --git a/.gradle/6.1/fileHashes/fileHashes.bin b/.gradle/6.1/fileHashes/fileHashes.bin
index 4a9371f..cb4a4b7 100644
Binary files a/.gradle/6.1/fileHashes/fileHashes.bin and b/.gradle/6.1/fileHashes/fileHashes.bin differ
diff --git a/.gradle/6.1/fileHashes/fileHashes.lock b/.gradle/6.1/fileHashes/fileHashes.lock
index 8fb9020..2a216bb 100644
Binary files a/.gradle/6.1/fileHashes/fileHashes.lock and b/.gradle/6.1/fileHashes/fileHashes.lock differ
diff --git a/.gradle/6.1/javaCompile/classAnalysis.bin b/.gradle/6.1/javaCompile/classAnalysis.bin
index 156885e..0ef85f5 100644
Binary files a/.gradle/6.1/javaCompile/classAnalysis.bin and b/.gradle/6.1/javaCompile/classAnalysis.bin differ
diff --git a/.gradle/6.1/javaCompile/javaCompile.lock b/.gradle/6.1/javaCompile/javaCompile.lock
index 5af65ab..ccdaa31 100644
Binary files a/.gradle/6.1/javaCompile/javaCompile.lock and b/.gradle/6.1/javaCompile/javaCompile.lock differ
diff --git a/.gradle/6.1/javaCompile/taskHistory.bin b/.gradle/6.1/javaCompile/taskHistory.bin
index 26914fc..2d10ea6 100644
Binary files a/.gradle/6.1/javaCompile/taskHistory.bin and b/.gradle/6.1/javaCompile/taskHistory.bin differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index e2a1c36..832e24d 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
index 1a066f3..73b35b6 100644
Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/.gradle/checksums/checksums.lock b/.gradle/checksums/checksums.lock
index 8982450..ab61f3c 100644
Binary files a/.gradle/checksums/checksums.lock and b/.gradle/checksums/checksums.lock differ
diff --git a/.gradle/checksums/md5-checksums.bin b/.gradle/checksums/md5-checksums.bin
index 915482b..0bb7edc 100644
Binary files a/.gradle/checksums/md5-checksums.bin and b/.gradle/checksums/md5-checksums.bin differ
diff --git a/.gradle/checksums/sha1-checksums.bin b/.gradle/checksums/sha1-checksums.bin
index 83e641b..0f925cb 100644
Binary files a/.gradle/checksums/sha1-checksums.bin and b/.gradle/checksums/sha1-checksums.bin differ
diff --git a/build.gradle b/build.gradle
index 8ad5a0e..13fa5e3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,14 +1,22 @@
plugins {
id 'java'
+ id "com.github.johnrengelman.shadow" version "5.2.0"
}
+
group 'org.example'
version '1.0-SNAPSHOT'
+
repositories {
mavenCentral()
}
+compileJava {
+ sourceCompatibility = targetCompatibility = '1.8'
+ compileJava.options.encoding = 'UTF-8'
+}
+
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.13.2'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.2'
diff --git a/build/classes/java/main/ch/m4th1eu/flansupdater/ArmorUtils.class b/build/classes/java/main/ch/m4th1eu/flansupdater/ArmorUtils.class
index b1f74b9..68fc2b4 100644
Binary files a/build/classes/java/main/ch/m4th1eu/flansupdater/ArmorUtils.class and b/build/classes/java/main/ch/m4th1eu/flansupdater/ArmorUtils.class differ
diff --git a/build/classes/java/main/ch/m4th1eu/flansupdater/FileUtils.class b/build/classes/java/main/ch/m4th1eu/flansupdater/FileUtils.class
index b3e1e60..d137884 100644
Binary files a/build/classes/java/main/ch/m4th1eu/flansupdater/FileUtils.class and b/build/classes/java/main/ch/m4th1eu/flansupdater/FileUtils.class differ
diff --git a/build/classes/java/main/ch/m4th1eu/flansupdater/Main.class b/build/classes/java/main/ch/m4th1eu/flansupdater/Main.class
index a70ee9a..cc617a9 100644
Binary files a/build/classes/java/main/ch/m4th1eu/flansupdater/Main.class and b/build/classes/java/main/ch/m4th1eu/flansupdater/Main.class differ
diff --git a/build/classes/java/main/ch/m4th1eu/flansupdater/VehiclesUtils.class b/build/classes/java/main/ch/m4th1eu/flansupdater/VehiclesUtils.class
index 7a97d81..73883ec 100644
Binary files a/build/classes/java/main/ch/m4th1eu/flansupdater/VehiclesUtils.class and b/build/classes/java/main/ch/m4th1eu/flansupdater/VehiclesUtils.class differ
diff --git a/build/resources/main/icon.png b/build/resources/main/icon.png
new file mode 100644
index 0000000..b41ce12
Binary files /dev/null and b/build/resources/main/icon.png differ
diff --git a/build/resources/main/logo_transparent.png b/build/resources/main/logo_transparent.png
new file mode 100644
index 0000000..0597ffd
Binary files /dev/null and b/build/resources/main/logo_transparent.png differ
diff --git a/build/resources/main/menu.fxml b/build/resources/main/menu.fxml
new file mode 100644
index 0000000..68642b4
--- /dev/null
+++ b/build/resources/main/menu.fxml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/resources/main/model.json b/build/resources/main/model.json
new file mode 100644
index 0000000..967e840
--- /dev/null
+++ b/build/resources/main/model.json
@@ -0,0 +1,76 @@
+{
+ "parent": "builtin/generated",
+ "textures": {
+ "layer0": "flansmod:items/your_item_texture"
+ },
+ "display": {
+ "thirdperson_lefthand": {
+ "rotation": [
+ 0,
+ 90,
+ -35
+ ],
+ "translation": [
+ 0,
+ 1.25,
+ -2.5
+ ],
+ "scale": [
+ 0.80,
+ 0.80,
+ 0.80
+ ]
+ },
+ "thirdperson_righthand": {
+ "rotation": [
+ 0,
+ 90,
+ -35
+ ],
+ "translation": [
+ 0,
+ 1.25,
+ -2.5
+ ],
+ "scale": [
+ 0.80,
+ 0.80,
+ 0.80
+ ]
+ },
+ "firstperson_lefthand": {
+ "rotation": [
+ 0,
+ -45,
+ 25
+ ],
+ "translation": [
+ 0,
+ 4,
+ 2
+ ],
+ "scale": [
+ 0.80,
+ 0.80,
+ 0.80
+ ]
+ },
+ "firstperson_righthand": {
+ "rotation": [
+ 0,
+ -45,
+ 25
+ ],
+ "translation": [
+ 0,
+ 4,
+ 2
+ ],
+ "scale": [
+ 0.80,
+ 0.80,
+ 0.80
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/ch/m4th1eu/flansupdater/ArmorUtils.java b/src/main/java/ch/m4th1eu/flansupdater/ArmorUtils.java
index 5a9ddab..69235b8 100644
--- a/src/main/java/ch/m4th1eu/flansupdater/ArmorUtils.java
+++ b/src/main/java/ch/m4th1eu/flansupdater/ArmorUtils.java
@@ -1,8 +1,7 @@
package ch.m4th1eu.flansupdater;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -34,7 +33,7 @@ public class ArmorUtils {
}
try {
- FileWriter myWriter = new FileWriter(NEWFILENAME);
+ Writer myWriter = new OutputStreamWriter(new FileOutputStream(NEWFILENAME), StandardCharsets.UTF_8);
myWriter.write(processArmorFile(readFile(path.toFile())));
myWriter.close();
} catch (IOException e) {
diff --git a/src/main/java/ch/m4th1eu/flansupdater/FileUtils.java b/src/main/java/ch/m4th1eu/flansupdater/FileUtils.java
index 0d597ae..2734c09 100644
--- a/src/main/java/ch/m4th1eu/flansupdater/FileUtils.java
+++ b/src/main/java/ch/m4th1eu/flansupdater/FileUtils.java
@@ -6,10 +6,12 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;
@@ -53,7 +55,34 @@ public class FileUtils {
* @return argument's value
*/
public static String get(String argument, String content) {
- Scanner scanner = new Scanner(content);
+ String str;
+ BufferedReader reader = new BufferedReader(new StringReader(content));
+ try {
+ while ((str = reader.readLine()) != null) {
+ if (argument.equals("Name")) {
+ if (str.contains("Name") && !str.contains("ShortName")) {
+ return str.replaceFirst(argument + " ", "");
+ }
+ } else if (str.startsWith(argument)) {
+ return str.replaceFirst(argument + " ", "");
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ //doesn't work neither
+ /*List lines = new ArrayList<>();
+ try {
+ lines = IOUtils.readLines(new StringReader(content));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return lines.stream().filter(s -> s.startsWith(argument)).findFirst().map(s -> s.replaceFirst(argument + " ", "")).orElse("null");*/
+
+
+ //disabled because I think it skip the firstline
+ /*Scanner scanner = new Scanner(content);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
@@ -61,9 +90,9 @@ public class FileUtils {
return line.replaceFirst(argument + " ", "");
}
}
- scanner.close();
+ scanner.close();*/
- return "null";
+ return "not found";
}
/**
@@ -98,12 +127,16 @@ public class FileUtils {
* @return file's content
*/
public static String readFile(File file) {
+ if (!file.exists()) {
+ return "";
+ }
+
try {
StringBuilder fileData = new StringBuilder();
BufferedReader reader = new BufferedReader(
- new FileReader(file.toString()));
+ new InputStreamReader(new FileInputStream(file.toString()), StandardCharsets.UTF_8));
char[] buf = new char[1024];
- int numRead = 0;
+ int numRead;
while ((numRead = reader.read(buf)) != -1) {
String readData = String.valueOf(buf, 0, numRead);
fileData.append(readData);
@@ -137,7 +170,7 @@ public class FileUtils {
StringBuilder stringBuilder = new StringBuilder();
langs.forEach(str -> stringBuilder.append(str).append("\n"));
- FileWriter myWriter = new FileWriter(Main.LANG_NEWPATH + "en_US.lang");
+ Writer myWriter = new OutputStreamWriter(new FileOutputStream(Main.LANG_NEWPATH + "en_US.lang"), StandardCharsets.UTF_8);
myWriter.write(stringBuilder.toString());
myWriter.close();
Logger.info("Successfully generated the new lang file.");
@@ -166,7 +199,7 @@ public class FileUtils {
public static void createModels(String shortName, String icon) {
//check if the models folder exists, if not we create it.
- File modelsFolder = new File(Main.JSON_PATH);
+ File modelsFolder = new File(Main.JSON_NEWPATH);
if (!modelsFolder.exists()) {
boolean isCreated = modelsFolder.mkdirs();
if (isCreated) {
@@ -179,14 +212,19 @@ public class FileUtils {
String jsonString = "{\"parent\":\"builtin/generated\",\"textures\":{\"layer0\":\"flansmod:items/your_item_texture\"},\"display\":{\"thirdperson_lefthand\":{\"rotation\":[0,90,-35],\"translation\":[0,1.25,-2.5],\"scale\":[0.8,0.8,0.8]},\"thirdperson_righthand\":{\"rotation\":[0,90,-35],\"translation\":[0,1.25,-2.5],\"scale\":[0.8,0.8,0.8]},\"firstperson_lefthand\":{\"rotation\":[0,-45,25],\"translation\":[0,4,2],\"scale\":[0.8,0.8,0.8]},\"firstperson_righthand\":{\"rotation\":[0,-45,25],\"translation\":[0,4,2],\"scale\":[0.8,0.8,0.8]}}}";
jsonString = jsonString.replaceFirst("your_item_texture", icon);
+ if (Paths.get(Main.JSON_PATH + shortName + ".json").toFile().exists()) {
+ jsonString = readFile(new File(Main.JSON_PATH + shortName + ".json"));
+ }
+
try {
- FileWriter myWriter = new FileWriter(Main.JSON_PATH + shortName + ".json");
+ Writer myWriter = new OutputStreamWriter(new FileOutputStream(Main.JSON_NEWPATH + shortName + ".json"), StandardCharsets.UTF_8);
myWriter.write(jsonString);
myWriter.close();
} catch (IOException e) {
Logger.error("Cannot create the json model file for : " + shortName);
e.printStackTrace();
}
+
}
public static void copyModels() {
@@ -199,6 +237,28 @@ public class FileUtils {
}
}
+
+ public static void deleteTempsFolder() {
+ recursiveDelete(new File(Main.PACK_PATH));
+ recursiveDelete(new File(Main.NEWPACK_PATH));
+ Logger.info("Sucessfully deleted temporary directories.");
+ }
+
+
+ private static void recursiveDelete(File file) {
+ //to end the recursive loop
+ if (!file.exists())
+ return;
+
+ //if directory, go inside and call recursively
+ if (file.isDirectory()) {
+ //call recursively
+ Arrays.stream(file.listFiles()).forEach(FileUtils::recursiveDelete);
+ }
+ //call delete to delete files and empty directory
+ file.delete();
+ }
+
public static void createPackInfo() {
JsonObject jsonObject = new JsonObject();
JsonObject pack = new JsonObject();
@@ -210,7 +270,7 @@ public class FileUtils {
String jsonString = gson.toJson(jsonObject);
try {
- FileWriter myWriter = new FileWriter(Main.NEWPACK_PATH + "pack_info.mcmeta");
+ Writer myWriter = new OutputStreamWriter(new FileOutputStream(Main.NEWPACK_PATH + "pack_info.mcmeta"), StandardCharsets.UTF_8);
myWriter.write(jsonString);
myWriter.close();
Logger.info("Successfully created the pack_info file.");
diff --git a/src/main/java/ch/m4th1eu/flansupdater/FrameController.java b/src/main/java/ch/m4th1eu/flansupdater/FrameController.java
new file mode 100644
index 0000000..5c53f9b
--- /dev/null
+++ b/src/main/java/ch/m4th1eu/flansupdater/FrameController.java
@@ -0,0 +1,141 @@
+package ch.m4th1eu.flansupdater;
+
+import javafx.application.Platform;
+import javafx.fxml.FXML;
+import javafx.scene.control.Alert;
+import javafx.scene.control.Button;
+import javafx.scene.control.TextField;
+import javafx.stage.FileChooser;
+import org.zeroturnaround.zip.ZipUtil;
+
+import java.awt.*;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.util.UUID;
+
+public class FrameController {
+ @FXML
+ TextField packname;
+ @FXML
+ Button bug;
+ @FXML
+ Button idea;
+ @FXML
+ Button convertir;
+ @FXML
+ Button selectpack;
+
+ private File selectedFile;
+
+ @FXML
+ private void initialize() {
+ registerHoverableButton(bug);
+ registerHoverableButton(idea);
+ registerHoverableButton(convertir);
+ registerHoverableButton(selectpack);
+
+ registerLinkableButton(bug, "https://github.com/M4TH1EU/Flan-s-Mod-Updater/issues/new?assignees=&labels=&template=bug_report.md&title=");
+ registerLinkableButton(idea, "https://github.com/M4TH1EU/Flan-s-Mod-Updater/issues/new?assignees=&labels=&template=feature_request.md&title=");
+
+ packname.setEditable(false);
+ convertir.setDisable(true);
+
+ convertir.setOnAction(event -> new Thread(() -> {
+ try {
+ Main.PACK_PATH = Files.createTempDirectory("flans-pack-old" + UUID.randomUUID()).toString() + "\\";
+ Main.NEWPACK_PATH = Files.createTempDirectory("flans-pack-updated" + UUID.randomUUID()).toString() + "\\";
+ Logger.info("Successfully set the new path to temps directories.");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ Platform.runLater(() -> {
+ selectpack.setDisable(true);
+ convertir.setDisable(true);
+ packname.setDisable(true);
+
+ convertir.setText("Extraction du pack...");
+ ZipUtil.unpack(new File(Main.PACK_ZIP), new File(Main.PACK_PATH));
+ });
+
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ Platform.runLater(() -> convertir.setText("Mise à jour..."));
+ Main.convert();
+ Platform.runLater(() -> convertir.setText("Terminé !"));
+ } catch (Exception e) {
+ Platform.runLater(() -> convertir.setText("Erreur, mise à jour échouée !"));
+ }
+
+ Platform.runLater(() -> {
+ Alert alert = new Alert(Alert.AlertType.INFORMATION);
+ alert.setTitle("Information");
+ alert.setHeaderText("Mise à jour terminée.");
+ alert.setContentText("La mise à jour du pack " + packname.getText() + " est terminée !" + "\nChemin : " + selectedFile.getParent());
+
+ alert.showAndWait();
+ });
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ FileUtils.deleteTempsFolder();
+
+ Platform.runLater(() -> {
+ packname.setText("");
+ selectedFile = new File("");
+ convertir.setText("Mettre à jour mon pack");
+ convertir.setDisable(false);
+ packname.setDisable(false);
+ selectpack.setDisable(false);
+ });
+ }).start());
+
+ selectpack.setOnAction(event -> {
+ FileChooser fileChooser = new FileChooser();
+ fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Flans Pack", "*.zip", "*.jar", "*.rar"));
+ selectedFile = fileChooser.showOpenDialog(Main.PRIMARY_STAGE);
+
+ if (selectedFile != null) {
+ packname.setText(selectedFile.getName());
+ Main.PACK_ZIP = selectedFile.getAbsolutePath();
+ }
+ convertir.setDisable(false);
+ });
+ }
+
+ public void registerHoverableButton(javafx.scene.control.Button button) {
+ button.setOnMouseEntered(event -> {
+ button.setStyle("-fx-background-color: grey; " +
+ "-fx-border-color: grey;" +
+ "-fx-text-fill: white;");
+ });
+
+ button.setOnMouseExited(event -> {
+ button.setStyle("-fx-background-color: transparent; " +
+ "-fx-border-color: grey;");
+ });
+
+ }
+
+ public void registerLinkableButton(javafx.scene.control.Button button, String url) {
+ button.setOnAction(event -> {
+ try {
+ Desktop.getDesktop().browse(new URI(url));
+ } catch (IOException | URISyntaxException e) {
+ e.printStackTrace();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/ch/m4th1eu/flansupdater/Main.java b/src/main/java/ch/m4th1eu/flansupdater/Main.java
index 536894a..413d8ae 100644
--- a/src/main/java/ch/m4th1eu/flansupdater/Main.java
+++ b/src/main/java/ch/m4th1eu/flansupdater/Main.java
@@ -1,39 +1,43 @@
package ch.m4th1eu.flansupdater;
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.scene.image.Image;
+import javafx.stage.Stage;
import org.zeroturnaround.zip.ZipUtil;
import java.io.File;
import java.nio.file.Paths;
-public class Main {
- public static final String PACK_PATH = "C:\\Users\\Mathieu\\Downloads\\Altis Mine Pack\\";
- public static final String NEWPACK_PATH = "C:\\Users\\Mathieu\\Downloads\\Altis Mine Pack NEW\\";
-
- public static final String VEHICLES_PATH = PACK_PATH + "vehicles\\";
- public static final String VEHICLES_NEWPATH = NEWPACK_PATH + "vehicles\\";
-
- public static final String ARMOR_PATH = PACK_PATH + "armorFiles\\";
- public static final String ARMOR_NEWPATH = NEWPACK_PATH + "armorFiles\\";
-
- public static final String ARMOR_TEXTURES_PATH = PACK_PATH + "assets\\flansmod\\armor\\";
- public static final String ARMOR_TEXTURES_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\armor\\";
-
- public static final String VEHICLESSKINS_PATH = PACK_PATH + "assets\\flansmod\\skins\\";
- public static final String VEHICLESSKINS_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\skins\\";
-
- public static final String JSON_PATH = NEWPACK_PATH + "assets\\flansmod\\models\\item\\";
-
- public static final String LANG_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\lang\\";
-
- public static final String MODELS_PATH = PACK_PATH + "com\\";
- public static final String MODELS_NEWPATH = NEWPACK_PATH + "com\\";
-
- public static final String ICONS_PATH = PACK_PATH + "assets\\flansmod\\textures\\items\\";
- public static final String ICONS_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\textures\\items\\";
-
+public class Main extends Application {
private static final Main INSTANCE = new Main();
- public static void main(String[] args) {
+ public static String PACK_ZIP = "C:\\Users\\Mathieu\\Downloads\\Altis Mine Pack.zip";
+ public static String PACK_PATH = "C:\\Users\\Mathieu\\Downloads\\Altis Mine Pack\\";
+ public static String VEHICLES_PATH = PACK_PATH + "vehicles\\";
+ public static String ARMOR_PATH = PACK_PATH + "armorFiles\\";
+ public static String ARMOR_TEXTURES_PATH = PACK_PATH + "assets\\flansmod\\armor\\";
+ public static String VEHICLESSKINS_PATH = PACK_PATH + "assets\\flansmod\\skins\\";
+ public static String MODELS_PATH = PACK_PATH + "com\\";
+ public static String ICONS_PATH = PACK_PATH + "assets\\flansmod\\textures\\items\\";
+ public static String NEWPACK_PATH = "C:\\Users\\Mathieu\\Downloads\\Altis Mine Pack NEW\\";
+ public static String VEHICLES_NEWPATH = NEWPACK_PATH + "vehicles\\";
+ public static String ARMOR_NEWPATH = NEWPACK_PATH + "armorFiles\\";
+ public static String ARMOR_TEXTURES_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\armor\\";
+ public static String VEHICLESSKINS_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\skins\\";
+ public static String JSON_PATH = PACK_PATH + "assets\\flansmod\\models\\item\\";
+ public static String JSON_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\models\\item\\";
+ public static String LANG_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\lang\\";
+ public static String MODELS_NEWPATH = NEWPACK_PATH + "com\\";
+ public static String ICONS_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\textures\\items\\";
+ public static Stage PRIMARY_STAGE = null;
+
+ public static void convert() {
+ Logger.info("Starting new pack update.");
+ refreshVariables();
+
FileUtils.copyModels();
VehiclesUtils.readAllVehiclesFiles();
VehiclesUtils.readAllVehiclesSkins();
@@ -43,9 +47,43 @@ public class Main {
FileUtils.createPackInfo();
FileUtils.writeLangs(FileUtils.langs);
- ZipUtil.pack(new File(NEWPACK_PATH), new File(Paths.get(NEWPACK_PATH).getParent() + "\\" + Paths.get(NEWPACK_PATH).getFileName() + ".zip"));
+ ZipUtil.pack(new File(NEWPACK_PATH),
+ new File(Paths.get(PACK_ZIP).getParent() + "\\" + Paths.get(PACK_ZIP).getFileName().toString().replaceAll(".zip", "")
+ .replaceAll(".jar", "")
+ .replaceAll(".rar", "")
+ + "_UPDATED.jar"));
+
Logger.info("Update complete.");
}
+ private static void refreshVariables() {
+ VEHICLES_PATH = PACK_PATH + "vehicles\\";
+ ARMOR_PATH = PACK_PATH + "armorFiles\\";
+ JSON_PATH = PACK_PATH + "assets\\flansmod\\models\\item\\";
+ ARMOR_TEXTURES_PATH = PACK_PATH + "assets\\flansmod\\armor\\";
+ VEHICLESSKINS_PATH = PACK_PATH + "assets\\flansmod\\skins\\";
+ MODELS_PATH = PACK_PATH + "com\\";
+ ICONS_PATH = PACK_PATH + "assets\\flansmod\\textures\\items\\";
+ VEHICLES_NEWPATH = NEWPACK_PATH + "vehicles\\";
+ ARMOR_NEWPATH = NEWPACK_PATH + "armorFiles\\";
+ ARMOR_TEXTURES_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\armor\\";
+ VEHICLESSKINS_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\skins\\";
+ JSON_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\models\\item\\";
+ LANG_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\lang\\";
+ MODELS_NEWPATH = NEWPACK_PATH + "com\\";
+ ICONS_NEWPATH = NEWPACK_PATH + "assets\\flansmod\\textures\\items\\";
+ Logger.info("Refreshed the variables.");
+ }
+ @Override
+ public void start(Stage primaryStage) throws Exception {
+ Parent root = FXMLLoader.load(Main.class.getResource("/menu.fxml"));
+
+ Main.PRIMARY_STAGE = primaryStage;
+ Main.PRIMARY_STAGE.setTitle("Flans Updater");
+ Main.PRIMARY_STAGE.setResizable(false);
+ Main.PRIMARY_STAGE.setScene(new Scene(root, 625, 365));
+ Main.PRIMARY_STAGE.getIcons().add(new Image(this.getClass().getResourceAsStream("/icon.png")));
+ Main.PRIMARY_STAGE.show();
+ }
}
diff --git a/src/main/java/ch/m4th1eu/flansupdater/VehiclesUtils.java b/src/main/java/ch/m4th1eu/flansupdater/VehiclesUtils.java
index e5b196d..4f20f3a 100644
--- a/src/main/java/ch/m4th1eu/flansupdater/VehiclesUtils.java
+++ b/src/main/java/ch/m4th1eu/flansupdater/VehiclesUtils.java
@@ -1,8 +1,7 @@
package ch.m4th1eu.flansupdater;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -33,7 +32,7 @@ public class VehiclesUtils {
}
try {
- FileWriter myWriter = new FileWriter(NEWFILENAME);
+ Writer myWriter = new OutputStreamWriter(new FileOutputStream(NEWFILENAME), StandardCharsets.UTF_8);
myWriter.write(processVehicleFile(readFile(path.toFile())));
myWriter.close();
} catch (IOException e) {
diff --git a/src/main/resources/icon.png b/src/main/resources/icon.png
new file mode 100644
index 0000000..b41ce12
Binary files /dev/null and b/src/main/resources/icon.png differ
diff --git a/src/main/resources/logo_transparent.png b/src/main/resources/logo_transparent.png
new file mode 100644
index 0000000..0597ffd
Binary files /dev/null and b/src/main/resources/logo_transparent.png differ
diff --git a/src/main/resources/menu.fxml b/src/main/resources/menu.fxml
new file mode 100644
index 0000000..68642b4
--- /dev/null
+++ b/src/main/resources/menu.fxml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/model.json b/src/main/resources/model.json
new file mode 100644
index 0000000..967e840
--- /dev/null
+++ b/src/main/resources/model.json
@@ -0,0 +1,76 @@
+{
+ "parent": "builtin/generated",
+ "textures": {
+ "layer0": "flansmod:items/your_item_texture"
+ },
+ "display": {
+ "thirdperson_lefthand": {
+ "rotation": [
+ 0,
+ 90,
+ -35
+ ],
+ "translation": [
+ 0,
+ 1.25,
+ -2.5
+ ],
+ "scale": [
+ 0.80,
+ 0.80,
+ 0.80
+ ]
+ },
+ "thirdperson_righthand": {
+ "rotation": [
+ 0,
+ 90,
+ -35
+ ],
+ "translation": [
+ 0,
+ 1.25,
+ -2.5
+ ],
+ "scale": [
+ 0.80,
+ 0.80,
+ 0.80
+ ]
+ },
+ "firstperson_lefthand": {
+ "rotation": [
+ 0,
+ -45,
+ 25
+ ],
+ "translation": [
+ 0,
+ 4,
+ 2
+ ],
+ "scale": [
+ 0.80,
+ 0.80,
+ 0.80
+ ]
+ },
+ "firstperson_righthand": {
+ "rotation": [
+ 0,
+ -45,
+ 25
+ ],
+ "translation": [
+ 0,
+ 4,
+ 2
+ ],
+ "scale": [
+ 0.80,
+ 0.80,
+ 0.80
+ ]
+ }
+ }
+}
\ No newline at end of file