mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
IsEmpty runtime fix.
This commit is contained in:
commit
3908351a5d
2 changed files with 8 additions and 19 deletions
|
@ -12,6 +12,7 @@
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.command.CommandException;
|
||||
|
@ -35,11 +36,11 @@ public IndexObject(long size, String hash) {
|
|||
}
|
||||
|
||||
private static final class IndexAssetVisitor extends SimpleFileVisitor<Path> {
|
||||
private final JsonArray objects;
|
||||
private final JsonObject objects;
|
||||
private final Path inputAssetDir;
|
||||
private final Path outputAssetDir;
|
||||
|
||||
private IndexAssetVisitor(JsonArray objects, Path inputAssetDir, Path outputAssetDir) {
|
||||
private IndexAssetVisitor(JsonObject objects, Path inputAssetDir, Path outputAssetDir) {
|
||||
this.objects = objects;
|
||||
this.inputAssetDir = inputAssetDir;
|
||||
this.outputAssetDir = outputAssetDir;
|
||||
|
@ -53,7 +54,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
|
|||
// Add to index and copy file
|
||||
String digest = SecurityHelper.toHex(SecurityHelper.digest(DigestAlgorithm.SHA1, file));
|
||||
IndexObject obj = new IndexObject(attrs.size(), digest);
|
||||
objects.add(gson.toJsonTree(obj));
|
||||
objects.add(name, gson.toJsonTree(obj));
|
||||
IOHelper.copy(file, resolveObjectFile(outputAssetDir, digest));
|
||||
|
||||
// Continue visiting
|
||||
|
@ -106,7 +107,7 @@ public void invoke(String... args) throws Exception {
|
|||
Files.createDirectory(outputAssetDir);
|
||||
|
||||
// Index objects
|
||||
JsonArray objects = new JsonArray();
|
||||
JsonObject objects = new JsonObject();
|
||||
LogHelper.subInfo("Indexing objects");
|
||||
IOHelper.walk(inputAssetDir, new IndexAssetVisitor(objects, inputAssetDir, outputAssetDir), false);
|
||||
|
||||
|
@ -114,7 +115,9 @@ public void invoke(String... args) throws Exception {
|
|||
LogHelper.subInfo("Writing asset index file: '%s'", indexFileName);
|
||||
|
||||
try (BufferedWriter writer = IOHelper.newWriter(resolveIndexFile(outputAssetDir, indexFileName))) {
|
||||
writer.write(gson.toJson(objects));
|
||||
JsonObject result = new JsonObject();
|
||||
result.add("objects",objects);
|
||||
writer.write(gson.toJson(result));
|
||||
}
|
||||
|
||||
// Finished
|
||||
|
|
|
@ -28,17 +28,3 @@ DirBridge.defaultUpdatesDir = DirBridge.dir.resolve("updates");
|
|||
if (!IOHelper.isDir(DirBridge.defaultUpdatesDir)) {
|
||||
java.nio.file.Files.createDirectory(DirBridge.defaultUpdatesDir);
|
||||
}
|
||||
|
||||
//====== SERVERS CONFIG ====== //
|
||||
var serversConfig = {
|
||||
defaults: {
|
||||
// Лозунг сервера
|
||||
description: "Мир в котором возможно все"
|
||||
},
|
||||
getServerProperty: function(profile, property){
|
||||
if(serversConfig[profile]==null || serversConfig[profile][property]==null){
|
||||
return serversConfig.defaults[property];
|
||||
}
|
||||
return serversConfig[profile][property];
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue