refactor: 优化代码
This commit is contained in:
@@ -78,7 +78,7 @@ public class HamsterCorePlugin extends JavaPlugin {
|
||||
logger.info("已关闭数据库连接池.");
|
||||
CoreAPI.getInstance().getExecutorService().shutdownNow();
|
||||
logger.info("已关闭线程池.");
|
||||
CoreAPI.getInstance().getScheduledExecutorService().shutdownNow();
|
||||
CoreAPI.getInstance().getScheduledService().shutdownNow();
|
||||
logger.info("已关闭调度器.");
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
InventoryView view = player.getOpenInventory();
|
||||
|
@@ -5,7 +5,6 @@ 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.api.CoreAPI;
|
||||
import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
|
||||
import cn.hamster3.mc.plugin.core.common.thread.NamedThreadFactory;
|
||||
import cn.hamster3.mc.plugin.core.common.util.serializer.ComponentTypeAdapter;
|
||||
import cn.hamster3.mc.plugin.core.common.util.serializer.MessageTypeAdapter;
|
||||
import com.google.gson.Gson;
|
||||
@@ -20,17 +19,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class CoreBukkitAPI extends CoreAPI {
|
||||
private final Gson gson;
|
||||
private final Gson humanGson;
|
||||
private final HikariDataSource datasource;
|
||||
private final ExecutorService executorService;
|
||||
private final ScheduledExecutorService scheduledExecutorService;
|
||||
|
||||
private CoreBukkitAPI() {
|
||||
HamsterCorePlugin plugin = HamsterCorePlugin.getInstance();
|
||||
@@ -72,9 +65,6 @@ public final class CoreBukkitAPI extends CoreAPI {
|
||||
.serializeNulls()
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
|
||||
executorService = Executors.newCachedThreadPool(new NamedThreadFactory("HamsterCore - Executor"));
|
||||
scheduledExecutorService = Executors.newScheduledThreadPool(1, new NamedThreadFactory("HamsterCore - Scheduler"));
|
||||
}
|
||||
|
||||
public static CoreBukkitAPI getInstance() {
|
||||
@@ -107,14 +97,4 @@ public final class CoreBukkitAPI extends CoreAPI {
|
||||
public @NotNull Gson getHumanGson() {
|
||||
return humanGson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ExecutorService getExecutorService() {
|
||||
return executorService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ScheduledExecutorService getScheduledExecutorService() {
|
||||
return scheduledExecutorService;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user