feat: 将 lettuce 改为 jedis
This commit is contained in:
@@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "cn.hamster3.mc.plugin"
|
group = "cn.hamster3.mc.plugin"
|
||||||
version = "1.2.4"
|
version = "1.3.0"
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
apply {
|
apply {
|
||||||
@@ -48,11 +48,6 @@ subprojects {
|
|||||||
}
|
}
|
||||||
shadowJar {
|
shadowJar {
|
||||||
archiveClassifier = ""
|
archiveClassifier = ""
|
||||||
relocate("io.lettuce", "cn.hamster3.mc.plugin.core.lib.io.lettuce")
|
|
||||||
relocate("io.netty", "cn.hamster3.mc.plugin.core.lib.io.netty")
|
|
||||||
relocate("reactor", "cn.hamster3.mc.plugin.core.lib.reactor")
|
|
||||||
relocate("org.reactivestreams", "cn.hamster3.mc.plugin.core.lib.org.reactivestreams")
|
|
||||||
|
|
||||||
relocate("org.quartz", "cn.hamster3.mc.plugin.core.lib.org.quartz")
|
relocate("org.quartz", "cn.hamster3.mc.plugin.core.lib.org.quartz")
|
||||||
relocate("org.terracotta.quartz", "cn.hamster3.mc.plugin.core.lib.org.terracotta.quartz")
|
relocate("org.terracotta.quartz", "cn.hamster3.mc.plugin.core.lib.org.terracotta.quartz")
|
||||||
relocate("com.zaxxer.hikari", "cn.hamster3.mc.plugin.core.lib.com.zaxxer.hikari")
|
relocate("com.zaxxer.hikari", "cn.hamster3.mc.plugin.core.lib.com.zaxxer.hikari")
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
|
@file:Suppress("VulnerableLibrariesLocal")
|
||||||
|
|
||||||
evaluationDependsOn(":core-common")
|
evaluationDependsOn(":core-common")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":core-common")) {
|
implementation(project(":core-common")) {
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
}
|
}
|
||||||
compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||||
|
|
||||||
implementation("de.tr7zw:item-nbt-api:2.12.3-SNAPSHOT")
|
implementation("de.tr7zw:item-nbt-api:2.12.3-SNAPSHOT")
|
||||||
compileOnly("net.milkbowl.vault:VaultAPI:1.7") {
|
compileOnly("net.milkbowl.vault:VaultAPI:1.7") {
|
||||||
@@ -28,8 +30,11 @@ dependencies {
|
|||||||
implementation("com.zaxxer:HikariCP:4.0.3") {
|
implementation("com.zaxxer:HikariCP:4.0.3") {
|
||||||
exclude(group = "org.slf4j")
|
exclude(group = "org.slf4j")
|
||||||
}
|
}
|
||||||
// https://mvnrepository.com/artifact/io.lettuce/lettuce-core
|
// https://mvnrepository.com/artifact/redis.clients/jedis
|
||||||
implementation("io.lettuce:lettuce-core:6.3.1.RELEASE")
|
implementation("redis.clients:jedis:5.1.2") {
|
||||||
|
exclude(group = "com.google.code.gson")
|
||||||
|
exclude(group = "org.slf4j")
|
||||||
|
}
|
||||||
// https://mvnrepository.com/artifact/org.quartz-scheduler/quartz
|
// https://mvnrepository.com/artifact/org.quartz-scheduler/quartz
|
||||||
implementation("org.quartz-scheduler:quartz:2.3.2") {
|
implementation("org.quartz-scheduler:quartz:2.3.2") {
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
|
@@ -109,7 +109,7 @@ public class HamsterCorePlugin extends JavaPlugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Logger logger = getLogger();
|
Logger logger = getLogger();
|
||||||
CoreAPI.getInstance().getRedisClient().close();
|
CoreAPI.getInstance().getJedisPool().close();
|
||||||
logger.info("已关闭 Redis 连接池");
|
logger.info("已关闭 Redis 连接池");
|
||||||
CoreAPI.getInstance().getHikariDataSource().close();
|
CoreAPI.getInstance().getHikariDataSource().close();
|
||||||
logger.info("已关闭数据库连接池");
|
logger.info("已关闭数据库连接池");
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
# 若没有设置 redis 用户名,也没有设置密码,则可以使用以下格式:
|
# 若没有设置 redis 用户名,也没有设置密码,则可以使用以下格式:
|
||||||
# redis://localhost:6379/0?clientName=HamsterCore
|
# redis://localhost:6379/0?clientName=HamsterCore
|
||||||
# 若不设置数据库,则默认使用 0
|
# 若不设置数据库,则默认使用 0
|
||||||
# 详细信息:https://github.com/lettuce-io/lettuce-core/wiki/Redis-URI-and-connection-details
|
|
||||||
redis-url: "redis://localhost:6379/0?clientName=HamsterCore&timeout=5s"
|
redis-url: "redis://localhost:6379/0?clientName=HamsterCore&timeout=5s"
|
||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
|
@@ -20,8 +20,11 @@ dependencies {
|
|||||||
implementation("com.zaxxer:HikariCP:4.0.3") {
|
implementation("com.zaxxer:HikariCP:4.0.3") {
|
||||||
exclude(group = "org.slf4j")
|
exclude(group = "org.slf4j")
|
||||||
}
|
}
|
||||||
// https://mvnrepository.com/artifact/io.lettuce/lettuce-core
|
// https://mvnrepository.com/artifact/redis.clients/jedis
|
||||||
implementation("io.lettuce:lettuce-core:6.3.1.RELEASE")
|
implementation("redis.clients:jedis:5.1.2") {
|
||||||
|
exclude(group = "com.google.code.gson")
|
||||||
|
exclude(group = "org.slf4j")
|
||||||
|
}
|
||||||
// https://mvnrepository.com/artifact/org.quartz-scheduler/quartz
|
// https://mvnrepository.com/artifact/org.quartz-scheduler/quartz
|
||||||
implementation("org.quartz-scheduler:quartz:2.3.2") {
|
implementation("org.quartz-scheduler:quartz:2.3.2") {
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
|
@@ -62,7 +62,7 @@ public class HamsterCorePlugin extends Plugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Logger logger = getLogger();
|
Logger logger = getLogger();
|
||||||
CoreAPI.getInstance().getRedisClient().close();
|
CoreAPI.getInstance().getJedisPool().close();
|
||||||
logger.info("已关闭 Redis 连接池");
|
logger.info("已关闭 Redis 连接池");
|
||||||
CoreAPI.getInstance().getHikariDataSource().close();
|
CoreAPI.getInstance().getHikariDataSource().close();
|
||||||
logger.info("已关闭数据库连接池");
|
logger.info("已关闭数据库连接池");
|
||||||
|
@@ -5,24 +5,22 @@ dependencies {
|
|||||||
// https://mvnrepository.com/artifact/org.yaml/snakeyaml
|
// https://mvnrepository.com/artifact/org.yaml/snakeyaml
|
||||||
compileOnly("org.yaml:snakeyaml:1.19")
|
compileOnly("org.yaml:snakeyaml:1.19")
|
||||||
|
|
||||||
implementation("net.kyori:adventure-platform-api:4.3.2") {
|
compileOnly("net.kyori:adventure-platform-api:4.3.2") {
|
||||||
exclude(group = "org.jetbrains")
|
exclude(group = "org.jetbrains")
|
||||||
}
|
}
|
||||||
implementation("net.kyori:adventure-text-serializer-gson:4.13.1") {
|
compileOnly("net.kyori:adventure-text-serializer-gson:4.13.1") {
|
||||||
exclude(group = "org.jetbrains")
|
exclude(group = "org.jetbrains")
|
||||||
exclude(group = "com.google.code.gson")
|
exclude(group = "com.google.code.gson")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/com.zaxxer/HikariCP
|
// https://mvnrepository.com/artifact/com.zaxxer/HikariCP
|
||||||
compileOnly("com.zaxxer:HikariCP:5.1.0") { isTransitive = false }
|
compileOnly("com.zaxxer:HikariCP:4.0.3") { isTransitive = false }
|
||||||
// https://mvnrepository.com/artifact/io.lettuce/lettuce-core
|
// https://mvnrepository.com/artifact/redis.clients/jedis
|
||||||
implementation("io.lettuce:lettuce-core:6.3.1.RELEASE") {
|
implementation("redis.clients:jedis:5.1.2") {
|
||||||
exclude(group = "io.netty")
|
exclude(group = "com.google.code.gson")
|
||||||
}
|
exclude(group = "org.slf4j")
|
||||||
implementation("org.quartz-scheduler:quartz:2.3.2") {
|
|
||||||
isTransitive = false
|
|
||||||
}
|
}
|
||||||
|
compileOnly("org.quartz-scheduler:quartz:2.3.2") { isTransitive = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
@@ -5,10 +5,10 @@ import cn.hamster3.mc.plugin.core.common.thread.NamedThreadFactory;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import io.lettuce.core.RedisClient;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.kyori.adventure.platform.AudienceProvider;
|
import net.kyori.adventure.platform.AudienceProvider;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import redis.clients.jedis.JedisPool;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -23,11 +23,11 @@ public abstract class CoreAPI {
|
|||||||
@Getter
|
@Getter
|
||||||
protected static CoreAPI instance;
|
protected static CoreAPI instance;
|
||||||
/**
|
/**
|
||||||
* lettuce redis 客户端
|
* Redis 连接池
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@NotNull
|
@NotNull
|
||||||
private final RedisClient redisClient;
|
private final JedisPool jedisPool;
|
||||||
/**
|
/**
|
||||||
* HamsterCore 公用数据库连接池
|
* HamsterCore 公用数据库连接池
|
||||||
*/
|
*/
|
||||||
@@ -50,7 +50,7 @@ public abstract class CoreAPI {
|
|||||||
scheduledService = Executors.newScheduledThreadPool(1, new NamedThreadFactory("HamsterCore - Scheduler"));
|
scheduledService = Executors.newScheduledThreadPool(1, new NamedThreadFactory("HamsterCore - Scheduler"));
|
||||||
|
|
||||||
getLogger().info("正在创建 redis 客户端");
|
getLogger().info("正在创建 redis 客户端");
|
||||||
redisClient = RedisClient.create(config.getString("redis-url"));
|
jedisPool = new JedisPool(config.getString("redis-url"));
|
||||||
getLogger().info("redis 客户端创建完成");
|
getLogger().info("redis 客户端创建完成");
|
||||||
|
|
||||||
ConfigSection datasourceConfig = config.getSection("datasource");
|
ConfigSection datasourceConfig = config.getSection("datasource");
|
||||||
|
Reference in New Issue
Block a user