From c6533916524299089f994e15309ac39e423af9a9 Mon Sep 17 00:00:00 2001 From: CarmJos Date: Wed, 23 Feb 2022 02:46:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8F=92=E4=BB=B6=E6=8C=87?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- .../plugin/easysql/api/EasySQLRegistry.java | 4 +- easysql-plugin-core/pom.xml | 2 +- .../plugin/easysql/EasySQLPluginPlatform.java | 27 +++++++ .../plugin/easysql/EasySQLRegistryImpl.java | 69 +++++++++++++--- .../easysql/command/EasySQLCommand.java | 81 +++++++++++++++++++ .../easysql/command/EasySQLHelpFormatter.java | 67 +++++++++++++++ .../plugin/easysql/util/ResourceReadUtil.java | 35 ++++++++ .../plugin/easysql/util/UpdateCheckUtil.java | 20 +---- .../main/resources/acf-core_zh_CN.properties | 48 +++++++++++ .../resources/acf-minecraft_zh_CN.properties | 39 +++++++++ platforms/easysql-plugin-bukkit/pom.xml | 13 +++ .../easysql/{bukkit => }/EasySQLBukkit.java | 16 ++-- .../src/main/resources/plugin.yml | 14 +--- platforms/easysql-plugin-bungee/pom.xml | 5 ++ platforms/easysql-plugin-sponge/pom.xml | 70 ++++++++++++++++ pom.xml | 24 ++++-- 17 files changed, 478 insertions(+), 62 deletions(-) create mode 100644 easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/command/EasySQLHelpFormatter.java create mode 100644 easysql-plugin-core/src/main/resources/acf-core_zh_CN.properties create mode 100644 easysql-plugin-core/src/main/resources/acf-minecraft_zh_CN.properties rename platforms/easysql-plugin-bukkit/src/main/java/cc/carm/plugin/easysql/{bukkit => }/EasySQLBukkit.java (86%) diff --git a/README.md b/README.md index e33c874..8d28a96 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ 轻松(用)SQL的独立运行库插件,支持多种服务端,适用于MineCraft全版本。 - ## 安装 ## 配置 @@ -23,6 +22,7 @@ ### 依赖方式 ## 指令 + 插件主指令为 `/easysql` ,所有指令只允许后台执行。 ```text @@ -30,10 +30,10 @@ - 查看插件指令帮助。 # version -- 查看插件版本并进行版本更新查询。 +- 查看当前插件版本与核心库(EasySQL)版本。 # list -- 列出当前所有的数据源配置与相关信息。 +- 列出当前所有的数据源管理器与相关信息。 # stats <数据源名称> - 查看指定数据源的统计信息与当前仍未关闭的查询。 diff --git a/easysql-plugin-api/src/main/java/cc/carm/plugin/easysql/api/EasySQLRegistry.java b/easysql-plugin-api/src/main/java/cc/carm/plugin/easysql/api/EasySQLRegistry.java index 6a8e9bc..5abc78d 100644 --- a/easysql-plugin-api/src/main/java/cc/carm/plugin/easysql/api/EasySQLRegistry.java +++ b/easysql-plugin-api/src/main/java/cc/carm/plugin/easysql/api/EasySQLRegistry.java @@ -32,7 +32,7 @@ public interface EasySQLRegistry { * @param name 要获取的 SQLManager 实例名称, 如果为 null 则获取首个实例 * @return {@link SQLManager} 实例 */ - @NotNull Optional<@Nullable SQLManager> getOptional(@Nullable String name); + @NotNull Optional getOptional(@Nullable String name); /** * 获取某命名空间下所有 SQLManager 实例 @@ -40,7 +40,7 @@ public interface EasySQLRegistry { * @return {@link SQLManager} 实例集合 */ @Unmodifiable - @NotNull Map list(); + @NotNull Map list(); /** * 创建并注册一个新的 SQLManager 实例 diff --git a/easysql-plugin-core/pom.xml b/easysql-plugin-core/pom.xml index 2617ed5..90021bf 100644 --- a/easysql-plugin-core/pom.xml +++ b/easysql-plugin-core/pom.xml @@ -76,7 +76,7 @@ com.google.guava guava - compile + provided 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 34c9587..6249e2f 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,7 +1,14 @@ package cc.carm.plugin.easysql; +import cc.carm.lib.easysql.api.SQLManager; import cc.carm.plugin.easysql.api.DBConfiguration; import cc.carm.plugin.easysql.api.EasySQLRegistry; +import cc.carm.plugin.easysql.command.EasySQLCommand; +import cc.carm.plugin.easysql.command.EasySQLHelpFormatter; +import co.aikar.commands.CommandManager; +import co.aikar.commands.InvalidCommandArgument; +import co.aikar.commands.Locales; +import com.google.common.collect.ImmutableList; import org.jetbrains.annotations.NotNull; import java.util.Map; @@ -22,4 +29,24 @@ public interface EasySQLPluginPlatform { EasySQLAPI.initializeAPI(registry); } + @SuppressWarnings("deprecation") + default void initializeCommands(CommandManager commandManager) { + commandManager.enableUnstableAPI("help"); + commandManager.setHelpFormatter(new EasySQLHelpFormatter(commandManager)); + commandManager.getLocales().setDefaultLocale(Locales.SIMPLIFIED_CHINESE); + commandManager.getCommandContexts().registerContext(SQLManager.class, c -> { + String name = c.popFirstArg(); + try { + return getRegistry().get(name); + } catch (NullPointerException exception) { + throw new InvalidCommandArgument("不存在名为 " + name + " 的数据库管理器。"); + } + }); + commandManager.getCommandCompletions().registerCompletion("sql-managers", c -> { + if (c.getIssuer().isPlayer()) return ImmutableList.of(); + else return ImmutableList.copyOf(getRegistry().list().keySet()); + }); + commandManager.registerCommand(new EasySQLCommand()); + } + } diff --git a/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/EasySQLRegistryImpl.java b/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/EasySQLRegistryImpl.java index 5feab18..b1aa322 100644 --- a/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/EasySQLRegistryImpl.java +++ b/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/EasySQLRegistryImpl.java @@ -3,6 +3,7 @@ package cc.carm.plugin.easysql; import cc.carm.lib.easysql.api.SQLManager; import cc.carm.lib.easysql.api.SQLQuery; import cc.carm.lib.easysql.manager.SQLManagerImpl; +import cc.carm.lib.githubreleases4j.GithubReleases4J; import cc.carm.plugin.easysql.api.DBConfiguration; import cc.carm.plugin.easysql.api.EasySQLRegistry; import cn.beecp.BeeDataSource; @@ -13,13 +14,29 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.function.Consumer; +import java.util.logging.Logger; public class EasySQLRegistryImpl implements EasySQLRegistry { + public static final String REPO_OWNER = "CarmJos"; + public static final String REPO_NAME = "EasySQL-Plugin"; - private final HashMap sqlManagerRegistry = new HashMap<>(); + private static EasySQLRegistryImpl instance; - public EasySQLRegistryImpl(@NotNull EasySQLPluginPlatform platform) { + protected ExecutorService executorPool; + protected EasySQLPluginPlatform platform; + private final HashMap sqlManagerRegistry = new HashMap<>(); + + protected EasySQLRegistryImpl(@NotNull EasySQLPluginPlatform platform) { + this.platform = platform; + EasySQLRegistryImpl.instance = this; + this.executorPool = Executors.newFixedThreadPool(2, (r) -> { + Thread thread = new Thread(r, "EasySQLRegistry"); + thread.setDaemon(true); + return thread; + }); Map configurations = platform.readConfigurations(); if (configurations.isEmpty()) { @@ -29,7 +46,7 @@ public class EasySQLRegistryImpl implements EasySQLRegistry { configurations.forEach((id, configuration) -> { try { - SQLManager sqlManager = create(id, configuration); + SQLManagerImpl sqlManager = create(id, configuration); this.sqlManagerRegistry.put(id, sqlManager); } catch (Exception exception) { platform.getLogger().warning("初始化SQLManager(#" + id + ") 出错,请检查配置文件."); @@ -40,7 +57,7 @@ public class EasySQLRegistryImpl implements EasySQLRegistry { } @Override - public @NotNull SQLManager get(@Nullable String id) throws NullPointerException { + public @NotNull SQLManagerImpl get(@Nullable String id) throws NullPointerException { if (!this.sqlManagerRegistry.containsKey(id)) { throw new NullPointerException("并不存在ID为 #" + id + " 的SQLManager."); } @@ -48,7 +65,7 @@ public class EasySQLRegistryImpl implements EasySQLRegistry { } @Override - public @NotNull Optional<@Nullable SQLManager> getOptional(@Nullable String name) { + public @NotNull Optional<@Nullable SQLManagerImpl> getOptional(@Nullable String name) { try { return Optional.of(get(name)); } catch (Exception exception) { @@ -58,13 +75,12 @@ public class EasySQLRegistryImpl implements EasySQLRegistry { @Override @Unmodifiable - public @NotNull Map list() { + public @NotNull Map list() { return ImmutableMap.copyOf(this.sqlManagerRegistry); } - @Override - public @NotNull SQLManager create(@Nullable String name, @NotNull DBConfiguration configuration) { + public @NotNull SQLManagerImpl create(@Nullable String name, @NotNull DBConfiguration configuration) { BeeDataSourceConfig config = new BeeDataSourceConfig(); config.setDriverClassName(configuration.getDriverClassName()); config.setJdbcUrl(configuration.getUrlPrefix() + configuration.getUrl()); @@ -91,16 +107,16 @@ public class EasySQLRegistryImpl implements EasySQLRegistry { } @Override - public @NotNull SQLManager create(@Nullable String name, @NotNull Properties properties) { + public @NotNull SQLManagerImpl create(@Nullable String name, @NotNull Properties properties) { return create(name, new BeeDataSourceConfig(properties)); } @Override - public @NotNull SQLManager create(@Nullable String name, @NotNull String propertyFileName) { + public @NotNull SQLManagerImpl create(@Nullable String name, @NotNull String propertyFileName) { return create(name, new BeeDataSourceConfig(propertyFileName)); } - public @NotNull SQLManager create(@Nullable String name, @NotNull BeeDataSourceConfig configuration) { + public @NotNull SQLManagerImpl create(@Nullable String name, @NotNull BeeDataSourceConfig configuration) { return new SQLManagerImpl(new BeeDataSource(configuration), name); } @@ -114,4 +130,35 @@ public class EasySQLRegistryImpl implements EasySQLRegistry { } } + public ExecutorService getExecutor() { + return executorPool; + } + + public static EasySQLRegistryImpl getInstance() { + return instance; + } + + public EasySQLPluginPlatform getPlatform() { + return platform; + } + + public void checkUpdate(String currentVersion) { + Logger logger = getInstance().getPlatform().getLogger(); + getExecutor().execute(() -> { + Integer behindVersions = GithubReleases4J.getVersionBehind(REPO_OWNER, REPO_NAME, currentVersion); + String downloadURL = GithubReleases4J.getReleasesURL(REPO_OWNER, REPO_NAME); + if (behindVersions == null) { + logger.severe("检查更新失败,请您定期查看插件是否更新,避免安全问题。"); + logger.severe("下载地址 " + downloadURL); + } else if (behindVersions < 0) { + logger.severe("检查更新失败! 当前版本未知,请您使用原生版本以避免安全问题。"); + logger.severe("最新版下载地址 " + downloadURL); + } else if (behindVersions > 0) { + logger.warning("发现新版本! 目前已落后 " + behindVersions + " 个版本。"); + logger.warning("最新版下载地址 " + downloadURL); + } else { + logger.info("检查完成,当前已是最新版本。"); + } + }); + } } 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 index 399b286..1b287ca 100644 --- 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 @@ -1,11 +1,92 @@ package cc.carm.plugin.easysql.command; +import cc.carm.lib.easysql.api.SQLManager; +import cc.carm.lib.easysql.api.SQLQuery; +import cc.carm.plugin.easysql.EasySQLRegistryImpl; import co.aikar.commands.BaseCommand; +import co.aikar.commands.CommandHelp; +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.annotation.*; + +import java.util.Map; +import java.util.UUID; + +import static cc.carm.plugin.easysql.util.ResourceReadUtil.getVersion; +@SuppressWarnings("unused") +@CommandAlias("EasySQL") +@Description("EasySQL-Plugin的主指令,用于开发者进行调试,只允许后台执行。") public class EasySQLCommand extends BaseCommand { + @HelpCommand + @Syntax("&9[页码或子指令名称]") + @Description("查看指定数据源的统计信息与当前仍未关闭的查询。") + public void help(CommandIssuer issuer, CommandHelp help) { + if (issuer.isPlayer()) { + issuer.sendMessage("只有后台执行才能使用此命令。"); + return; + } + help.showHelp(); + } + @Subcommand("list") + @Description("列出当前所有的数据源管理器与相关信息。") + public void list(CommandIssuer issuer) { + if (issuer.isPlayer()) { + issuer.sendMessage("只有后台执行才能使用此命令。"); + return; + } + Map runningManagers = EasySQLRegistryImpl.getInstance().list(); + if (runningManagers.isEmpty()) { + issuer.sendMessage("当前无正在运行的数据库管理器。"); + } else { + issuer.sendMessage("当前有 " + runningManagers.size() + " 个正在运行的数据库管理器:"); + runningManagers.forEach( + (name, manager) -> issuer.sendMessage("- " + name + " (" + manager.getActiveQuery().size() + " running)") + ); + } + } + + @Subcommand("version") + @Description("查看当前插件版本与核心库(EasySQL)版本。") + public void version(CommandIssuer issuer) { + if (issuer.isPlayer()) { + issuer.sendMessage("只有后台执行才能使用此命令。"); + return; + } + String pluginVersion = getVersion(this, "cc.carm.plugin", "easysql-plugin-core"); + String apiVersion = getVersion(this, "cc.carm.lib", "easysql-api"); + if (pluginVersion == null || apiVersion == null) { + issuer.sendMessage("无法获取当前版本信息,请保证使用原生版本以避免安全问题。"); + return; + } + issuer.sendMessage("当前插件版本为 " + pluginVersion + "。 (核心接口版本 " + apiVersion + ")"); + issuer.sendMessage("正在检查更新,请稍候..."); + EasySQLRegistryImpl.getInstance().checkUpdate(pluginVersion); + } + + @Subcommand("info") + @CommandCompletion("@sql-managers") + @Syntax("&9<数据源管理器名称>") + @Description("查看指定数据源的统计信息与当前仍未关闭的查询。") + public void info(CommandIssuer issuer, + @Syntax("数据源管理器名称,一般在配置文件中指定。") SQLManager manager) { + if (issuer.isPlayer()) { + issuer.sendMessage("只有后台执行才能使用此命令。"); + return; + } + Map activeQueries = manager.getActiveQuery(); + if (activeQueries.isEmpty()) { + issuer.sendMessage("当前暂无活跃查询。"); + } else { + issuer.sendMessage("当前有 " + activeQueries.size() + " 个活跃查询:"); + activeQueries.forEach((uuid, query) -> { + issuer.sendMessage("# " + uuid.toString()); + issuer.sendMessage("- " + query.getSQLContent()); + }); + } + } } diff --git a/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/command/EasySQLHelpFormatter.java b/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/command/EasySQLHelpFormatter.java new file mode 100644 index 0000000..e8a459e --- /dev/null +++ b/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/command/EasySQLHelpFormatter.java @@ -0,0 +1,67 @@ +package cc.carm.plugin.easysql.command; + +import co.aikar.commands.*; + +public class EasySQLHelpFormatter extends CommandHelpFormatter { + + public EasySQLHelpFormatter(CommandManager manager) { + super(manager); + } + + @Override + public void printHelpHeader(CommandHelp help, CommandIssuer issuer) { + issuer.sendMessage("§3§lEasySQL-Plugin §7指令帮助"); + } + + @Override + public void printHelpCommand(CommandHelp help, CommandIssuer issuer, HelpEntry entry) { + issuer.sendMessage("§8# §f" + entry.getCommand() + " §r" + entry.getParameterSyntax()); + if (!entry.getDescription().isEmpty()) { + issuer.sendMessage("§8- §7" + entry.getDescription()); + } + } + + @Override + public void printHelpFooter(CommandHelp help, CommandIssuer issuer) { + } + + @Override + public void printSearchHeader(CommandHelp help, CommandIssuer issuer) { + issuer.sendMessage("§3§lEasySQL-Plugin §7指令帮助查询"); + } + + @Override + public void printSearchEntry(CommandHelp help, CommandIssuer issuer, HelpEntry entry) { + printHelpCommand(help, issuer, entry); + } + + @Override + public void printSearchFooter(CommandHelp help, CommandIssuer issuer) { + } + + @Override + public void printDetailedHelpHeader(CommandHelp help, CommandIssuer issuer, HelpEntry entry) { + issuer.sendMessage("§3§lEasySQL-Plugin §7指令帮助 §8(§f" + entry.getCommand() + "§8)"); + } + + @Override + public void printDetailedHelpCommand(CommandHelp help, CommandIssuer issuer, HelpEntry entry) { + printHelpCommand(help, issuer, entry); + } + + @Override + public void printDetailedParameter(CommandHelp help, CommandIssuer issuer, HelpEntry entry, CommandParameter param) { + if (param.getDescription() != null) { + if (param.getSyntax() != null) { + issuer.sendMessage("§8@§r" + param.getSyntax() + "§7 §f" + param.getDescription()); + } else { + issuer.sendMessage("§8@§f" + param.getName() + "§7 §f" + param.getDescription()); + } + } + } + + @Override + public void printDetailedHelpFooter(CommandHelp help, CommandIssuer issuer, HelpEntry entry) { + } + +} 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 index b2a37f3..04afa66 100644 --- 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 @@ -1,10 +1,12 @@ package cc.carm.plugin.easysql.util; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import java.util.Properties; import java.util.Scanner; public class ResourceReadUtil { @@ -23,5 +25,38 @@ public class ResourceReadUtil { } } + public static String getMavenPropertiesPath(@NotNull String groupID, @NotNull String artifactID) { + return String.format("/META-INF/maven/%s/%s/pom.properties", groupID, artifactID); + } + + public static synchronized @Nullable String getVersion(@NotNull Object provider, + @NotNull String groupID, + @NotNull String artifactID) { + String path = getMavenPropertiesPath(groupID, artifactID); + String version = null; + // Using maven properties to get the version + try (InputStream is = provider.getClass().getResourceAsStream(path)) { + if (is != null) { + Properties p = new Properties(); + p.load(is); + version = p.getProperty("version", ""); + } + } catch (Exception ignored) { + } + + if (version != null) return version; + + // Fine, lets try Java API + Package pkg = provider.getClass().getPackage(); + if (pkg != null) { + version = pkg.getImplementationVersion(); + if (version == null) { + version = pkg.getSpecificationVersion(); + } + } + + return version; + } + } diff --git a/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/util/UpdateCheckUtil.java b/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/util/UpdateCheckUtil.java index 0e27cf1..8e96e48 100644 --- a/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/util/UpdateCheckUtil.java +++ b/easysql-plugin-core/src/main/java/cc/carm/plugin/easysql/util/UpdateCheckUtil.java @@ -6,24 +6,8 @@ import java.util.logging.Logger; public class UpdateCheckUtil { - public static final String REPO_OWNER = "CarmJos"; - public static final String REPO_NAME = "EasySQL-Plugin"; - public void checkUpdate(Logger logger, String currentVersion) { - Integer behindVersions = GithubReleases4J.getVersionBehind(REPO_OWNER, REPO_NAME, currentVersion); - String downloadURL = GithubReleases4J.getReleasesURL(REPO_OWNER, REPO_NAME); - if (behindVersions == null) { - logger.severe("检查更新失败,请您定期查看插件是否更新,避免安全问题。"); - logger.severe("下载地址 " + downloadURL); - } else if (behindVersions < 0) { - logger.severe("检查更新失败! 当前版本未知,请您使用原生版本以避免安全问题。"); - logger.severe("最新版下载地址 " + downloadURL); - } else if (behindVersions > 0) { - logger.warning("发现新版本! 目前已落后 " + behindVersions + " 个版本。"); - logger.warning("最新版下载地址 " + downloadURL); - } else { - logger.info("检查完成,当前已是最新版本。"); - } - } + + } diff --git a/easysql-plugin-core/src/main/resources/acf-core_zh_CN.properties b/easysql-plugin-core/src/main/resources/acf-core_zh_CN.properties new file mode 100644 index 0000000..3e3f88d --- /dev/null +++ b/easysql-plugin-core/src/main/resources/acf-core_zh_CN.properties @@ -0,0 +1,48 @@ +# suppress inspection "UnusedProperty" for whole file +# +# Copyright (c) 2016-2021 Daniel Ennis (Aikar) - MIT License +# +# 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 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. +# +acf-core.permission_denied=很抱歉,你没有执行此命令的权限。 +acf-core.permission_denied_parameter=很抱歉,你没有执行此命令的权限。 +acf-core.error_generic_logged=很抱歉,插件产生了内部错误。问题已输出在游戏日志中。 +acf-core.unknown_command=您输入了未知的指令,输入 /help 获得指令帮助。 +acf-core.invalid_syntax=指令用法:{command} {syntax} +acf-core.error_prefix=在执行指令时出现了一个错误:\n{message} +acf-core.error_performing_command=很抱歉,指令执行中出现了错误。 +acf-core.info_message={message} +acf-core.please_specify_one_of=错误:请输入 {valid} 中的某一个。 +acf-core.must_be_a_number=错误:{num} 必须是数字。 +acf-core.must_be_min_length=错误:至少需要输入 {min} 个字符。 +acf-core.must_be_max_length=错误:最多需要输入 {max} 个字符。 +acf-core.please_specify_at_most=错误:请输入一个不大于 {max} 的值。 +acf-core.please_specify_at_least=错误:请输入一个不小于 {min} 的值。 +acf-core.not_allowed_on_console=错误:控制台不能执行此命令。 +acf-core.could_not_find_player=错误:找不到名叫 {search} 的玩家。 +acf-core.no_command_matched_search=没有找到匹配 {search} 的指令。 +acf-core.help_page_information=- 页面 {page} / {totalpages} (共计 {results} 个结果)。 +acf-core.help_no_results=错误:没有更多的搜索结果。 +acf-core.help_header==== 关于指令 {commandprefix}{command} 的使用说明 === +acf-core.help_format={command} {parameters} {separator} {description} +acf-core.help_detailed_header==== 显示指令 {commandprefix}{command} 的详细使用说明 === +acf-core.help_detailed_command_format={command} {parameters} {separator} {description} +acf-core.help_detailed_parameter_format={syntaxorname}: {description} +acf-core.help_search_header==== 指令 {commandprefix}{command} {search} 的搜索结果 === \ No newline at end of file diff --git a/easysql-plugin-core/src/main/resources/acf-minecraft_zh_CN.properties b/easysql-plugin-core/src/main/resources/acf-minecraft_zh_CN.properties new file mode 100644 index 0000000..1f0c362 --- /dev/null +++ b/easysql-plugin-core/src/main/resources/acf-minecraft_zh_CN.properties @@ -0,0 +1,39 @@ +# suppress inspection "UnusedProperty" for whole file +# +# Copyright (c) 2016-2021 Daniel Ennis (Aikar) - MIT License +# +# 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 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. +# + +acf-minecraft.invalid_world = 错误:该世界不存在。 +acf-minecraft.you_must_be_holding_item = 错误:你的主手上必须持有物品。 +acf-minecraft.player_is_vanished_confirm = \ + 警告:{vanished} 已被隐藏。不要暴露他们的身份!\n\ + 如果你确认这么做,请在他们的名字后面加上 :confirm 。\n\ + 例如:{vanished}:confirm +acf-minecraft.username_too_short = 错误:名字太短,请至少输入三个字符。 +acf-minecraft.is_not_a_valid_name = 错误:{name} 不是一个可以用的名字。 +acf-minecraft.multiple_players_match = 错误:{search} 的搜索结果过多(共计{all}人),请再详细一点。 +acf-minecraft.no_player_found_server = 没有搜索到匹配 {search} 的在线玩家。 +acf-minecraft.no_player_found_offline = 没有搜索到匹配 {search} 的在线/离线玩家。 +acf-minecraft.no_player_found = 没有搜索到匹配 {search} 的玩家。 +acf-minecraft.location_please_specify_world = 错误:请指明世界。例如:world:x,y,z。 +acf-minecraft.location_please_specify_xyz = 错误:请指明坐标x,y和z。例如:world:x,y,z。 +acf-minecraft.location_console_not_relative = 错误:控制台不能使用相对坐标来指明位置。 \ No newline at end of file diff --git a/platforms/easysql-plugin-bukkit/pom.xml b/platforms/easysql-plugin-bukkit/pom.xml index 6ff23f2..3b09e9e 100644 --- a/platforms/easysql-plugin-bukkit/pom.xml +++ b/platforms/easysql-plugin-bukkit/pom.xml @@ -98,6 +98,10 @@ cc.carm.lib.easyplugin cc.carm.plugin.easysql.lib.easyplugin + + cc.carm.lib.githubreleases4j + cc.carm.plugin.easysql.lib.githubreleases4j + co.aikar.commands cc.carm.plugin.easysql.lib.acf @@ -108,6 +112,15 @@ + + co.aikar:* + + META-INF/MANIFEST.MF + META-INF/*.txt + acf-core*.properties + acf-minecraft*.properties + + *:* 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/EasySQLBukkit.java similarity index 86% rename from platforms/easysql-plugin-bukkit/src/main/java/cc/carm/plugin/easysql/bukkit/EasySQLBukkit.java rename to platforms/easysql-plugin-bukkit/src/main/java/cc/carm/plugin/easysql/EasySQLBukkit.java index 2aade2b..4a13961 100644 --- 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/EasySQLBukkit.java @@ -1,9 +1,7 @@ -package cc.carm.plugin.easysql.bukkit; +package cc.carm.plugin.easysql; 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; @@ -24,21 +22,22 @@ public class EasySQLBukkit extends EasyPlugin implements EasySQLPluginPlatform { protected static EasySQLBukkit instance; - protected PaperCommandManager commandManager; - protected EasySQLRegistryImpl registry; + private PaperCommandManager commandManager; + private EasySQLRegistryImpl registry; @Override protected void load() { EasySQLBukkit.instance = this; - this.commandManager = new PaperCommandManager(this); - + this.registry = new EasySQLRegistryImpl(this); initializeAPI(getRegistry()); + } @Override protected boolean initialize() { - //TODO COMMANDS + this.commandManager = new PaperCommandManager(this); + initializeCommands(getCommandManager()); return true; } @@ -69,7 +68,6 @@ public class EasySQLBukkit extends EasyPlugin implements EasySQLPluginPlatform { 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 beb009b..8479bc4 100644 --- a/platforms/easysql-plugin-bukkit/src/main/resources/plugin.yml +++ b/platforms/easysql-plugin-bukkit/src/main/resources/plugin.yml @@ -1,5 +1,6 @@ -main: cc.carm.plugin.easysql.bukkit.EasySQLBukkit +main: cc.carm.plugin.easysql.EasySQLBukkit version: ${project.version} +prefix: EasySQL-Plugin name: EasySQL-Plugin-Bukkit load: STARTUP @@ -9,13 +10,4 @@ authors: - CarmJos - GhostChu -api-version: 1.13 - -prefix: EasySQL - -commands: - "EasySQLBukkit": - usage: "/EasySQLBukkit help" - description: "EasySQL独立插件的主指令,只允许后台运行。" - aliases: - - "EasySQL" \ No newline at end of file +api-version: 1.13 \ No newline at end of file diff --git a/platforms/easysql-plugin-bungee/pom.xml b/platforms/easysql-plugin-bungee/pom.xml index e0eedb9..b6c3f5b 100644 --- a/platforms/easysql-plugin-bungee/pom.xml +++ b/platforms/easysql-plugin-bungee/pom.xml @@ -118,6 +118,7 @@ META-INF/MANIFEST.MF META-INF/*.txt + acf-minecraft*.properties @@ -130,6 +131,10 @@ org.json cc.carm.plugin.easysql.lib.json + + cc.carm.lib.githubreleases4j + cc.carm.plugin.easysql.lib.githubreleases4j + co.aikar.commands cc.carm.plugin.easysql.lib.acf diff --git a/platforms/easysql-plugin-sponge/pom.xml b/platforms/easysql-plugin-sponge/pom.xml index ed9862f..bf475f5 100644 --- a/platforms/easysql-plugin-sponge/pom.xml +++ b/platforms/easysql-plugin-sponge/pom.xml @@ -17,4 +17,74 @@ 17 + + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.3 + + + package + + shade + + + + + ${project.name}-${project.version} + ${project.parent.basedir}/asset/ + false + + + *:* + + META-INF/MANIFEST.MF + META-INF/*.txt + + + + + + org.bstats + cc.carm.plugin.easysql.lib.bstats + + + org.json + cc.carm.plugin.easysql.lib.json + + + cc.carm.lib.githubreleases4j + cc.carm.plugin.easysql.lib.githubreleases4j + + + co.aikar.commands + cc.carm.plugin.easysql.lib.acf + + + co.aikar.locales + cc.carm.plugin.easysql.lib.locales + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2454671..21ec651 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ ${java.version} UTF-8 UTF-8 - 0.3.6 + 0.3.8 1.3.8 4.0.3 @@ -99,12 +99,6 @@ https://repo1.maven.org/maven2/ - - github - GitHub Packages - https://maven.pkg.github.com/CarmJos/* - - @@ -188,6 +182,22 @@ + + org.apache.maven.plugins + maven-clean-plugin + 2.5 + + + + ${project.basedir}/asset/ + true + + **/* + + + + + org.apache.maven.plugins maven-surefire-plugin