6 Commits
1.4.0 ... 1.4.3

Author SHA1 Message Date
141e2f62e0 feat: 优化线程池配置并更新依赖版本
All checks were successful
Publish Project / build (push) Successful in 3m17s
- 将 item-nbt-api 从 2.15.1 更新至 2.15.3
- 将 adventure-platform-bukkit 从 4.3.2 更新至 4.4.1
- 将 adventure-text-minimessage 从 4.15.0 更新至 4.25.0
- 升级项目版本号从 1.4.2 至 1.4.3
- 在各模块配置文件中新增线程池大小配置项
- 根据配置动态设置普通任务和定时任务线程池大小
- 默认线程池大小分别为 10 和 5,并支持自定义配置
2025-12-13 22:26:47 +08:00
0b8614fec9 ci: 优化构建脚本 2025-08-23 04:12:30 +08:00
b9be8e4b0b ci: 优化构建脚本 2025-08-23 04:11:29 +08:00
594bdf15b6 fix: 修复插件自动更新时下载 URL 显示错误的问题
All checks were successful
Publish Project / build (push) Successful in 2m45s
2025-07-30 20:41:56 +08:00
d16602a06d build: 在 Velocity 中引入 relocate 后的 netty,防止依赖版本冲突
All checks were successful
Publish Project / build (push) Successful in 5m3s
2025-07-10 20:36:26 +08:00
ad216ef89b feat: 在插件卸载时关闭 AudienceProvider 2025-07-06 05:57:57 +08:00
15 changed files with 63 additions and 27 deletions

View File

@@ -17,12 +17,11 @@ jobs:
java-version: 21
distribution: temurin
cache: gradle
cache-dependency-path: gradle/wrapper/gradle-wrapper.properties
- name: Build Project
env:
ORG_GRADLE_PROJECT_MAVEN_AIRGAME_USERNAME: ${{ secrets.MAVEN_AIRGAME_USERNAME }}
ORG_GRADLE_PROJECT_MAVEN_AIRGAME_PASSWORD: ${{ secrets.MAVEN_AIRGAME_PASSWORD }}
run: chmod +x gradlew && ./gradlew build publish --no-daemon
run: chmod +x gradlew && ./gradlew build publish --console plain --no-daemon
- name: Publish to Release
uses: softprops/action-gh-release@v2
with:

View File

@@ -24,9 +24,9 @@ repositories {
dependencies {
// 对于 Bukkit 插件
compileOnly("cn.hamster3.mc.plugin:core-bukkit:1.4.0")
compileOnly("cn.hamster3.mc.plugin:core-bukkit:1.4.2")
// 对于 BungeeCord 插件
compileOnly("cn.hamster3.mc.plugin:core-bungee:1.4.0")
compileOnly("cn.hamster3.mc.plugin:core-bungee:1.4.2")
}
```
@@ -52,13 +52,13 @@ dependencies {
<dependency>
<groupId>cn.hamster3.mc.plugin</groupId>
<artifactId>core-bukkit</artifactId>
<version>1.4.0</version>
<version>1.4.2</version>
</dependency>
<!--对于 BungeeCord 插件-->
<dependency>
<groupId>cn.hamster3.mc.plugin</groupId>
<artifactId>core-bungee</artifactId>
<version>1.4.0</version>
<version>1.4.2</version>
</dependency>
</dependencies>
</project>

View File

@@ -5,7 +5,7 @@ plugins {
}
group = "cn.hamster3.mc.plugin"
version = "1.4.0"
version = "1.4.3"
description = "叁只仓鼠的 Minecraft 插件开发通用工具包"
subprojects {

View File

@@ -14,14 +14,14 @@ dependencies {
compileOnly("me.clip:placeholderapi:2.11.5") { isTransitive = false }
// https://www.spigotmc.org/resources/nbt-api.7939/
implementation("de.tr7zw:item-nbt-api:2.15.1")
implementation("de.tr7zw:item-nbt-api:2.15.3")
api("net.kyori:adventure-platform-bukkit:4.3.2") {
api("net.kyori:adventure-platform-bukkit:4.4.1") {
exclude(group = "org.jetbrains")
exclude(group = "com.google.code.gson")
exclude(group = "io.netty")
}
api("net.kyori:adventure-text-minimessage:4.15.0") {
api("net.kyori:adventure-text-minimessage:4.25.0") {
exclude(module = "adventure-api")
exclude(group = "org.jetbrains")
exclude(group = "io.netty")
@@ -50,11 +50,7 @@ tasks {
shadowJar {
dependsOn(":core-relocate-lettuce:shadowJar")
val task = project(":core-relocate-lettuce").tasks.shadowJar.get()
from(task.outputs.files.map {
if (it.isDirectory) it else zipTree(
it
)
})
from(task.outputs.files.map { if (it.isDirectory) it else zipTree(it) })
destinationDirectory = rootProject.layout.buildDirectory
relocate("de.tr7zw.changeme.nbtapi", "cn.hamster3.mc.plugin.core.lib.de.tr7zw.nbtapi")
relocate("de.tr7zw.annotations", "cn.hamster3.mc.plugin.core.lib.de.tr7zw.nbtapi.annotations")

View File

@@ -130,6 +130,8 @@ public class HamsterCorePlugin extends JavaPlugin {
@Override
public void onDisable() {
long start = System.currentTimeMillis();
audienceProvider.close();
simpleLogger.info("已关闭 AudienceProvider.");
if (CoreAPI.getInstance().isEnableRedis()) {
CoreAPI.getInstance().getJedisPool().close();
CoreAPI.getInstance().getRedisClient().close();

View File

@@ -4,7 +4,8 @@ import cn.hamster3.mc.plugin.core.bukkit.HamsterCorePlugin;
import cn.hamster3.mc.plugin.core.bukkit.command.ParentCommand;
import cn.hamster3.mc.plugin.core.bukkit.constant.CoreMessage;
import cn.hamster3.mc.plugin.core.bukkit.util.CoreBukkitUtils;
import de.tr7zw.changeme.nbtapi.*;
import de.tr7zw.changeme.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.NBTType;
import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBT;
import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBTCompoundList;
import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBTList;

View File

@@ -1,3 +1,11 @@
# 普通任务执行线程池大小
# 建议设置为玩家数 / 5但不小于 10
executor-thread-pool-size: 10
# 定时任务执行线程池大小
# 建议设置为玩家数 / 10但不小于 5
scheduler-thread-pool-size: 5
# 是否启用 redis 连接池功能
enable-redis: false

View File

@@ -42,11 +42,7 @@ tasks {
shadowJar {
dependsOn(":core-relocate-lettuce:shadowJar")
val task = project(":core-relocate-lettuce").tasks.shadowJar.get()
from(task.outputs.files.map {
if (it.isDirectory) it else zipTree(
it
)
})
from(task.outputs.files.map { if (it.isDirectory) it else zipTree(it) })
destinationDirectory = rootProject.layout.buildDirectory
}
}

View File

@@ -70,6 +70,8 @@ public class HamsterCorePlugin extends Plugin {
@Override
public void onDisable() {
long start = System.currentTimeMillis();
audienceProvider.close();
simpleLogger.info("已关闭 AudienceProvider.");
if (CoreAPI.getInstance().isEnableRedis()) {
CoreAPI.getInstance().getJedisPool().close();
CoreAPI.getInstance().getRedisClient().close();

View File

@@ -1,3 +1,11 @@
# 普通任务执行线程池大小
# 建议设置为玩家数 / 5但不小于 10
executor-thread-pool-size: 10
# 定时任务执行线程池大小
# 建议设置为玩家数 / 10但不小于 5
scheduler-thread-pool-size: 5
# 是否启用 redis 连接池功能
enable-redis: false

View File

@@ -57,8 +57,14 @@ public abstract class CoreAPI {
public CoreAPI(@NotNull ConfigSection config) {
SimpleLogger logger = getLogger();
executorService = Executors.newCachedThreadPool(new NamedThreadFactory("HamsterCore - Executor"));
scheduledService = Executors.newScheduledThreadPool(1, new NamedThreadFactory("HamsterCore - Scheduler"));
executorService = Executors.newFixedThreadPool(
config.getInt("executor-thread-pool-size", 10),
new NamedThreadFactory("HamsterCore - Executor")
);
scheduledService = Executors.newScheduledThreadPool(
config.getInt("scheduler-thread-pool-size", 5),
new NamedThreadFactory("HamsterCore - Scheduler")
);
logger.info("已创建线程池");
enableRedis = config.getBoolean("enable-redis", true);

View File

@@ -47,7 +47,7 @@ public final class UpdateCheckUtils {
case "GITEA_RELEASES": {
lastRelease = getGiteaLastRelease(baseUrl, gitRepo, gitToken);
if (downloadUrl == null) {
downloadUrl = URI.create(baseUrl).resolve(gitRepo).toString();
downloadUrl = URI.create(baseUrl).resolve("/" + gitRepo).toString();
}
break;
}
@@ -58,7 +58,7 @@ public final class UpdateCheckUtils {
}
lastRelease = getGitlabLastRelease(baseUrl, projectID, gitToken);
if (downloadUrl == null) {
downloadUrl = URI.create(baseUrl).resolve(gitRepo).toString();
downloadUrl = URI.create(baseUrl).resolve("/" + gitRepo).toString();
}
break;
}

View File

@@ -1,6 +1,9 @@
@file:Suppress("VulnerableLibrariesLocal")
evaluationDependsOn(":core-common")
evaluationDependsOn(":core-relocate-lettuce")
val shade = configurations.create("shade")
dependencies {
api(project(":core-common")) { isTransitive = false }
@@ -14,10 +17,11 @@ dependencies {
exclude(group = "com.google.code.gson")
exclude(group = "org.slf4j")
}
api("io.lettuce:lettuce-core:6.7.1.RELEASE") {
exclude(group = "io.netty")
compileOnlyApi("io.lettuce:lettuce-core:6.7.1.RELEASE") {
exclude(group = "org.slf4j")
exclude(group = "io.netty")
}
shade(project(":core-relocate-lettuce"))
// https://mvnrepository.com/artifact/com.mysql/mysql-connector-j
runtimeOnly("com.mysql:mysql-connector-j:8.4.0")
@@ -50,6 +54,9 @@ tasks {
archiveBaseName = "HamsterCore-Velocity"
}
shadowJar {
dependsOn(":core-relocate-lettuce:shadowJar")
val task = project(":core-relocate-lettuce").tasks.shadowJar.get()
from(task.outputs.files.map { if (it.isDirectory) it else zipTree(it) })
destinationDirectory = rootProject.layout.buildDirectory
}
}

View File

@@ -4,6 +4,7 @@ import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
import cn.hamster3.mc.plugin.core.common.config.YamlConfig;
import cn.hamster3.mc.plugin.core.common.util.UpdateCheckUtils;
import cn.hamster3.mc.plugin.core.velocity.api.CoreVelocityAPI;
import cn.hamster3.mc.plugin.core.velocity.impl.AudienceProviderImpl;
import cn.hamster3.mc.plugin.core.velocity.util.VelocitySimpleLogger;
import com.google.inject.Inject;
import com.velocitypowered.api.event.PostOrder;
@@ -83,6 +84,8 @@ public class HamsterCorePlugin {
@Subscribe(order = PostOrder.LAST)
public void onProxyShutdown(ProxyShutdownEvent event) {
long start = System.currentTimeMillis();
AudienceProviderImpl.INSTANCE.close();
simpleLogger.info("已关闭 AudienceProvider.");
if (CoreAPI.getInstance().isEnableRedis()) {
CoreAPI.getInstance().getJedisPool().close();
CoreAPI.getInstance().getRedisClient().close();

View File

@@ -1,3 +1,11 @@
# 普通任务执行线程池大小
# 建议设置为玩家数 / 5但不小于 10
executor-thread-pool-size: 10
# 定时任务执行线程池大小
# 建议设置为玩家数 / 10但不小于 5
scheduler-thread-pool-size: 5
# 是否启用 redis 连接池功能
enable-redis: false