feat: 移除 redission,格式化代码
This commit is contained in:
@@ -38,12 +38,6 @@ dependencies {
|
||||
implementation("com.zaxxer:HikariCP:${hikariVersion}") {
|
||||
exclude(group = "org.slf4j")
|
||||
}
|
||||
val redissionVersion = property("redission_version")
|
||||
implementation("org.redisson:redisson:${redissionVersion}") {
|
||||
exclude(group = "io.netty")
|
||||
exclude(group = "org.yaml")
|
||||
exclude(group = "org.slf4j")
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
@@ -13,9 +13,9 @@ import cn.hamster3.mc.plugin.core.bukkit.page.listener.PageListener;
|
||||
import cn.hamster3.mc.plugin.core.bukkit.util.serializer.ItemStackAdapter;
|
||||
import cn.hamster3.mc.plugin.core.bukkit.util.serializer.PotionEffectAdapter;
|
||||
import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
|
||||
import cn.hamster3.mc.plugin.core.common.util.CoreUtils;
|
||||
import cn.hamster3.mc.plugin.core.common.util.serializer.ComponentTypeAdapter;
|
||||
import cn.hamster3.mc.plugin.core.common.util.serializer.MessageTypeAdapter;
|
||||
import cn.hamster3.mc.plugin.core.common.util.CoreUtils;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -78,12 +78,12 @@ public class HamsterCorePlugin extends JavaPlugin {
|
||||
ParentLoreCommand.INSTANCE.hook();
|
||||
long time = System.currentTimeMillis() - start;
|
||||
logger.info("仓鼠核心启动完成,总计耗时 " + time + " ms.");
|
||||
Bukkit.getScheduler().runTaskLater(this, ()->{
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||
PointAPI.reloadPlayerPointAPIHook();
|
||||
logger.info("已完成 PlayerPoints 挂载.");
|
||||
VaultAPI.reloadVaultHook();
|
||||
logger.info("已完成 VaultAPI 挂载.");
|
||||
},1L);
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,6 +91,8 @@ public class HamsterCorePlugin extends JavaPlugin {
|
||||
Logger logger = getLogger();
|
||||
long start = System.currentTimeMillis();
|
||||
logger.info("仓鼠核心正在关闭...");
|
||||
CoreBukkitAPI.getInstance().getDataSource().close();
|
||||
logger.info("已关闭数据库连接池.");
|
||||
CoreUtils.WORKER_EXECUTOR.shutdownNow();
|
||||
logger.info("已暂停 WORKER_EXECUTOR.");
|
||||
CoreUtils.SCHEDULED_EXECUTOR.shutdownNow();
|
||||
|
@@ -8,20 +8,10 @@ import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.config.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Objects;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class CoreBukkitAPI extends CoreAPI {
|
||||
private final HikariDataSource datasource;
|
||||
private final RedissonClient redissonClient;
|
||||
|
||||
private CoreBukkitAPI() {
|
||||
HamsterCorePlugin plugin = HamsterCorePlugin.getInstance();
|
||||
@@ -48,19 +38,6 @@ public final class CoreBukkitAPI extends CoreAPI {
|
||||
hikariConfig.setValidationTimeout(datasourceConfig.getLong("validation-timeout", 5000));
|
||||
hikariConfig.setPoolName("HamsterCore-Pool");
|
||||
datasource = new HikariDataSource(hikariConfig);
|
||||
|
||||
File file = new File(plugin.getDataFolder(), "redission.yml");
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
Files.copy(
|
||||
Objects.requireNonNull(plugin.getResource("redission.yml")),
|
||||
file.toPath(), StandardCopyOption.REPLACE_EXISTING
|
||||
);
|
||||
}
|
||||
redissonClient = Redisson.create(Config.fromYAML(file));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("redis 连接加载失败!", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static CoreBukkitAPI getInstance() {
|
||||
@@ -83,9 +60,4 @@ public final class CoreBukkitAPI extends CoreAPI {
|
||||
public @NotNull HikariDataSource getDataSource() {
|
||||
return datasource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RedissonClient getRedissonClient() {
|
||||
return redissonClient;
|
||||
}
|
||||
}
|
||||
|
@@ -60,6 +60,10 @@ public abstract class PageableHandler<E> extends FixedPageHandler {
|
||||
return elementButtonName;
|
||||
}
|
||||
|
||||
public void setElementButtonName(String elementButtonName) {
|
||||
this.elementButtonName = elementButtonName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getElementButtonName(@NotNull E element) {
|
||||
return elementButtonName;
|
||||
@@ -218,8 +222,4 @@ public abstract class PageableHandler<E> extends FixedPageHandler {
|
||||
public void setBarrierButtonName(String barrierButtonName) {
|
||||
this.barrierButtonName = barrierButtonName;
|
||||
}
|
||||
|
||||
public void setElementButtonName(String elementButtonName) {
|
||||
this.elementButtonName = elementButtonName;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user