diff --git a/src/main/kotlin/de/bypixeltv/skcloudnet/commands/SkCloudnetCommands.kt b/src/main/kotlin/de/bypixeltv/skcloudnet/commands/SkCloudnetCommands.kt index 96a7daa..e958210 100644 --- a/src/main/kotlin/de/bypixeltv/skcloudnet/commands/SkCloudnetCommands.kt +++ b/src/main/kotlin/de/bypixeltv/skcloudnet/commands/SkCloudnetCommands.kt @@ -2,6 +2,7 @@ package de.bypixeltv.skcloudnet.commands import ch.njol.skript.Skript import de.bypixeltv.skcloudnet.Main +import de.bypixeltv.skcloudnet.tasks.UpdateCheck import de.bypixeltv.skcloudnet.utils.GetVersion import de.bypixeltv.skcloudnet.utils.UpdateChecker import dev.jorel.commandapi.kotlindsl.commandTree @@ -56,9 +57,11 @@ class SkCloudnetCommands { val githubVersion = GetVersion().getLatestAddonVersion()?.replace("v", "")?.toDouble() if (githubVersion != null) { if (githubVersion > Main.INSTANCE.description.version.replace("v", "").toDouble()) { - player.sendMessage(miniMessages.deserialize("[SkCloudnet] There is an update available for SkCloudnet! You're on version ${Main.INSTANCE.description.version} and the latest version is $githubVersion!\n\nDownload the latest version here: https://github.com/byPixelTV/SkCloudnet/releases")) + player.sendMessage(miniMessages.deserialize("[SkCloudnet] There is an update available for SkCloudnet! You're on version ${Main.INSTANCE.description.version} and the latest version is $githubVersion!\n\nDownload the latest version here: https://github.com/byPixelTV/SkCloudnet/releases ")) } else { - if (githubVersion < Main.INSTANCE.description.version.replace("v", "").toDouble()) { + if (githubVersion == Main.INSTANCE.description.version.replace("v", "").toDouble()) { + player.sendMessage(miniMessages.deserialize("[SkCloudnet] You're on the latest version of SkCloudnet! Version ${Main.INSTANCE.description.version}")) + } else if (githubVersion < Main.INSTANCE.description.version.replace("v", "").toDouble()) { player.sendMessage(miniMessages.deserialize("[SkCloudnet] You're running a development version of SkCloudnet! Please note that this version may contain bugs! Version ${Main.INSTANCE.description.version} > ${GetVersion().getLatestAddonVersion()}")) } } diff --git a/src/main/kotlin/de/bypixeltv/skcloudnet/elements/expressions/players/ExprGetAllCloudnetPlayers.kt b/src/main/kotlin/de/bypixeltv/skcloudnet/elements/expressions/players/ExprGetAllCloudnetPlayers.kt new file mode 100644 index 0000000..6148a42 --- /dev/null +++ b/src/main/kotlin/de/bypixeltv/skcloudnet/elements/expressions/players/ExprGetAllCloudnetPlayers.kt @@ -0,0 +1,63 @@ +package de.bypixeltv.skcloudnet.elements.expressions.players + +import ch.njol.skript.Skript +import ch.njol.skript.doc.Description +import ch.njol.skript.doc.Examples +import ch.njol.skript.doc.Name +import ch.njol.skript.doc.Since +import ch.njol.skript.lang.Expression +import ch.njol.skript.lang.ExpressionType +import ch.njol.skript.lang.SkriptParser +import ch.njol.skript.lang.util.SimpleExpression +import ch.njol.util.Kleenean +import eu.cloudnetservice.driver.inject.InjectionLayer +import eu.cloudnetservice.driver.registry.ServiceRegistry +import eu.cloudnetservice.modules.bridge.player.PlayerManager +import org.bukkit.entity.Player +import org.bukkit.event.Event + + +@Name("CloudNet Proxy of Player") +@Description("Returns the CloudNet proxy of a player.") +@Examples("send cloudnet proxy of \"byPixelTV\" parsed as player") +@Since("1.0") + +class ExprGetAllCloudnetPlayers : SimpleExpression() { + + private val serviceRegistry: ServiceRegistry = InjectionLayer.ext().instance(ServiceRegistry::class.java) + private val playerManager: PlayerManager = serviceRegistry.firstProvider(PlayerManager::class.java) + + companion object{ + init { + Skript.registerExpression( + ExprGetAllCloudnetPlayers::class.java, String::class.java, + ExpressionType.SIMPLE, "all [of the] cloudnet players") + } + } + + override fun isSingle(): Boolean { + return false + } + + @Suppress("UNCHECKED_CAST") + override fun init( + exprs: Array>, + matchedPattern: Int, + isDelayed: Kleenean?, + parseResult: SkriptParser.ParseResult? + ): Boolean { + return true + } + override fun get(e: Event?): Array { + return playerManager.onlinePlayers().names().toTypedArray() + } + + override fun getReturnType(): Class { + return String::class.java + } + + override fun toString(e: Event?, debug: Boolean): String { + return "all cloudnet players" + } + +} \ No newline at end of file