diff --git a/.gitignore b/.gitignore
index 1810748..ae298ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
.idea
!.idea/artifacts/*
+!.idea/libraries/*
!.idea/compiler.xml
!.idea/encodings.xml
!.idea/misc.xml
diff --git a/.idea/artifacts/Launcher.xml b/.idea/artifacts/Launcher.xml
index e359b78..a1a1039 100644
--- a/.idea/artifacts/Launcher.xml
+++ b/.idea/artifacts/Launcher.xml
@@ -7,6 +7,7 @@
+
\ No newline at end of file
diff --git a/.idea/libraries/hikaricp_2_4_0.xml b/.idea/libraries/hikaricp_2_4_0.xml
new file mode 100644
index 0000000..f250036
--- /dev/null
+++ b/.idea/libraries/hikaricp_2_4_0.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/jansi_1_11.xml b/.idea/libraries/jansi_1_11.xml
new file mode 100644
index 0000000..08d74af
--- /dev/null
+++ b/.idea/libraries/jansi_1_11.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/jline_2_12_1.xml b/.idea/libraries/jline_2_12_1.xml
new file mode 100644
index 0000000..e4f7633
--- /dev/null
+++ b/.idea/libraries/jline_2_12_1.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/minimal_json_0_9_4.xml b/.idea/libraries/minimal_json_0_9_4.xml
new file mode 100644
index 0000000..b1d6e1b
--- /dev/null
+++ b/.idea/libraries/minimal_json_0_9_4.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/mysql_5_1_36.xml b/.idea/libraries/mysql_5_1_36.xml
new file mode 100644
index 0000000..e539066
--- /dev/null
+++ b/.idea/libraries/mysql_5_1_36.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LaunchServer/source/command/hash/IndexAssetCommand.java b/LaunchServer/source/command/hash/IndexAssetCommand.java
index 13d1316..9fe49a4 100644
--- a/LaunchServer/source/command/hash/IndexAssetCommand.java
+++ b/LaunchServer/source/command/hash/IndexAssetCommand.java
@@ -9,6 +9,9 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collections;
+import com.eclipsesource.json.Json;
+import com.eclipsesource.json.JsonObject;
+import com.eclipsesource.json.WriterConfig;
import launcher.LauncherAPI;
import launcher.helper.IOHelper;
import launcher.helper.LogHelper;
@@ -16,7 +19,6 @@
import launchserver.LaunchServer;
import launchserver.command.Command;
import launchserver.command.CommandException;
-import org.json.JSONObject;
public final class IndexAssetCommand extends Command {
public static final String INDEXES_DIR = "indexes";
@@ -54,16 +56,14 @@
Files.createDirectory(outputAssetDir);
// Index objects
+ JsonObject objects = Json.object();
LogHelper.subInfo("Indexing objects");
- JSONObject objects = new JSONObject();
IOHelper.walk(inputAssetDir, new IndexAssetVisitor(objects, inputAssetDir, outputAssetDir), false);
// Write index file
LogHelper.subInfo("Writing asset index file: '%s'", indexFileName);
try (BufferedWriter writer = IOHelper.newWriter(resolveIndexFile(outputAssetDir, indexFileName))) {
- JSONObject root = new JSONObject();
- root.put(OBJECTS_DIR, objects);
- root.write(writer);
+ Json.object().add(OBJECTS_DIR, objects).writeTo(writer, WriterConfig.MINIMAL);
}
// Finished
@@ -82,11 +82,11 @@
}
private static final class IndexAssetVisitor extends SimpleFileVisitor {
- private final JSONObject objects;
+ private final JsonObject objects;
private final Path inputAssetDir;
private final Path outputAssetDir;
- private IndexAssetVisitor(JSONObject objects, Path inputAssetDir, Path outputAssetDir) {
+ private IndexAssetVisitor(JsonObject objects, Path inputAssetDir, Path outputAssetDir) {
this.objects = objects;
this.inputAssetDir = inputAssetDir;
this.outputAssetDir = outputAssetDir;
@@ -97,17 +97,12 @@
String name = IOHelper.toString(inputAssetDir.relativize(file));
LogHelper.subInfo("Indexing: '%s'", name);
- // Calculate SHA-1 digest and get size
+ // Add to index and copy file
String digest = SecurityHelper.toHex(SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA1, file));
-
- // Add to objects
- JSONObject object = new JSONObject();
- object.put("size", attrs.size());
- object.put("hash", digest);
- objects.put(name, object);
-
- // Copy file
+ objects.add(name, Json.object().add("size", attrs.size()).add("hash", digest));
IOHelper.copy(file, resolveObjectFile(outputAssetDir, digest));
+
+ // Continue visiting
return super.visitFile(file, attrs);
}
}
diff --git a/LaunchServer/source/command/hash/UnindexAssetCommand.java b/LaunchServer/source/command/hash/UnindexAssetCommand.java
index 2d1941c..6362598 100644
--- a/LaunchServer/source/command/hash/UnindexAssetCommand.java
+++ b/LaunchServer/source/command/hash/UnindexAssetCommand.java
@@ -5,13 +5,13 @@
import java.nio.file.Path;
import java.util.Collections;
+import com.eclipsesource.json.Json;
+import com.eclipsesource.json.JsonObject;
import launcher.helper.IOHelper;
import launcher.helper.LogHelper;
import launchserver.LaunchServer;
import launchserver.command.Command;
import launchserver.command.CommandException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
public final class UnindexAssetCommand extends Command {
public UnindexAssetCommand(LaunchServer server) {
@@ -45,22 +45,20 @@
Files.createDirectory(outputAssetDir);
// Read JSON file
+ JsonObject objects;
LogHelper.subInfo("Reading asset index file: '%s'", indexFileName);
- JSONObject objects;
try (BufferedReader reader = IOHelper.newReader(IndexAssetCommand.resolveIndexFile(inputAssetDir, indexFileName))) {
- objects = new JSONObject(new JSONTokener(reader)).getJSONObject(IndexAssetCommand.OBJECTS_DIR);
+ objects = Json.parse(reader).asObject().get(IndexAssetCommand.OBJECTS_DIR).asObject();
}
// Restore objects
- LogHelper.subInfo("Unindexing %d objects", objects.length());
- for (String name : objects.keySet()) {
+ LogHelper.subInfo("Unindexing %d objects", objects.size());
+ for (JsonObject.Member member : objects) {
+ String name = member.getName();
LogHelper.subInfo("Unindexing: '%s'", name);
- // Get JSON object
- JSONObject object = objects.getJSONObject(name);
- String hash = object.getString("hash");
-
// Copy hashed file to target
+ String hash = member.getValue().asObject().get("hash").asString();
Path source = IndexAssetCommand.resolveObjectFile(inputAssetDir, hash);
IOHelper.copy(source, outputAssetDir.resolve(name));
}
diff --git a/Launcher/Launcher.iml b/Launcher/Launcher.iml
index b37175f..21cb0d9 100644
--- a/Launcher/Launcher.iml
+++ b/Launcher/Launcher.iml
@@ -3,13 +3,13 @@
-
-
+
+
\ No newline at end of file
diff --git a/Launcher/source-json/JSONArray.java b/Launcher/source-json/JSONArray.java
deleted file mode 100644
index 3f05548..0000000
--- a/Launcher/source-json/JSONArray.java
+++ /dev/null
@@ -1,977 +0,0 @@
-package org.json;
-
-/*
- Copyright (c) 2002 JSON.org
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- The Software shall be used for Good, not Evil.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * A JSONArray is an ordered sequence of values. Its external text form is a
- * string wrapped in square brackets with commas separating the values. The
- * internal form is an object having get and opt
- * methods for accessing the values by index, and put methods for
- * adding or replacing values. The values can be any of these types:
- * Boolean, JSONArray, JSONObject,
- * Number, String, or the
- * JSONObject.NULL object.
- *
- * The constructor can convert a JSON text into a Java object. The
- * toString method converts to JSON text.
- *
- * A get method returns a value if one can be found, and throws an
- * exception if one cannot be found. An opt method returns a
- * default value instead of throwing an exception, and so is useful for
- * obtaining optional values.
- *
- * The generic get() and opt() methods return an
- * object which you can cast or query for type. There are also typed
- * get and opt methods that do type checking and type
- * coercion for you.
- *
- * The texts produced by the toString methods strictly conform to
- * JSON syntax rules. The constructors are more forgiving in the texts they will
- * accept:
- *
- *
An extra , (comma) may appear just
- * before the closing bracket.
- *
The null value will be inserted when there is ,
- * (comma) elision.
- *
Strings may be quoted with ' (single
- * quote).
- *
Strings do not need to be quoted at all if they do not begin with a quote
- * or single quote, and if they do not contain leading or trailing spaces, and
- * if they do not contain any of these characters:
- * { } [ ] / \ : , # and if they do not look like numbers and
- * if they are not the reserved words true, false, or
- * null.
- *
- *
- * @author JSON.org
- * @version 2014-05-03
- */
-public class JSONArray {
-
- /**
- * The arrayList where the JSONArray's properties are kept.
- */
- private final ArrayList