From 251e8817075f7ad40e839b26fa95b5e320f9c05d Mon Sep 17 00:00:00 2001 From: Panda260 Date: Sun, 25 Jun 2023 22:56:27 +0200 Subject: [PATCH 1/4] folia-supported: true --- .../simplecloud-module-chat-tab/src/main/resources/plugin.yml | 1 + .../simplecloud-module-permission/src/main/resources/plugin.yml | 1 + .../simplecloud-module-proxy/src/main/resources/plugin.yml | 1 + .../simplecloud-module-sign/src/main/resources/plugin.yml | 1 + simplecloud-plugin/src/main/resources/plugin.yml | 1 + 5 files changed, 5 insertions(+) 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 af3e83af4..b932b7fe4 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 a203afac6..d8164bb6a 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/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 From 5b2a40140542698259f2852897467f8ad9071559 Mon Sep 17 00:00:00 2001 From: DevSnx <59105899+DevSnx@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:27:46 +0200 Subject: [PATCH 2/4] Push --- simplecloud-plugin/build.gradle | 3 +++ .../eu/thesimplecloud/plugin/server/CloudSpigotPlugin.kt | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/simplecloud-plugin/build.gradle b/simplecloud-plugin/build.gradle index 57f4a30ab..8ae8013d7 100644 --- a/simplecloud-plugin/build.gradle +++ b/simplecloud-plugin/build.gradle @@ -28,6 +28,8 @@ 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 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 +37,7 @@ dependencies { api('net.kyori:adventure-text-minimessage:4.14.0') api('net.kyori:adventure-platform-bungeecord:4.1.2') + } shadowJar { 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..e179aa827 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 @@ -76,15 +76,18 @@ class CloudSpigotPlugin : JavaPlugin(), ICloudServerPlugin { } private fun synchronizeOnlineCountTask() { + // Create a task that runs periodically object : BukkitRunnable() { override fun run() { + // Ensure that the task runs on the main thread val service = CloudPlugin.instance.thisService() - if (service.getOnlineCount() != server.onlinePlayers.size) { - service.setOnlineCount(server.onlinePlayers.size) + // Check the online player count and update the service if it has changed + if (service.getOnlineCount() != Bukkit.getOnlinePlayers().size) { + service.setOnlineCount(Bukkit.getOnlinePlayers().size) service.update() } } - }.runTaskTimerAsynchronously(this, 20 * 30, 20 * 30) + }.runTaskTimer(this, 20 * 30, 20 * 30) // Run every 30 seconds } } \ No newline at end of file From b16100de7de219ca16482d91fc92e605d889c198 Mon Sep 17 00:00:00 2001 From: DevSnx <59105899+DevSnx@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:29:55 +0200 Subject: [PATCH 3/4] (+) Folia Support --- simplecloud-plugin/build.gradle | 4 ++-- .../plugin/server/CloudSpigotPlugin.kt | 22 +++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/simplecloud-plugin/build.gradle b/simplecloud-plugin/build.gradle index 8ae8013d7..a6757237b 100644 --- a/simplecloud-plugin/build.gradle +++ b/simplecloud-plugin/build.gradle @@ -29,7 +29,7 @@ dependencies { api(project(":simplecloud-client")) - compileOnly 'org.folia:folia-api:1.20.6-R0.1-SNAPSHOT' // Stellen Sie sicher, dass Sie die korrekte Version verwenden + //compileOnly 'org.folia:folia-api:1.20.6-R0.1-SNAPSHOT' // Stellen Sie sicher, dass Sie die korrekte Version verwenden 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' @@ -49,4 +49,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 e179aa827..62ac2ad47 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 @@ -54,7 +54,7 @@ class CloudSpigotPlugin : JavaPlugin(), ICloudServerPlugin { CloudAPI.instance.getEventManager().registerListener(CloudPlugin.instance, CloudListener()) server.pluginManager.registerEvents(SpigotListener(), this) server.pluginManager.registerEvents(ReloadCommandBlocker(), this) - synchronizeOnlineCountTask() + //synchronizeOnlineCountTask() } override fun onBeforeFirstUpdate() { @@ -76,18 +76,26 @@ class CloudSpigotPlugin : JavaPlugin(), ICloudServerPlugin { } private fun synchronizeOnlineCountTask() { - // Create a task that runs periodically + // Erstelle eine Aufgabe, die regelmäßig ausgeführt wird object : BukkitRunnable() { override fun run() { - // Ensure that the task runs on the main thread + // Sicherstellen, dass die Aufgabe im Haupt-Thread läuft val service = CloudPlugin.instance.thisService() - // Check the online player count and update the service if it has changed - if (service.getOnlineCount() != Bukkit.getOnlinePlayers().size) { - service.setOnlineCount(Bukkit.getOnlinePlayers().size) + + // Überprüfen, ob der Dienst null ist + if (service == null) { + println("Service ist null, kann die Online-Zahl nicht synchronisieren.") + return + } + + // Überprüfen der Anzahl der Online-Spieler und Aktualisieren des Dienstes, falls sich die Anzahl geändert hat + val onlineCount = Bukkit.getOnlinePlayers().size + if (service.getOnlineCount() != onlineCount) { + service.setOnlineCount(onlineCount) service.update() } } - }.runTaskTimer(this, 20 * 30, 20 * 30) // Run every 30 seconds + }.runTaskTimer(this, 20 * 30, 20 * 30) // Alle 30 Sekunden ausführen } } \ No newline at end of file From 4fada3beed18987427130ca107e71f8ff3fa7d97 Mon Sep 17 00:00:00 2001 From: DevSnx <59105899+DevSnx@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:47:30 +0200 Subject: [PATCH 4/4] Push --- simplecloud-plugin/build.gradle | 3 ++ .../plugin/server/CloudSpigotPlugin.kt | 48 +++++++++++-------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/simplecloud-plugin/build.gradle b/simplecloud-plugin/build.gradle index a6757237b..f50a4e99c 100644 --- a/simplecloud-plugin/build.gradle +++ b/simplecloud-plugin/build.gradle @@ -30,6 +30,9 @@ dependencies { 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' 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 62ac2ad47..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 { @@ -54,7 +56,7 @@ class CloudSpigotPlugin : JavaPlugin(), ICloudServerPlugin { CloudAPI.instance.getEventManager().registerListener(CloudPlugin.instance, CloudListener()) server.pluginManager.registerEvents(SpigotListener(), this) server.pluginManager.registerEvents(ReloadCommandBlocker(), this) - //synchronizeOnlineCountTask() + synchronizeOnlineCountTask() } override fun onBeforeFirstUpdate() { @@ -75,27 +77,31 @@ class CloudSpigotPlugin : JavaPlugin(), ICloudServerPlugin { return CloudPlayerManagerSpigot::class } + private fun synchronizeOnlineCountTask() { - // Erstelle eine Aufgabe, die regelmäßig ausgeführt wird - object : BukkitRunnable() { - override fun run() { - // Sicherstellen, dass die Aufgabe im Haupt-Thread läuft - val service = CloudPlugin.instance.thisService() - - // Überprüfen, ob der Dienst null ist - if (service == null) { - println("Service ist null, kann die Online-Zahl nicht synchronisieren.") - return - } - - // Überprüfen der Anzahl der Online-Spieler und Aktualisieren des Dienstes, falls sich die Anzahl geändert hat - val onlineCount = Bukkit.getOnlinePlayers().size - if (service.getOnlineCount() != onlineCount) { - service.setOnlineCount(onlineCount) - 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 } - }.runTaskTimer(this, 20 * 30, 20 * 30) // Alle 30 Sekunden ausführen + + 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