From 22c2e20d3ca6935249251047000f9663b221bead Mon Sep 17 00:00:00 2001 From: sekwah Date: Wed, 17 Jan 2018 05:56:11 +0000 Subject: [PATCH 1/3] Added code to save the config file after loading it --- .../core/AdvancedPortalsCore.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java b/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java index 4a03f72..f3a4a54 100644 --- a/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java +++ b/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java @@ -7,9 +7,9 @@ import com.sekwah.advancedportals.core.util.InfoLogger; public class AdvancedPortalsCore { private static AdvancedPortalsCore instance; - private static DataStorage dataStorage; - private static InfoLogger infoLogger; - private static Config config; + private DataStorage dataStorage; + private InfoLogger infoLogger; + private Config config; public AdvancedPortalsCore(DataStorage dataStorage, InfoLogger infoLogger) { this.dataStorage = dataStorage; @@ -19,12 +19,20 @@ public class AdvancedPortalsCore { } private void onEnable() { - config = dataStorage.loadJson(Config.class, "config.json"); - infoLogger.log("\u00A7aAdvanced portals have been successfully enabled!"); + this.loadPortalData(); + infoLogger.log("Advanced portals have been successfully enabled!"); + } + + /** + * Can be used for in /portal reload as well. + */ + private void loadPortalData() { + this.config = this.dataStorage.loadJson(Config.class, "config.json"); + this.dataStorage.storeJson(this.config, "config.json"); } public void onDisable() { - infoLogger.log("\u00A7cAdvanced portals are being disabled!"); + infoLogger.log("Advanced portals are being disabled!"); } private static AdvancedPortalsCore getInstance() { @@ -32,10 +40,10 @@ public class AdvancedPortalsCore { } public static DataStorage getDataStorage() { - return dataStorage; + return instance.dataStorage; } public static InfoLogger getInfoLogger() { - return infoLogger; + return instance.infoLogger; } } From 854c06eba322e08e4198cd213092b5c28cf44351 Mon Sep 17 00:00:00 2001 From: sekwah Date: Thu, 18 Jan 2018 06:28:51 +0000 Subject: [PATCH 2/3] started adding command template --- .../core/api/commands/SubCommand.java | 2 +- .../core/commands/CommandTemplate.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/com/sekwah/advancedportals/core/commands/CommandTemplate.java diff --git a/src/com/sekwah/advancedportals/core/api/commands/SubCommand.java b/src/com/sekwah/advancedportals/core/api/commands/SubCommand.java index 840bb8a..385b589 100644 --- a/src/com/sekwah/advancedportals/core/api/commands/SubCommand.java +++ b/src/com/sekwah/advancedportals/core/api/commands/SubCommand.java @@ -5,7 +5,7 @@ import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer import java.util.List; /** - * Subcommand that can be registered to parts. + * Subcommand that can be registered under e.g. /portal show or /portal edit * * @author sekwah41 */ diff --git a/src/com/sekwah/advancedportals/core/commands/CommandTemplate.java b/src/com/sekwah/advancedportals/core/commands/CommandTemplate.java new file mode 100644 index 0000000..1831ccd --- /dev/null +++ b/src/com/sekwah/advancedportals/core/commands/CommandTemplate.java @@ -0,0 +1,18 @@ +package com.sekwah.advancedportals.core.commands; + +import com.sun.corba.se.impl.activation.CommandHandler; + +import java.util.List; + +/** + * Already know spigot's auto complete possibilities + * + * Sponge https://docs.spongepowered.org/stable/en/plugin/commands/arguments.html#custom-command-elements + */ +public interface CommandTemplate { + + void onCommand(CommandHandler sender, String[] args); + + List onTabComplete(CommandHandler sender, String[] args); + +} From b508e7e0cc061cf1620efa8b15c967ca49c22818 Mon Sep 17 00:00:00 2001 From: sekwah Date: Fri, 19 Jan 2018 02:39:39 +0000 Subject: [PATCH 3/3] Added some info and started command stuff a little --- .../advancedportals/core/commands/CommandTemplate.java | 6 ++++++ .../sekwah/advancedportals/core/commands/PortalCommand.java | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 src/com/sekwah/advancedportals/core/commands/PortalCommand.java diff --git a/src/com/sekwah/advancedportals/core/commands/CommandTemplate.java b/src/com/sekwah/advancedportals/core/commands/CommandTemplate.java index 1831ccd..1d5c2bd 100644 --- a/src/com/sekwah/advancedportals/core/commands/CommandTemplate.java +++ b/src/com/sekwah/advancedportals/core/commands/CommandTemplate.java @@ -13,6 +13,12 @@ public interface CommandTemplate { void onCommand(CommandHandler sender, String[] args); + /** + * Fired when someone asks for a tab complete action. + * @param sender + * @param args + * @return + */ List onTabComplete(CommandHandler sender, String[] args); } diff --git a/src/com/sekwah/advancedportals/core/commands/PortalCommand.java b/src/com/sekwah/advancedportals/core/commands/PortalCommand.java new file mode 100644 index 0000000..fa36282 --- /dev/null +++ b/src/com/sekwah/advancedportals/core/commands/PortalCommand.java @@ -0,0 +1,4 @@ +package com.sekwah.advancedportals.core.commands; + +public class PortalCommand { +}