perf: 清理无效代码

This commit is contained in:
2024-03-13 20:51:48 +08:00
parent de7c4decf1
commit ac18e73c5e
8 changed files with 16 additions and 115 deletions

View File

@@ -5,9 +5,7 @@ dependencies {
// https://mvnrepository.com/artifact/org.yaml/snakeyaml
compileOnly("org.yaml:snakeyaml:1.19")
implementation("net.kyori:adventure-platform-api:4.3.2") {
exclude(group = "org.jetbrains")
}
implementation("net.kyori:adventure-platform-api:4.3.2") { exclude(group = "org.jetbrains") }
implementation("net.kyori:adventure-text-serializer-gson:4.13.1") {
exclude(group = "org.jetbrains")
exclude(group = "com.google.code.gson")

View File

@@ -8,7 +8,7 @@ import com.zaxxer.hikari.HikariDataSource;
import lombok.Getter;
import net.kyori.adventure.platform.AudienceProvider;
import org.jetbrains.annotations.NotNull;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPooled;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -27,7 +27,7 @@ public abstract class CoreAPI {
*/
@Getter
@NotNull
private final JedisPool jedisPool;
private final JedisPooled jedisPool;
/**
* HamsterCore 公用数据库连接池
*/
@@ -49,9 +49,9 @@ public abstract class CoreAPI {
executorService = Executors.newCachedThreadPool(new NamedThreadFactory("HamsterCore - Executor"));
scheduledService = Executors.newScheduledThreadPool(1, new NamedThreadFactory("HamsterCore - Scheduler"));
getLogger().info("正在创建 redis 客户端");
jedisPool = new JedisPool(config.getString("redis-url"));
getLogger().info("redis 客户端创建完成");
getLogger().info("正在创建 redis 连接池");
jedisPool = new JedisPooled(config.getString("redis-url"));
getLogger().info("redis 连接池创建完成");
ConfigSection datasourceConfig = config.getSection("datasource");
if (datasourceConfig == null) {

View File

@@ -1,7 +1,5 @@
package cn.hamster3.mc.plugin.core.common.util;
import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
@@ -13,34 +11,11 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.time.Duration;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@SuppressWarnings("unused")
public final class CoreUtils {
/**
* @deprecated 使用 {@link CoreAPI#getGson()}
*/
@Deprecated
public static Gson GSON = CoreAPI.getInstance().getGson();
/**
* @deprecated 使用 {@link CoreAPI#getHumanGson()}
*/
@Deprecated
public static Gson GSON_HUMAN = CoreAPI.getInstance().getHumanGson();
/**
* @deprecated 使用 {@link CoreAPI#getExecutorService()}
*/
@Deprecated
public static ExecutorService WORKER_EXECUTOR = CoreAPI.getInstance().getExecutorService();
/**
* @deprecated 使用 {@link CoreAPI#getScheduledService()}
*/
@Deprecated
public static ScheduledExecutorService SCHEDULED_EXECUTOR = CoreAPI.getInstance().getScheduledService();
private CoreUtils() {
}

View File

@@ -1,33 +0,0 @@
package cn.hamster3.mc.plugin.core.common.util;
import lombok.Getter;
import java.io.Serializable;
import java.util.Objects;
@Getter
@Deprecated
@SuppressWarnings("unused")
public class Pair<K, V> implements Serializable {
private final K key;
private final V value;
public Pair(K key, V value) {
this.key = key;
this.value = value;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Pair<?, ?> pair = (Pair<?, ?>) o;
return Objects.equals(key, pair.key) && Objects.equals(value, pair.value);
}
@Override
public int hashCode() {
return Objects.hash(key, value);
}
}