This commit is contained in:
cuftica 2023-07-26 22:33:41 +02:00
parent 4eff81f493
commit 21d4f6a536
2 changed files with 7 additions and 3 deletions

View File

@ -134,7 +134,7 @@ public class PsHubCore extends JavaPlugin {
spiGui = new SpiGUI(this);
// Initialize ServerCache
serverCache = new ServerCache(serversController, getConfig());
serverCache = new ServerCache(serversController, getConfig(), this);
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", serverCache);

View File

@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import os.arcadiadevs.playerservers.hubcore.PsHubCore;
import os.arcadiadevs.playerservers.hubcore.controllers.ServersController;
import os.arcadiadevs.playerservers.hubcore.dto.ServerRecord;
import os.arcadiadevs.playerservers.hubcore.utils.BungeeUtil;
@ -27,10 +28,13 @@ public class ServerCache extends BukkitRunnable implements PluginMessageListener
private final ServersController serversController;
public ServerCache(ServersController serversController, FileConfiguration config) {
private final PsHubCore instance;
public ServerCache(ServersController serversController, FileConfiguration config, PsHubCore instance) {
this.serversController = serversController;
this.servers = new ArrayList<>();
this.config = config;
this.instance = instance;
}
/**
@ -39,7 +43,7 @@ public class ServerCache extends BukkitRunnable implements PluginMessageListener
@SneakyThrows
@Override
public void run() {
while (!this.isCancelled()) {
while (instance.isEnabled()) {
Player player = Bukkit.getOnlinePlayers().stream().findAny().orElse(null);
if (player == null) {