Updated AddonscriptJSON format
This commit is contained in:
parent
8e16457e6c
commit
067994b705
|
@ -9,12 +9,13 @@ sourceCompatibility = 1.8
|
|||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.google.code.gson:gson:+'
|
||||
compile 'org.apache.maven:maven-core:+'
|
||||
compile 'org.python:jython:2.7.0'
|
||||
|
||||
compile "com.github.TheRandomLabs:CurseAPI:master-SNAPSHOT"
|
||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||
}
|
||||
|
|
|
@ -3,13 +3,12 @@ package ley.anvil.addonscript.util;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
|
||||
public abstract class JSON {
|
||||
|
||||
public static Gson gson = new GsonBuilder().create();
|
||||
public static Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
public String toJSON() {
|
||||
return gson.toJson(this);
|
||||
|
@ -20,14 +19,16 @@ public abstract class JSON {
|
|||
return toJSON();
|
||||
}
|
||||
|
||||
public String toFormattedJSON() {
|
||||
return formatJSON(toJSON());
|
||||
public void write(Writer writer) {
|
||||
gson.toJson(this, writer);
|
||||
}
|
||||
|
||||
public static <T> T read(Reader reader, Class<T> type) {
|
||||
return gson.fromJson(reader, type);
|
||||
}
|
||||
|
||||
public static String formatJSON(String json) {
|
||||
//TODO JSON formatting
|
||||
return json;
|
||||
public static <T> T fromJSON(String json, Class<T> type) {
|
||||
return gson.fromJson(json, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.List;
|
|||
public class AddonscriptJSON extends JSON {
|
||||
|
||||
public static AddonscriptJSON fromJSON(String json) {
|
||||
return gson.fromJson(json, AddonscriptJSON.class);
|
||||
return fromJSON(json, AddonscriptJSON.class);
|
||||
}
|
||||
|
||||
public static AddonscriptJSON create() {
|
||||
|
@ -176,6 +176,14 @@ public class AddonscriptJSON extends JSON {
|
|||
}
|
||||
|
||||
public static class File {
|
||||
/**
|
||||
* The ID of this file.
|
||||
* If multiple files have the same ID,
|
||||
* Addonscript will interpret this files as identical.
|
||||
* Addonscript will then try to install the first of them
|
||||
* and only if this fails, it will try the next.
|
||||
*/
|
||||
public String id;
|
||||
/**
|
||||
* The installer for this file
|
||||
* Format: <installerid>:<param 1>:<param 2>...
|
||||
|
@ -219,12 +227,6 @@ public class AddonscriptJSON extends JSON {
|
|||
* Supported type: included, required, recommended, optional or incompatible
|
||||
*/
|
||||
public String type = "included";
|
||||
/**
|
||||
* Informations about the version of the addons
|
||||
* Only useable when using a link to a Addonscript JSON file
|
||||
*/
|
||||
public VersionData version;
|
||||
|
||||
/**
|
||||
* Meta information for this relation
|
||||
* This is not always useful, because some repositories, like curseforge, are
|
||||
|
@ -247,25 +249,4 @@ public class AddonscriptJSON extends JSON {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently useless
|
||||
*/
|
||||
public static class VersionData {
|
||||
|
||||
public String version;
|
||||
|
||||
public int versionID;
|
||||
|
||||
public int minVersion;
|
||||
|
||||
public int maxVersion;
|
||||
|
||||
public boolean openUp;
|
||||
|
||||
public boolean openDown;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue