mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
add maven assembly plugin, disable assets extraction
This commit is contained in:
parent
06abdb64a8
commit
4e08fe3665
19
pom.xml
19
pom.xml
@ -38,6 +38,19 @@
|
||||
<mainClass>de.bixilon.minosoft.Minosoft</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>de.bixilon.minosoft.Minosoft</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@ -84,5 +97,11 @@
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>1.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<type>maven-plugin</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -37,7 +37,7 @@ import java.util.Map;
|
||||
|
||||
public class Launcher extends Application {
|
||||
|
||||
public static void main() {
|
||||
public static void start() {
|
||||
launch();
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ import de.bixilon.minosoft.gui.main.AccountListCell;
|
||||
import de.bixilon.minosoft.gui.main.Server;
|
||||
import de.bixilon.minosoft.logging.Log;
|
||||
import de.bixilon.minosoft.logging.LogLevels;
|
||||
import de.bixilon.minosoft.util.FolderUtil;
|
||||
import de.bixilon.minosoft.util.OSUtil;
|
||||
import de.bixilon.minosoft.util.Util;
|
||||
import de.bixilon.minosoft.util.mojang.api.MojangAccount;
|
||||
@ -55,13 +54,10 @@ public class Minosoft {
|
||||
// set log level from config
|
||||
Log.setLevel(LogLevels.valueOf(config.getString(GameConfiguration.GENERAL_LOG_LEVEL)));
|
||||
Log.info(String.format("Logging info with level: %s", Log.getLevel()));
|
||||
Log.info("Checking assets...");
|
||||
checkAssets();
|
||||
Log.info("Assets checking done");
|
||||
Log.info("Loading versions.json...");
|
||||
long mappingStartLoadingTime = System.currentTimeMillis();
|
||||
try {
|
||||
Versions.load(Util.readJsonFromFile(Config.homeDir + "assets/mapping/versions.json"));
|
||||
Versions.load(Util.readJsonAsset("mapping/versions.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
@ -75,7 +71,7 @@ public class Minosoft {
|
||||
|
||||
|
||||
serverList = config.getServers();
|
||||
Launcher.main();
|
||||
Launcher.start();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,16 +107,6 @@ public class Minosoft {
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkAssets() {
|
||||
try {
|
||||
FolderUtil.copyFolder(Minosoft.class.getResource("/assets").toURI(), Config.homeDir + "assets/");
|
||||
} catch (Exception e) {
|
||||
Log.fatal("Error occurred while checking assets: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<Server> getServerList() {
|
||||
return serverList;
|
||||
}
|
||||
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Codename Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.util;
|
||||
|
||||
import de.bixilon.minosoft.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class FolderUtil {
|
||||
|
||||
public static void copyFolder(URI from, String to) throws IOException {
|
||||
File folder = new File(from);
|
||||
for (String entry : folder.list()) {
|
||||
File entryFile = new File(folder.getPath() + File.separator + entry);
|
||||
if (entryFile.isDirectory()) {
|
||||
copyFolder(entryFile.toURI(), to + File.separator + entry);
|
||||
continue;
|
||||
}
|
||||
File out = new File(to + File.separator + entry);
|
||||
if (out.exists()) {
|
||||
// check
|
||||
if (Files.mismatch(Path.of(entryFile.getPath()), Path.of(out.getPath())) == -1) {
|
||||
// identically
|
||||
continue;
|
||||
}
|
||||
// move file to an other location and re extract
|
||||
moveFileToOld(out);
|
||||
}
|
||||
File outFolder = new File(out.getParent());
|
||||
if (!outFolder.exists()) {
|
||||
outFolder.mkdirs();
|
||||
}
|
||||
Files.copy(new FileInputStream(entryFile), out.toPath());
|
||||
}
|
||||
}
|
||||
|
||||
private static void moveFileToOld(File file) {
|
||||
File newFile = new File(file.getAbsolutePath() + ".old");
|
||||
if (newFile.exists()) {
|
||||
newFile.delete();
|
||||
Log.verbose(String.format("Deleted file: %s", newFile.getAbsoluteFile()));
|
||||
}
|
||||
file.renameTo(newFile);
|
||||
Log.verbose(String.format("Renamed %s to: %s", newFile.getAbsoluteFile(), newFile.getName()));
|
||||
}
|
||||
}
|
@ -128,6 +128,14 @@ public final class Util {
|
||||
return readFile(new File(fileName));
|
||||
}
|
||||
|
||||
public static String readAsset(String path) throws IOException {
|
||||
return readFile(new BufferedReader((new InputStreamReader(Util.class.getResourceAsStream("/assets/" + path)))), true);
|
||||
}
|
||||
|
||||
public static JsonObject readJsonAsset(String path) throws IOException {
|
||||
return (JsonObject) JsonParser.parseString(readAsset(path));
|
||||
}
|
||||
|
||||
public static String readFile(BufferedReader reader, boolean closeStream) throws IOException {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
String ls = System.getProperty("line.separator");
|
||||
|
Loading…
x
Reference in New Issue
Block a user