From 108442ad437a01aa12faa01bab3ba3fecb929bd5 Mon Sep 17 00:00:00 2001 From: CarmJos Date: Tue, 22 Feb 2022 02:59:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=9A=E7=94=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=B8=8E=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/carm/plugin/easysql/EasySQLAPI.java | 2 +- easysql-plugin-core/pom.xml | 7 ++ .../plugin/easysql/EasySQLPluginPlatform.java | 7 +- .../easysql/command/EasySQLCommand.java | 11 +++ .../plugin/easysql/util/ResourceReadUtil.java | 27 +++++++ platforms/easysql-plugin-bukkit/pom.xml | 23 +++++- .../cc/carm/plugin/easysql/EasySQLBukkit.java | 54 ------------- .../plugin/easysql/bukkit/EasySQLBukkit.java | 78 +++++++++++++++++++ .../src/main/resources/plugin.yml | 21 +++++ platforms/easysql-plugin-bungee/pom.xml | 31 +++++++- .../cc/carm/plugin/easysql/EasySQLBungee.java | 6 ++ platforms/easysql-plugin-sponge/pom.xml | 20 +++++ platforms/easysql-plugin-velocity/pom.xml | 13 +++- pom.xml | 12 +-- 14 files changed, 246 insertions(+), 66 deletions(-) create mode 100644 easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/command/EasySQLCommand.java create mode 100644 easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/util/ResourceReadUtil.java delete mode 100644 platforms/easysql-plugin-bukkit/src/main/java/cc/carm/plugin/easysql/EasySQLBukkit.java create mode 100644 platforms/easysql-plugin-bukkit/src/main/java/cc/carm/plugin/easysql/bukkit/EasySQLBukkit.java create mode 100644 platforms/easysql-plugin-sponge/pom.xml diff --git a/easysql-plugin-api/src/main/java/cc/carm/plugin/easysql/EasySQLAPI.java b/easysql-plugin-api/src/main/java/cc/carm/plugin/easysql/EasySQLAPI.java index 112a553..6a85c70 100644 --- a/easysql-plugin-api/src/main/java/cc/carm/plugin/easysql/EasySQLAPI.java +++ b/easysql-plugin-api/src/main/java/cc/carm/plugin/easysql/EasySQLAPI.java @@ -6,7 +6,7 @@ public class EasySQLAPI { protected static EasySQLRegistry api; - protected static void init(EasySQLRegistry api) { + protected static void initializeAPI(EasySQLRegistry api) { EasySQLAPI.api = api; } diff --git a/easysql-plugin-core/pom.xml b/easysql-plugin-core/pom.xml index cb192e9..2617ed5 100644 --- a/easysql-plugin-core/pom.xml +++ b/easysql-plugin-core/pom.xml @@ -30,6 +30,13 @@ compile + + co.aikar + acf-core + 0.5.1-SNAPSHOT + provided + + com.github.chris2018998 beecp diff --git a/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/EasySQLPluginPlatform.java b/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/EasySQLPluginPlatform.java index 0fd7e99..34c9587 100644 --- a/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/EasySQLPluginPlatform.java +++ b/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/EasySQLPluginPlatform.java @@ -1,6 +1,7 @@ package cc.carm.plugin.easysql; import cc.carm.plugin.easysql.api.DBConfiguration; +import cc.carm.plugin.easysql.api.EasySQLRegistry; import org.jetbrains.annotations.NotNull; import java.util.Map; @@ -9,7 +10,7 @@ import java.util.logging.Logger; public interface EasySQLPluginPlatform { - + @NotNull EasySQLRegistry getRegistry(); @NotNull Map readConfigurations(); @@ -17,4 +18,8 @@ public interface EasySQLPluginPlatform { Logger getLogger(); + default void initializeAPI(EasySQLRegistry registry) { + EasySQLAPI.initializeAPI(registry); + } + } diff --git a/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/command/EasySQLCommand.java b/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/command/EasySQLCommand.java new file mode 100644 index 0000000..399b286 --- /dev/null +++ b/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/command/EasySQLCommand.java @@ -0,0 +1,11 @@ +package cc.carm.plugin.easysql.command; + +import co.aikar.commands.BaseCommand; + + +public class EasySQLCommand extends BaseCommand { + + + + +} diff --git a/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/util/ResourceReadUtil.java b/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/util/ResourceReadUtil.java new file mode 100644 index 0000000..b2a37f3 --- /dev/null +++ b/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/util/ResourceReadUtil.java @@ -0,0 +1,27 @@ +package cc.carm.plugin.easysql.util; + +import org.jetbrains.annotations.Nullable; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +public class ResourceReadUtil { + + + public static @Nullable String[] readResource(@Nullable InputStream resourceStream) { + if (resourceStream == null) return null; + try (Scanner scanner = new Scanner(resourceStream, "UTF-8")) { + List contents = new ArrayList<>(); + while (scanner.hasNextLine()) { + contents.add(scanner.nextLine()); + } + return contents.toArray(new String[0]); + } catch (Exception e) { + return null; + } + } + + +} diff --git a/platforms/easysql-plugin-bukkit/pom.xml b/platforms/easysql-plugin-bukkit/pom.xml index 5270c52..6ff23f2 100644 --- a/platforms/easysql-plugin-bukkit/pom.xml +++ b/platforms/easysql-plugin-bukkit/pom.xml @@ -24,7 +24,6 @@ EasySQL-Plugin-Bukkit - @@ -37,6 +36,8 @@ cc.carm.lib easyplugin-main + ${easyplugin.version} + true compile @@ -50,9 +51,19 @@ org.bstats bstats-bukkit - 2.2.1 + 3.0.0 + true compile + + + co.aikar + acf-paper + 0.5.1-SNAPSHOT + true + compile + + @@ -87,6 +98,14 @@ cc.carm.lib.easyplugin cc.carm.plugin.easysql.lib.easyplugin + + co.aikar.commands + cc.carm.plugin.easysql.lib.acf + + + co.aikar.locales + cc.carm.plugin.easysql.lib.locales + diff --git a/platforms/easysql-plugin-bukkit/src/main/java/cc/carm/plugin/easysql/EasySQLBukkit.java b/platforms/easysql-plugin-bukkit/src/main/java/cc/carm/plugin/easysql/EasySQLBukkit.java deleted file mode 100644 index 45e25fa..0000000 --- a/platforms/easysql-plugin-bukkit/src/main/java/cc/carm/plugin/easysql/EasySQLBukkit.java +++ /dev/null @@ -1,54 +0,0 @@ -package cc.carm.plugin.easysql; - -import cc.carm.lib.easyplugin.EasyPlugin; -import cc.carm.lib.easyplugin.i18n.EasyPluginMessageProvider; -import cc.carm.plugin.easysql.api.DBConfiguration; -import cc.carm.plugin.easysql.util.PropertiesUtil; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -public class EasySQLBukkit extends EasyPlugin implements EasySQLPluginPlatform { - - public EasySQLBukkit() { - super(new EasyPluginMessageProvider.zh_CN()); - } - - @Override - protected void load() { - - } - - @Override - protected boolean initialize() { - return false; - } - - @Override - public @NotNull Map readConfigurations() { - return new HashMap<>(); - } - - @Override - public @NotNull Map readProperties() { - return PropertiesUtil.readDBProperties(new File(getDataFolder(), "properties")); - } - - @Override - public void outputInfo() { - log("\n" + - "&5&l ______ _____ ____ _ &d&l_____ _ _ \n" + - "&5&l| ____| / ____|/ __ \\| | &d&l| __ \\| | (_) \n" + - "&5&l| |__ __ _ ___ _ _| (___ | | | | | &d&l| |__) | |_ _ __ _ _ _ __ \n" + - "&5&l| __| / _` / __| | | |\\___ \\| | | | | &d&l| ___/| | | | |/ _` | | '_ \\ \n" + - "&5&l| |___| (_| \\__ \\ |_| |____) | |__| | |____ &d&l| | | | |_| | (_| | | | | |\n" + - "&5&l|______\\__,_|___/\\__, |_____/ \\___\\_\\______| &d&l|_| |_|\\__,_|\\__, |_|_| |_|\n" + - "&5&l __/ | &d&l __/ | \n" + - "&5&l |___/ &d&l|___/ " - ); - } - -} diff --git a/platforms/easysql-plugin-bukkit/src/main/java/cc/carm/plugin/easysql/bukkit/EasySQLBukkit.java b/platforms/easysql-plugin-bukkit/src/main/java/cc/carm/plugin/easysql/bukkit/EasySQLBukkit.java new file mode 100644 index 0000000..2aade2b --- /dev/null +++ b/platforms/easysql-plugin-bukkit/src/main/java/cc/carm/plugin/easysql/bukkit/EasySQLBukkit.java @@ -0,0 +1,78 @@ +package cc.carm.plugin.easysql.bukkit; + +import cc.carm.lib.easyplugin.EasyPlugin; +import cc.carm.lib.easyplugin.i18n.EasyPluginMessageProvider; +import cc.carm.plugin.easysql.EasySQLPluginPlatform; +import cc.carm.plugin.easysql.EasySQLRegistryImpl; +import cc.carm.plugin.easysql.api.DBConfiguration; +import cc.carm.plugin.easysql.util.PropertiesUtil; +import cc.carm.plugin.easysql.util.ResourceReadUtil; +import co.aikar.commands.PaperCommandManager; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Properties; + +public class EasySQLBukkit extends EasyPlugin implements EasySQLPluginPlatform { + + public EasySQLBukkit() { + super(new EasyPluginMessageProvider.zh_CN()); + } + + protected static EasySQLBukkit instance; + + protected PaperCommandManager commandManager; + protected EasySQLRegistryImpl registry; + + @Override + protected void load() { + EasySQLBukkit.instance = this; + this.commandManager = new PaperCommandManager(this); + + + initializeAPI(getRegistry()); + } + + @Override + protected boolean initialize() { + //TODO COMMANDS + return true; + } + + @Override + @NotNull + public EasySQLRegistryImpl getRegistry() { + return this.registry; + } + + @Override + public @NotNull + Map readConfigurations() { + return new HashMap<>(); + } + + @Override + public @NotNull + Map readProperties() { + return PropertiesUtil.readDBProperties(new File(getDataFolder(), "properties")); + } + + @Override + public void outputInfo() { + Optional.ofNullable(ResourceReadUtil.readResource(this.getResource("info.txt"))).ifPresent(this::log); + } + + public static EasySQLBukkit getInstance() { + return EasySQLBukkit.instance; + } + + + protected PaperCommandManager getCommandManager() { + return commandManager; + } + + +} diff --git a/platforms/easysql-plugin-bukkit/src/main/resources/plugin.yml b/platforms/easysql-plugin-bukkit/src/main/resources/plugin.yml index e69de29..beb009b 100644 --- a/platforms/easysql-plugin-bukkit/src/main/resources/plugin.yml +++ b/platforms/easysql-plugin-bukkit/src/main/resources/plugin.yml @@ -0,0 +1,21 @@ +main: cc.carm.plugin.easysql.bukkit.EasySQLBukkit +version: ${project.version} +name: EasySQL-Plugin-Bukkit +load: STARTUP + +website: ${project.url} +description: ${project.description} +authors: + - CarmJos + - GhostChu + +api-version: 1.13 + +prefix: EasySQL + +commands: + "EasySQLBukkit": + usage: "/EasySQLBukkit help" + description: "EasySQL独立插件的主指令,只允许后台运行。" + aliases: + - "EasySQL" \ No newline at end of file diff --git a/platforms/easysql-plugin-bungee/pom.xml b/platforms/easysql-plugin-bungee/pom.xml index 54635d7..e0eedb9 100644 --- a/platforms/easysql-plugin-bungee/pom.xml +++ b/platforms/easysql-plugin-bungee/pom.xml @@ -26,10 +26,12 @@ + bungeecord-repo https://oss.sonatype.org/content/repositories/snapshots + @@ -60,7 +62,16 @@ org.bstats bstats-bungeecord - 2.2.1 + 3.0.0 + true + compile + + + + co.aikar + acf-bungee + 0.5.1-SNAPSHOT + true compile @@ -110,6 +121,24 @@ + + + org.bstats + cc.carm.plugin.easysql.lib.bstats + + + org.json + cc.carm.plugin.easysql.lib.json + + + co.aikar.commands + cc.carm.plugin.easysql.lib.acf + + + co.aikar.locales + cc.carm.plugin.easysql.lib.locales + + diff --git a/platforms/easysql-plugin-bungee/src/main/java/cc/carm/plugin/easysql/EasySQLBungee.java b/platforms/easysql-plugin-bungee/src/main/java/cc/carm/plugin/easysql/EasySQLBungee.java index 52e0591..44e5faa 100644 --- a/platforms/easysql-plugin-bungee/src/main/java/cc/carm/plugin/easysql/EasySQLBungee.java +++ b/platforms/easysql-plugin-bungee/src/main/java/cc/carm/plugin/easysql/EasySQLBungee.java @@ -1,6 +1,7 @@ package cc.carm.plugin.easysql; import cc.carm.plugin.easysql.api.DBConfiguration; +import cc.carm.plugin.easysql.api.EasySQLRegistry; import cc.carm.plugin.easysql.util.PropertiesUtil; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.config.Configuration; @@ -68,6 +69,11 @@ public class EasySQLBungee extends Plugin implements EasySQLPluginPlatform { getLogger().info("Shutting down..."); } + @Override + public @NotNull EasySQLRegistry getRegistry() { + return null; + } + @Override public @NotNull Map readConfigurations() { return new HashMap<>(); diff --git a/platforms/easysql-plugin-sponge/pom.xml b/platforms/easysql-plugin-sponge/pom.xml new file mode 100644 index 0000000..ed9862f --- /dev/null +++ b/platforms/easysql-plugin-sponge/pom.xml @@ -0,0 +1,20 @@ + + + + easysql-plugin + cc.carm.plugin + 0.0.2 + ../../pom.xml + + 4.0.0 + + easysql-plugin-sponge + + + 17 + 17 + + + \ No newline at end of file diff --git a/platforms/easysql-plugin-velocity/pom.xml b/platforms/easysql-plugin-velocity/pom.xml index b157297..9047123 100644 --- a/platforms/easysql-plugin-velocity/pom.xml +++ b/platforms/easysql-plugin-velocity/pom.xml @@ -52,10 +52,21 @@ org.bstats bstats-velocity - 2.2.1 + 3.0.0 + true compile + + + co.aikar + acf-velocity + 0.5.1-SNAPSHOT + true + compile + + + diff --git a/pom.xml b/pom.xml index ff65acf..2454671 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,7 @@ platforms/easysql-plugin-bukkit platforms/easysql-plugin-bungee platforms/easysql-plugin-velocity + platforms/easysql-plugin-sponge EasySQL-Plugin @@ -88,6 +89,11 @@ https://repo.carm.cc/repository/maven-public/ + + aikar + https://repo.aikar.co/content/groups/aikar/ + + central https://repo1.maven.org/maven2/ @@ -148,12 +154,6 @@ ${easysql.version} - - cc.carm.lib - easyplugin-main - ${easyplugin.version} - - com.google.guava