From 81dbe3b234963c1d84f0096ddc2483b48b8dbed1 Mon Sep 17 00:00:00 2001 From: Paldiu Date: Fri, 26 Mar 2021 12:47:33 -0500 Subject: [PATCH] Json Stuff --- .../java/io/github/simplexdev/api/IJson.java | 10 ++ .../simplexcore/command/CommandLoader.java | 1 - .../simplexdev/simplexcore/config/Json.java | 103 ++++-------------- 3 files changed, 30 insertions(+), 84 deletions(-) create mode 100644 src/main/java/io/github/simplexdev/api/IJson.java diff --git a/src/main/java/io/github/simplexdev/api/IJson.java b/src/main/java/io/github/simplexdev/api/IJson.java new file mode 100644 index 0000000..d826397 --- /dev/null +++ b/src/main/java/io/github/simplexdev/api/IJson.java @@ -0,0 +1,10 @@ +package io.github.simplexdev.api; + +import io.github.simplexdev.api.func.Path; +import org.json.simple.JSONObject; + +public interface IJson { + JSONObject getJSONObject(Path path); + + +} diff --git a/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java b/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java index bbbef8c..fa9eef3 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java +++ b/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java @@ -16,7 +16,6 @@ import org.reflections.Reflections; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.util.Arrays; -import java.util.Map; import java.util.MissingResourceException; public final class CommandLoader { diff --git a/src/main/java/io/github/simplexdev/simplexcore/config/Json.java b/src/main/java/io/github/simplexdev/simplexcore/config/Json.java index c901038..c897be0 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/config/Json.java +++ b/src/main/java/io/github/simplexdev/simplexcore/config/Json.java @@ -1,96 +1,33 @@ package io.github.simplexdev.simplexcore.config; -import io.github.simplexdev.api.IConfig; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import io.github.simplexdev.api.IJson; import io.github.simplexdev.api.func.Path; -import org.bukkit.configuration.ConfigurationSection; +import io.github.simplexdev.simplexcore.module.SimplexModule; +import org.json.simple.JSONObject; -import java.util.List; - -public class Json implements IConfig { +public final class Json implements IJson { // TODO: Write actual JSON implementations. + // + private final Gson gson; + private final SimplexModule plugin; - @Override - public void set(Path path, Object value) { + Json(SimplexModule plugin) { + this.gson = new GsonBuilder().setPrettyPrinting().create(); + this.plugin = plugin; + } + final Gson getGson() { + return gson; + } + + public final SimplexModule getPlugin() { + return plugin; } @Override - public boolean contains(Path path) { - return false; - } - - @Override - public ConfigurationSection getConfigurationSection(Path path) { - return null; - } - - @Override - public List getStringList(Path path) { - return null; - } - - @Override - public long getLong(Path path) { - return 0; - } - - @Override - public List getList(Path path) { - return null; - } - - @Override - public boolean getBoolean(Path path) { - return false; - } - - @Override - public int getInt(Path path) { - return 0; - } - - @Override - public double getDouble(Path path) { - return 0; - } - - @Override - public String getString(Path path) { - return null; - } - - @Override - public long getLong(Path path, long def) { - return 0; - } - - @Override - public List getList(Path path, List def) { - return null; - } - - @Override - public boolean getBoolean(Path path, boolean def) { - return false; - } - - @Override - public int getInt(Path path, int def) { - return 0; - } - - @Override - public double getDouble(Path path, double def) { - return 0; - } - - @Override - public String getString(Path path, String def) { - return null; - } - - @Override - public Object get(Path path, Object def) { + public JSONObject getJSONObject(Path path) { return null; } }