perf: 简化代码
This commit is contained in:
@@ -9,15 +9,12 @@
|
|||||||
redis-url: "redis://localhost:6379/0?clientName=HamsterCore&timeout=5s"
|
redis-url: "redis://localhost:6379/0?clientName=HamsterCore&timeout=5s"
|
||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
# 数据库链接驱动地址
|
# 数据库链接驱动地址,旧版服务端(低于1.13)请使用:com.mysql.jdbc.Driver
|
||||||
# 除非你知道自己在做什么,否则不建议更改该项
|
|
||||||
# 旧版服务端(低于1.13)请使用:com.mysql.jdbc.Driver
|
|
||||||
driver: "com.mysql.cj.jdbc.Driver"
|
driver: "com.mysql.cj.jdbc.Driver"
|
||||||
# 数据库链接填写格式:
|
# MySQL数据库链接填写格式:
|
||||||
# jdbc:mysql://{数据库地址}:{数据库端口}/{使用的库名}?参数
|
# jdbc:mysql://{数据库地址}:{数据库端口}/{使用的库名}?参数
|
||||||
# 除非你知道自己在做什么,否则不建议随意更改参数
|
|
||||||
url: "jdbc:mysql://localhost:3306/Test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
|
url: "jdbc:mysql://localhost:3306/Test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
|
||||||
# 如果你不需要做多端跨服,那么请使用 sqlite 作本地数据库
|
# 如果你不需要做多端跨服,那么请使用 sqlite 作本地数据库 ↓
|
||||||
# driver: "org.sqlite.JDBC"
|
# driver: "org.sqlite.JDBC"
|
||||||
# url: "jdbc:sqlite:./plugins/HamsterCore/database.db"
|
# url: "jdbc:sqlite:./plugins/HamsterCore/database.db"
|
||||||
# 用户名
|
# 用户名
|
||||||
|
@@ -10,11 +10,9 @@ redis-url: "redis://localhost:6379/0?clientName=HamsterCore&timeout=5s"
|
|||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
# 数据库链接驱动地址
|
# 数据库链接驱动地址
|
||||||
# 除非你知道自己在做什么,否则不建议更改该项
|
|
||||||
driver: "com.mysql.cj.jdbc.Driver"
|
driver: "com.mysql.cj.jdbc.Driver"
|
||||||
# 数据库链接填写格式:
|
# MySQL数据库链接填写格式:
|
||||||
# jdbc:mysql://{数据库地址}:{数据库端口}/{使用的库名}?参数
|
# jdbc:mysql://{数据库地址}:{数据库端口}/{使用的库名}?参数
|
||||||
# 除非你知道自己在做什么,否则不建议随意更改参数
|
|
||||||
url: "jdbc:mysql://localhost:3306/Test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
|
url: "jdbc:mysql://localhost:3306/Test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
|
||||||
# 用户名
|
# 用户名
|
||||||
username: "root"
|
username: "root"
|
||||||
|
@@ -12,6 +12,10 @@ dependencies {
|
|||||||
exclude(group = "org.jetbrains")
|
exclude(group = "org.jetbrains")
|
||||||
exclude(group = "com.google.code.gson")
|
exclude(group = "com.google.code.gson")
|
||||||
}
|
}
|
||||||
|
compileOnlyApi("net.kyori:adventure-text-serializer-legacy:4.13.1") {
|
||||||
|
exclude(group = "org.jetbrains")
|
||||||
|
exclude(group = "com.google.code.gson")
|
||||||
|
}
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/redis.clients/jedis
|
// https://mvnrepository.com/artifact/redis.clients/jedis
|
||||||
compileOnlyApi("redis.clients:jedis:5.1.2") {
|
compileOnlyApi("redis.clients:jedis:5.1.2") {
|
||||||
|
@@ -29,7 +29,7 @@ public abstract class CoreAPI {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final JedisPool jedisPool;
|
private final JedisPool jedisPool;
|
||||||
/**
|
/**
|
||||||
* HamsterCore 公用数据库连接池
|
* 公用数据库连接池
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -63,7 +63,7 @@ public abstract class CoreAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 HamsterCore 公用数据库连接池
|
* 获取公用数据库连接池
|
||||||
*
|
*
|
||||||
* @return 公用数据库连接池
|
* @return 公用数据库连接池
|
||||||
*/
|
*/
|
||||||
@@ -73,7 +73,7 @@ public abstract class CoreAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 HamsterCore 公用数据库连接
|
* 获取公用数据库连接
|
||||||
*
|
*
|
||||||
* @return 公用数据库连接
|
* @return 公用数据库连接
|
||||||
* @throws SQLException -
|
* @throws SQLException -
|
||||||
|
@@ -7,7 +7,7 @@ import com.google.gson.JsonElement;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -32,15 +32,12 @@ public final class UpdateCheckUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void checkUpdate(@NotNull String pluginName, @NotNull ConfigSection updateConfig, @NotNull Audience sender) throws IOException {
|
public static void checkUpdate(@NotNull String pluginName, @NotNull ConfigSection updateConfig, @NotNull Audience sender) throws IOException {
|
||||||
String version = updateConfig.getString("version");
|
String version = updateConfig.getString("version", "");
|
||||||
if (version == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String checkType = updateConfig.getString("CHECK_TYPE", "");
|
String checkType = updateConfig.getString("CHECK_TYPE", "");
|
||||||
String baseUrl = updateConfig.getString("GIT_BASE_URL");
|
String baseUrl = updateConfig.getString("GIT_BASE_URL");
|
||||||
String gitRepo = updateConfig.getString("GIT_REPO");
|
String gitRepo = updateConfig.getString("GIT_REPO");
|
||||||
String downloadUrl = updateConfig.getString("DOWNLOAD_URL");
|
String downloadUrl = updateConfig.getString("DOWNLOAD_URL");
|
||||||
if (baseUrl == null || gitRepo == null || downloadUrl == null) {
|
if (baseUrl == null || gitRepo == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String gitToken = updateConfig.getString("GIT_TOKEN");
|
String gitToken = updateConfig.getString("GIT_TOKEN");
|
||||||
@@ -65,8 +62,12 @@ public final class UpdateCheckUtils {
|
|||||||
if (compareVersion(lastRelease, version) <= 0) {
|
if (compareVersion(lastRelease, version) <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(Component.text(String.format("§a插件 §l%s§a 发布了新版本 %s", pluginName, lastRelease)));
|
sender.sendMessage(LegacyComponentSerializer.legacySection().deserialize(
|
||||||
sender.sendMessage(Component.text(String.format("§b下载链接: §n%s", downloadUrl)));
|
String.format("§a插件 §l%s§a 发布了新版本 %s", pluginName, lastRelease)
|
||||||
|
));
|
||||||
|
if (downloadUrl != null) {
|
||||||
|
sender.sendMessage(LegacyComponentSerializer.legacySection().deserialize("§b下载链接: §n" + downloadUrl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int compareVersion(@NotNull String version1, String version2) {
|
public static int compareVersion(@NotNull String version1, String version2) {
|
||||||
|
@@ -71,7 +71,7 @@ public class HamsterCorePlugin {
|
|||||||
slf4jLogger.error("初始化 CoreAPI 出错", e);
|
slf4jLogger.error("初始化 CoreAPI 出错", e);
|
||||||
}
|
}
|
||||||
long time = System.currentTimeMillis() - start;
|
long time = System.currentTimeMillis() - start;
|
||||||
slf4jLogger.info("HamsterCore 初始化完成,总计耗时 " + time + " ms");
|
slf4jLogger.info("仓鼠核心初始化完成,总计耗时 " + time + " ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.FIRST)
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
@@ -120,6 +120,6 @@ public class HamsterCorePlugin {
|
|||||||
CoreAPI.getInstance().getScheduledService().shutdownNow();
|
CoreAPI.getInstance().getScheduledService().shutdownNow();
|
||||||
slf4jLogger.info("已关闭 ScheduledExecutorService 线程池");
|
slf4jLogger.info("已关闭 ScheduledExecutorService 线程池");
|
||||||
long time = System.currentTimeMillis() - start;
|
long time = System.currentTimeMillis() - start;
|
||||||
slf4jLogger.info("HamsterCore 关闭完成,总计耗时 " + time + " ms");
|
slf4jLogger.info("仓鼠核心关闭完成,总计耗时 " + time + " ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -10,16 +10,10 @@ redis-url: "redis://localhost:6379/0?clientName=HamsterCore&timeout=5s"
|
|||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
# 数据库链接驱动地址
|
# 数据库链接驱动地址
|
||||||
# 除非你知道自己在做什么,否则不建议更改该项
|
|
||||||
# 旧版服务端(低于1.13)请使用:com.mysql.jdbc.Driver
|
|
||||||
driver: "com.mysql.cj.jdbc.Driver"
|
driver: "com.mysql.cj.jdbc.Driver"
|
||||||
# 数据库链接填写格式:
|
# MySQL数据库链接填写格式:
|
||||||
# jdbc:mysql://{数据库地址}:{数据库端口}/{使用的库名}?参数
|
# jdbc:mysql://{数据库地址}:{数据库端口}/{使用的库名}?参数
|
||||||
# 除非你知道自己在做什么,否则不建议随意更改参数
|
|
||||||
url: "jdbc:mysql://localhost:3306/Test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
|
url: "jdbc:mysql://localhost:3306/Test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
|
||||||
# 如果你不需要做多端跨服,那么请使用 sqlite 作本地数据库
|
|
||||||
# driver: "org.sqlite.JDBC"
|
|
||||||
# url: "jdbc:sqlite:./plugins/HamsterCore/database.db"
|
|
||||||
# 用户名
|
# 用户名
|
||||||
username: "root"
|
username: "root"
|
||||||
# 密码
|
# 密码
|
||||||
@@ -28,8 +22,8 @@ datasource:
|
|||||||
# 推荐值:1~3
|
# 推荐值:1~3
|
||||||
minimum-idle: 0
|
minimum-idle: 0
|
||||||
# 最大链接数
|
# 最大链接数
|
||||||
# 推荐值:不低于3
|
# 推荐值:不低于5
|
||||||
maximum-pool-size: 3
|
maximum-pool-size: 5
|
||||||
# 保持连接池可用的间隔
|
# 保持连接池可用的间隔
|
||||||
# 除非你的服务器数据库连接经常断开,否则不建议启用该选项
|
# 除非你的服务器数据库连接经常断开,否则不建议启用该选项
|
||||||
# 单位:毫秒
|
# 单位:毫秒
|
||||||
|
Reference in New Issue
Block a user