Skip to content

Commit

Permalink
Added some other things and prepared for release
Browse files Browse the repository at this point in the history
  • Loading branch information
byPixelTV committed Apr 8, 2024
1 parent 9022557 commit ad9201b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 84 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/de/bypixeltv/skcloudnet/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.bypixeltv.skcloudnet
import ch.njol.skript.Skript
import ch.njol.skript.SkriptAddon
import de.bypixeltv.skcloudnet.commands.SkCloudnetCommands
import de.bypixeltv.skcloudnet.tasks.UpdateCheck
import de.bypixeltv.skcloudnet.utils.GetVersion
import de.bypixeltv.skcloudnet.utils.UpdateChecker
import dev.jorel.commandapi.CommandAPI
Expand Down Expand Up @@ -85,6 +86,7 @@ class Main : KSpigot() {
}

UpdateChecker
UpdateCheck

val metrics: Metrics = Metrics(this, 21526)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.bypixeltv.skcloudnet.commands
import ch.njol.skript.Skript
import de.bypixeltv.skcloudnet.Main
import de.bypixeltv.skcloudnet.utils.GetVersion
import de.bypixeltv.skcloudnet.utils.UpdateChecker
import dev.jorel.commandapi.kotlindsl.commandTree
import dev.jorel.commandapi.kotlindsl.literalArgument
import dev.jorel.commandapi.kotlindsl.playerExecutor
Expand Down Expand Up @@ -52,27 +53,17 @@ class SkCloudnetCommands {
literalArgument("version") {
withPermission("skcloudnet.admin.version")
playerExecutor { player, _ ->
val githubVersion = GetVersion().getLatestAddonVersion()
val githubVersion = GetVersion().getLatestAddonVersion()?.replace("v", "")?.toDouble()
if (githubVersion != null) {
if (githubVersion != Main.INSTANCE.description.version) {
player.sendMessage(" ")
player.sendMessage(" ")
player.sendMessage(miniMessages.deserialize("<dark_grey>[<gradient:aqua:blue:aqua>SkCloudnet</gradient>]</dark_grey> <color:#43fa00>There is an update available for SkCloudnet!</color> <aqua>You're on version <yellow>${Main.INSTANCE.description.version}</yellow> and the latest version is <yellow>$githubVersion</yellow></aqua>!\n\n<color:#43fa00>Download the latest version here:</color> <click:open_url:'https://github.com/byPixelTV/SkCloudnet/releases'><blue>https://github.com/byPixelTV/SkCloudnet/releases</blue></click> <aqua>"))
player.sendMessage(" ")
player.sendMessage(" ")
if (githubVersion > Main.INSTANCE.description.version.replace("v", "").toDouble()) {
player.sendMessage(miniMessages.deserialize("<dark_grey>[<gradient:aqua:blue:aqua>SkCloudnet</gradient>]</dark_grey> <color:#43fa00>There is an update available for SkCloudnet!</color> <aqua>You're on version <yellow>${Main.INSTANCE.description.version}</yellow> and the latest version is <yellow>$githubVersion</yellow></aqua>!\n\n<color:#43fa00>Download the latest version here:</color> <blue>https://github.com/byPixelTV/SkCloudnet/releases</blue><aqua>"))
} else {
player.sendMessage(" ")
player.sendMessage(" ")
player.sendMessage(miniMessages.deserialize("<dark_grey>[<gradient:aqua:blue:aqua>SkCloudnet</gradient>]</dark_grey> <color:#43fa00>You're on the latest version of SkCloudnet!</color> <aqua>Version <yellow>${Main.INSTANCE.description.version}</yellow></aqua>"))
player.sendMessage(" ")
player.sendMessage(" ")
if (githubVersion < Main.INSTANCE.description.version.replace("v", "").toDouble()) {
player.sendMessage(miniMessages.deserialize("<dark_grey>[<gradient:aqua:blue:aqua>SkCloudnet</gradient>]</dark_grey> <color:#ff0000>You're running a development version of SkCloudnet! Please note that this version may contain bugs!</color> <aqua>Version <color:#ff0000>${Main.INSTANCE.description.version}</color> > <color:#43fa00>${GetVersion().getLatestAddonVersion()}</color></aqua>"))
}
}
} else {
player.sendMessage(" ")
player.sendMessage(" ")
player.sendMessage(miniMessages.deserialize("<dark_grey>[<gradient:aqua:blue:aqua>SkCloudnet</gradient>]</dark_grey> <color:#ff0000>Unable to fetch the latest version from Github!</color> <aqua>Are you rate limited?</aqua>"))
player.sendMessage(" ")
player.sendMessage(" ")
}
}
}
Expand Down

This file was deleted.

50 changes: 50 additions & 0 deletions src/main/kotlin/de/bypixeltv/skcloudnet/tasks/UpdateCheck.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package de.bypixeltv.skcloudnet.tasks

import de.bypixeltv.skcloudnet.Main
import de.bypixeltv.skcloudnet.utils.GetVersion
import net.axay.kspigot.runnables.task
import net.kyori.adventure.text.minimessage.MiniMessage

object UpdateCheck {
private val miniMessages = MiniMessage.miniMessage()

fun scheudle() {
task(false, 36000, 72000) {
val githubVersion = GetVersion().getLatestAddonVersion()?.replace("v", "")?.toDouble()
if (githubVersion != null) {
if (githubVersion > Main.INSTANCE.description.version.replace("v", "").toDouble()) {
Main.INSTANCE.server.consoleSender.sendMessage(" ")
Main.INSTANCE.server.consoleSender.sendMessage(" ")
Main.INSTANCE.server.consoleSender.sendMessage(miniMessages.deserialize("<color:#43fa00>There is an update available for SkCloudnet!</color> <aqua>You're on version <yellow>${Main.INSTANCE.description.version}</yellow> and the latest version is <yellow>$githubVersion</yellow></aqua>!\n\n<color:#43fa00>Download the latest version here:</color> <blue>https://github.com/byPixelTV/SkCloudnet/releases</blue> <aqua>"))
Main.INSTANCE.server.consoleSender.sendMessage(" ")
Main.INSTANCE.server.consoleSender.sendMessage(" ")
} else {
if (githubVersion == Main.INSTANCE.description.version.replace("v", "").toDouble()) {
Main.INSTANCE.server.consoleSender.sendMessage(" ")
Main.INSTANCE.server.consoleSender.sendMessage(" ")
Main.INSTANCE.server.consoleSender.sendMessage(miniMessages.deserialize("<color:#43fa00>You're on the latest version of SkCloudnet!</color> <aqua>Version <yellow>${Main.INSTANCE.description.version}</yellow></aqua>"))
Main.INSTANCE.server.consoleSender.sendMessage(" ")
Main.INSTANCE.server.consoleSender.sendMessage(" ")
} else if (githubVersion < Main.INSTANCE.description.version.replace("v", "").toDouble()) {
Main.INSTANCE.server.consoleSender.sendMessage(" ")
Main.INSTANCE.server.consoleSender.sendMessage(" ")
Main.INSTANCE.server.consoleSender.sendMessage(miniMessages.deserialize("<color:#ff0000>You're running a development version of SkCloudnet! Please note that this version may contain bugs!</color> <aqua>Version <color:#ff0000>${Main.INSTANCE.description.version}</color> > <color:#43fa00>${GetVersion().getLatestAddonVersion()}</color></aqua>"))
Main.INSTANCE.server.consoleSender.sendMessage(" ")
Main.INSTANCE.server.consoleSender.sendMessage(" ")
}
}
} else {
Main.INSTANCE.server.consoleSender.sendMessage(" ")
Main.INSTANCE.server.consoleSender.sendMessage(" ")
Main.INSTANCE.server.consoleSender.sendMessage(miniMessages.deserialize("<color:#ff0000>Unable to fetch the latest version from Github!</color> <aqua>Are you rate limited?</aqua>"))
Main.INSTANCE.server.consoleSender.sendMessage(" ")
Main.INSTANCE.server.consoleSender.sendMessage(" ")
}
}
}

init {
scheudle()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ object UpdateChecker {
val githubVersion = GetVersion().getLatestAddonVersion()?.replace("v", "")?.toDouble()
if (githubVersion != null) {
if (githubVersion > Main.INSTANCE.description.version.replace("v", "").toDouble()) {
player.sendMessage(miniMessages.deserialize("\n\n<dark_grey>[<gradient:aqua:blue:aqua>SkCloudnet</gradient>]</dark_grey> <color:#43fa00>There is an update available for SkCloudnet!</color> <aqua>You're on version <yellow>${Main.INSTANCE.description.version}</yellow> and the latest version is <yellow>$githubVersion</yellow></aqua>!\n\n<color:#43fa00>Download the latest version here:</color> <blue>https://github.com/byPixelTV/SkCloudnet/releases</blue> <aqua>"))
player.sendMessage(miniMessages.deserialize("<dark_grey>[<gradient:aqua:blue:aqua>SkCloudnet</gradient>]</dark_grey> <color:#43fa00>There is an update available for SkCloudnet!</color> <aqua>You're on version <yellow>${Main.INSTANCE.description.version}</yellow> and the latest version is <yellow>$githubVersion</yellow></aqua>!<color:#43fa00>Download the latest version here:</color> <blue>https://github.com/byPixelTV/SkCloudnet/releases</blue> <aqua>"))
} else {
if (githubVersion < Main.INSTANCE.description.version.replace("v", "").toDouble()) {
player.sendMessage(miniMessages.deserialize("\n\n<dark_grey>[<gradient:aqua:blue:aqua>SkCloudnet</gradient>]</dark_grey> <color:#ff0000>You're running a development version of SkCloudnet! Please note that this version may contain bugs!</color> <aqua>Version <color:#ff0000>${Main.INSTANCE.description.version}</color> > <color:#43fa00>${GetVersion().getLatestAddonVersion()}</color></aqua>"))
player.sendMessage(miniMessages.deserialize("<dark_grey>[<gradient:aqua:blue:aqua>SkCloudnet</gradient>]</dark_grey> <color:#ff0000>You're running a development version of SkCloudnet! Please note that this version may contain bugs!</color> <aqua>Version <color:#ff0000>${Main.INSTANCE.description.version}</color> > <color:#43fa00>${GetVersion().getLatestAddonVersion()}</color></aqua>"))
}
}
} else {
player.sendMessage(miniMessages.deserialize("\n\n<dark_grey>[<gradient:aqua:blue:aqua>SkCloudnet</gradient>]</dark_grey> <color:#ff0000>Unable to fetch the latest version from Github!</color> <aqua>Are you rate limited?</aqua>"))
player.sendMessage(miniMessages.deserialize("<dark_grey>[<gradient:aqua:blue:aqua>SkCloudnet</gradient>]</dark_grey> <color:#ff0000>Unable to fetch the latest version from Github!</color> <aqua>Are you rate limited?</aqua>"))
}
}
}
Expand Down

0 comments on commit ad9201b

Please sign in to comment.