diff --git a/simplecloud-modules/simplecloud-module-chat-tab/src/main/resources/plugin.yml b/simplecloud-modules/simplecloud-module-chat-tab/src/main/resources/plugin.yml index 81e8fa542..5e298d602 100644 --- a/simplecloud-modules/simplecloud-module-chat-tab/src/main/resources/plugin.yml +++ b/simplecloud-modules/simplecloud-module-chat-tab/src/main/resources/plugin.yml @@ -1,6 +1,7 @@ name: SimpleCloud-Chat-Tab version: 1.0 author: Fllip +folia-supported: true main: eu.thesimplecloud.module.prefix.service.spigot.BukkitPluginMain diff --git a/simplecloud-modules/simplecloud-module-permission/src/main/resources/plugin.yml b/simplecloud-modules/simplecloud-module-permission/src/main/resources/plugin.yml index d9c9d9d85..9a7dd429c 100644 --- a/simplecloud-modules/simplecloud-module-permission/src/main/resources/plugin.yml +++ b/simplecloud-modules/simplecloud-module-permission/src/main/resources/plugin.yml @@ -1,6 +1,7 @@ name: SimpleCloud-Permission version: 1.0 author: Wetterbericht +folia-supported: true main: eu.thesimplecloud.module.permission.service.spigot.SpigotPluginMain diff --git a/simplecloud-modules/simplecloud-module-proxy/src/main/resources/plugin.yml b/simplecloud-modules/simplecloud-module-proxy/src/main/resources/plugin.yml index 773428e08..995ecf5c0 100644 --- a/simplecloud-modules/simplecloud-module-proxy/src/main/resources/plugin.yml +++ b/simplecloud-modules/simplecloud-module-proxy/src/main/resources/plugin.yml @@ -1,6 +1,7 @@ name: SimpleCloud-Proxy version: 1.0 author: Fllip +folia-supported: true main: eu.thesimplecloud.module.proxy.service.bungee.BungeePluginMain diff --git a/simplecloud-modules/simplecloud-module-sign/src/main/resources/plugin.yml b/simplecloud-modules/simplecloud-module-sign/src/main/resources/plugin.yml index 4414b087c..e33c76758 100644 --- a/simplecloud-modules/simplecloud-module-sign/src/main/resources/plugin.yml +++ b/simplecloud-modules/simplecloud-module-sign/src/main/resources/plugin.yml @@ -1,6 +1,7 @@ name: SimpleCloud-Sign version: 1.0 author: Wetterbericht +folia-supported: true main: eu.thesimplecloud.module.sign.service.BukkitPluginMain diff --git a/simplecloud-plugin/build.gradle b/simplecloud-plugin/build.gradle index 57f4a30ab..f50a4e99c 100644 --- a/simplecloud-plugin/build.gradle +++ b/simplecloud-plugin/build.gradle @@ -28,6 +28,11 @@ dependencies { api(project(":simplecloud-api")) api(project(":simplecloud-client")) + + //compileOnly 'org.folia:folia-api:1.20.6-R0.1-SNAPSHOT' // Stellen Sie sicher, dass Sie die korrekte Version verwenden + implementation("com.cjcrafter:foliascheduler:0.6.0") + + compileOnly 'org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT' compileOnly 'net.md-5:bungeecord-api:1.17-R0.1-SNAPSHOT' compileOnly 'com.velocitypowered:velocity-api:3.1.1' @@ -35,6 +40,7 @@ dependencies { api('net.kyori:adventure-text-minimessage:4.14.0') api('net.kyori:adventure-platform-bungeecord:4.1.2') + } shadowJar { @@ -46,4 +52,4 @@ shadowJar { jar { dependsOn ':simplecloud-client:jar' -} +} \ No newline at end of file diff --git a/simplecloud-plugin/src/main/kotlin/eu/thesimplecloud/plugin/server/CloudSpigotPlugin.kt b/simplecloud-plugin/src/main/kotlin/eu/thesimplecloud/plugin/server/CloudSpigotPlugin.kt index 934b95b00..5e8660c7d 100644 --- a/simplecloud-plugin/src/main/kotlin/eu/thesimplecloud/plugin/server/CloudSpigotPlugin.kt +++ b/simplecloud-plugin/src/main/kotlin/eu/thesimplecloud/plugin/server/CloudSpigotPlugin.kt @@ -22,6 +22,8 @@ package eu.thesimplecloud.plugin.server +import com.cjcrafter.foliascheduler.FoliaCompatibility +import com.cjcrafter.foliascheduler.TaskImplementation import eu.thesimplecloud.api.CloudAPI import eu.thesimplecloud.api.player.ICloudPlayerManager import eu.thesimplecloud.plugin.impl.player.CloudPlayerManagerSpigot @@ -31,9 +33,9 @@ import eu.thesimplecloud.plugin.server.listener.SpigotListener import eu.thesimplecloud.plugin.startup.CloudPlugin import org.bukkit.Bukkit import org.bukkit.plugin.java.JavaPlugin -import org.bukkit.scheduler.BukkitRunnable import kotlin.reflect.KClass + class CloudSpigotPlugin : JavaPlugin(), ICloudServerPlugin { companion object { @@ -75,16 +77,31 @@ class CloudSpigotPlugin : JavaPlugin(), ICloudServerPlugin { return CloudPlayerManagerSpigot::class } + private fun synchronizeOnlineCountTask() { - object : BukkitRunnable() { - override fun run() { - val service = CloudPlugin.instance.thisService() - if (service.getOnlineCount() != server.onlinePlayers.size) { - service.setOnlineCount(server.onlinePlayers.size) - service.update() - } + val scheduler = FoliaCompatibility(this).serverImplementation + scheduler.async().runDelayed({ task: TaskImplementation -> + this.getLogger().info("This is the scheduled task! I'm async! $task") + + val service = CloudPlugin.instance.thisService() + + // Early return if service is null + if (service == null) { + this.getLogger().warning("Service is null, unable to synchronize online count.") + return@runDelayed } - }.runTaskTimerAsynchronously(this, 20 * 30, 20 * 30) + + val onlineCount = Bukkit.getOnlinePlayers().size + + // Update the service if the online player count has changed + if (service.getOnlineCount() != onlineCount) { + service.setOnlineCount(onlineCount) + service.update() + this.getLogger().info("Updated online count to $onlineCount") + } + + }, 5 * 20L) + } } \ No newline at end of file diff --git a/simplecloud-plugin/src/main/resources/plugin.yml b/simplecloud-plugin/src/main/resources/plugin.yml index ed978a8b7..7508d3479 100644 --- a/simplecloud-plugin/src/main/resources/plugin.yml +++ b/simplecloud-plugin/src/main/resources/plugin.yml @@ -1,6 +1,7 @@ name: SimpleCloud-Plugin version: 1.0 author: Wetterbericht +folia-supported: true main: eu.thesimplecloud.plugin.server.CloudSpigotPlugin