Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/folia support #196

Open
wants to merge 8 commits into
base: dev/2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: SimpleCloud-Chat-Tab
version: 1.0
author: Fllip
folia-supported: true

main: eu.thesimplecloud.module.prefix.service.spigot.BukkitPluginMain

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: SimpleCloud-Permission
version: 1.0
author: Wetterbericht
folia-supported: true

main: eu.thesimplecloud.module.permission.service.spigot.SpigotPluginMain

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: SimpleCloud-Proxy
version: 1.0
author: Fllip
folia-supported: true

main: eu.thesimplecloud.module.proxy.service.bungee.BungeePluginMain

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: SimpleCloud-Sign
version: 1.0
author: Wetterbericht
folia-supported: true

main: eu.thesimplecloud.module.sign.service.BukkitPluginMain

Expand Down
8 changes: 7 additions & 1 deletion simplecloud-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@ 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'
annotationProcessor 'com.velocitypowered:velocity-api:3.1.1'

api('net.kyori:adventure-text-minimessage:4.14.0')
api('net.kyori:adventure-platform-bungeecord:4.1.2')

}

shadowJar {
Expand All @@ -46,4 +52,4 @@ shadowJar {

jar {
dependsOn ':simplecloud-client:jar'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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<Void?> ->
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)

}

}
1 change: 1 addition & 0 deletions simplecloud-plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: SimpleCloud-Plugin
version: 1.0
author: Wetterbericht
folia-supported: true

main: eu.thesimplecloud.plugin.server.CloudSpigotPlugin

Expand Down