1
mirror of https://github.com/CarmJos/MineSQL.git synced 2024-09-19 20:25:45 +00:00

完成插件指令

This commit is contained in:
Carm Jos 2022-02-23 02:46:07 +08:00
parent 108442ad43
commit c653391652
17 changed files with 478 additions and 62 deletions

View File

@ -13,7 +13,6 @@
轻松(用)SQL的独立运行库插件支持多种服务端适用于MineCraft全版本。
## 安装
## 配置
@ -23,6 +22,7 @@
### 依赖方式
## 指令
插件主指令为 `/easysql` ,所有指令只允许后台执行。
```text
@ -30,10 +30,10 @@
- 查看插件指令帮助。
# version
- 查看插件版本并进行版本更新查询
- 查看当前插件版本与核心库(EasySQL)版本
# list
- 列出当前所有的数据源配置与相关信息。
- 列出当前所有的数据源管理器与相关信息。
# stats <数据源名称>
- 查看指定数据源的统计信息与当前仍未关闭的查询。

View File

@ -32,7 +32,7 @@ public interface EasySQLRegistry {
* @param name 要获取的 SQLManager 实例名称, 如果为 null 则获取首个实例
* @return {@link SQLManager} 实例
*/
@NotNull Optional<@Nullable SQLManager> getOptional(@Nullable String name);
@NotNull Optional<? extends SQLManager> getOptional(@Nullable String name);
/**
* 获取某命名空间下所有 SQLManager 实例
@ -40,7 +40,7 @@ public interface EasySQLRegistry {
* @return {@link SQLManager} 实例集合
*/
@Unmodifiable
@NotNull Map<String, SQLManager> list();
@NotNull Map<String, ? extends SQLManager> list();
/**
* 创建并注册一个新的 SQLManager 实例

View File

@ -76,7 +76,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -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());
}
}

View File

@ -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<String, SQLManager> sqlManagerRegistry = new HashMap<>();
private static EasySQLRegistryImpl instance;
public EasySQLRegistryImpl(@NotNull EasySQLPluginPlatform platform) {
protected ExecutorService executorPool;
protected EasySQLPluginPlatform platform;
private final HashMap<String, SQLManagerImpl> 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<String, DBConfiguration> 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<String, SQLManager> list() {
public @NotNull Map<String, SQLManagerImpl> 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("检查完成,当前已是最新版本。");
}
});
}
}

View File

@ -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<String, ? extends SQLManager> 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<UUID, SQLQuery> 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());
});
}
}
}

View File

@ -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) {
}
}

View File

@ -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;
}
}

View File

@ -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("检查完成,当前已是最新版本。");
}
}
}

View File

@ -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=您输入了未知的指令,输入 <c2>/help</c2> 获得指令帮助。
acf-core.invalid_syntax=指令用法:<c2>{command}</c2> <c3>{syntax}</c3>
acf-core.error_prefix=在执行指令时出现了一个错误:\n{message}
acf-core.error_performing_command=很抱歉,指令执行中出现了错误。
acf-core.info_message={message}
acf-core.please_specify_one_of=错误:请输入 <c2>{valid}</c2> 中的某一个。
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=错误:找不到名叫 <c2>{search}</c2> 的玩家。
acf-core.no_command_matched_search=没有找到匹配 <c2>{search}</c2> 的指令。
acf-core.help_page_information=- 页面 <c2>{page}</c2> / <c2>{totalpages}</c2> (共计 <c3>{results}</c3> 个结果)。
acf-core.help_no_results=错误:没有更多的搜索结果。
acf-core.help_header=<c3>=== </c3><c1>关于指令 </c1><c2>{commandprefix}{command}</c2><c1> 的使用说明</c1><c3> ===</c3>
acf-core.help_format=<c1>{command}</c1> <c2>{parameters}</c2> <c3>{separator} {description}</c3>
acf-core.help_detailed_header=<c3>=== </c3><c1>显示指令 </c1><c2>{commandprefix}{command}</c2><c1> 的详细使用说明</c1><c3> ===</c3>
acf-core.help_detailed_command_format=<c1>{command}</c1> <c2>{parameters}</c2> <c3>{separator} {description}</c3>
acf-core.help_detailed_parameter_format=<c2>{syntaxorname}</c2>: <c3>{description}</c3>
acf-core.help_search_header=<c3>=== </c3><c1>指令 </c1><c2>{commandprefix}{command} {search}</c2><c1> 的搜索结果</c1><c3> ===</c3>

View File

@ -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 = \
警告:<c2>{vanished}</c2> 已被隐藏。不要暴露他们的身份!\n\
如果你确认这么做,请在他们的名字后面加上 <c2>:confirm</c2> 。\n\
例如:<c2>{vanished}:confirm</c2>
acf-minecraft.username_too_short = 错误:名字太短,请至少输入三个字符。
acf-minecraft.is_not_a_valid_name = 错误:<c2>{name}</c2> 不是一个可以用的名字。
acf-minecraft.multiple_players_match = 错误:<c2>{search}</c2> 的搜索结果过多<c3>(共计{all}人)</c3>,请再详细一点。
acf-minecraft.no_player_found_server = 没有搜索到匹配 <c2>{search}</c2> 的在线玩家。
acf-minecraft.no_player_found_offline = 没有搜索到匹配 <c2>{search}</c2> 的在线/离线玩家。
acf-minecraft.no_player_found = 没有搜索到匹配 <c2>{search}</c2> 的玩家。
acf-minecraft.location_please_specify_world = 错误:请指明世界。例如:<c2>world:x,y,z</c2>。
acf-minecraft.location_please_specify_xyz = 错误请指明坐标xy和z。例如<c2>world:x,y,z</c2>。
acf-minecraft.location_console_not_relative = 错误:控制台不能使用相对坐标来指明位置。

View File

@ -98,6 +98,10 @@
<pattern>cc.carm.lib.easyplugin</pattern>
<shadedPattern>cc.carm.plugin.easysql.lib.easyplugin</shadedPattern>
</relocation>
<relocation>
<pattern>cc.carm.lib.githubreleases4j</pattern>
<shadedPattern>cc.carm.plugin.easysql.lib.githubreleases4j</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>cc.carm.plugin.easysql.lib.acf</shadedPattern> <!-- Replace this -->
@ -108,6 +112,15 @@
</relocation>
</relocations>
<filters>
<filter>
<artifact>co.aikar:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/*.txt</exclude>
<exclude>acf-core*.properties</exclude>
<exclude>acf-minecraft*.properties</exclude>
</excludes>
</filter>
<filter>
<artifact>*:*</artifact>
<excludes>

View File

@ -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;
}

View File

@ -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"
api-version: 1.13

View File

@ -118,6 +118,7 @@
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/*.txt</exclude>
<exclude>acf-minecraft*.properties</exclude>
</excludes>
</filter>
</filters>
@ -130,6 +131,10 @@
<pattern>org.json</pattern>
<shadedPattern>cc.carm.plugin.easysql.lib.json</shadedPattern>
</relocation>
<relocation>
<pattern>cc.carm.lib.githubreleases4j</pattern>
<shadedPattern>cc.carm.plugin.easysql.lib.githubreleases4j</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>cc.carm.plugin.easysql.lib.acf</shadedPattern> <!-- Replace this -->

View File

@ -17,4 +17,74 @@
<maven.compiler.target>17</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<finalName>${project.name}-${project.version}</finalName>
<outputDirectory>${project.parent.basedir}/asset/</outputDirectory>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/*.txt</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>cc.carm.plugin.easysql.lib.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>org.json</pattern>
<shadedPattern>cc.carm.plugin.easysql.lib.json</shadedPattern>
</relocation>
<relocation>
<pattern>cc.carm.lib.githubreleases4j</pattern>
<shadedPattern>cc.carm.plugin.easysql.lib.githubreleases4j</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>cc.carm.plugin.easysql.lib.acf</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>co.aikar.locales</pattern>
<shadedPattern>cc.carm.plugin.easysql.lib.locales</shadedPattern> <!-- Replace this -->
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
</project>

24
pom.xml
View File

@ -10,7 +10,7 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<easysql.version>0.3.6</easysql.version>
<easysql.version>0.3.8</easysql.version>
<easyplugin.version>1.3.8</easyplugin.version>
<hikaricp.version>4.0.3</hikaricp.version>
</properties>
@ -99,12 +99,6 @@
<url>https://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/CarmJos/*</url>
</repository>
</repositories>
<dependencies>
@ -188,6 +182,22 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>${project.basedir}/asset/</directory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>**/*</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>