Skip to content

Commit

Permalink
updater
Browse files Browse the repository at this point in the history
  • Loading branch information
Cephetir committed Feb 4, 2022
1 parent e6d93ff commit 9815cae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion h.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6
2.5
11 changes: 6 additions & 5 deletions src/main/kotlin/me/cephetir/skyskipped/SkySkipped.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package me.cephetir.skyskipped

import gg.essential.api.utils.Multithreading
import gg.essential.api.utils.WebUtil
import gg.essential.universal.UChat
import gg.essential.universal.wrappers.message.UTextComponent
Expand All @@ -26,6 +27,7 @@ import me.cephetir.skyskipped.event.Listener
import me.cephetir.skyskipped.features.Features
import me.cephetir.skyskipped.features.impl.discordrpc.RPC
import me.cephetir.skyskipped.utils.BlurUtils
import net.minecraft.client.Minecraft
import net.minecraft.event.ClickEvent
import net.minecraftforge.client.ClientCommandHandler
import net.minecraftforge.common.MinecraftForge
Expand Down Expand Up @@ -83,24 +85,23 @@ class SkySkipped {
var checked = false
@SubscribeEvent
fun onWorldLoad(event: WorldEvent.Load) {
if(checked) return
if(checked || Minecraft.getMinecraft().theWorld == null) return
checked = true
logger.info("Checking for updates...")
Thread {
Multithreading.runAsync Thread@ {
val version = WebUtil.fetchString("https://raw.githubusercontent.com/Cephetir/SkySkipped/kotlin/h.txt") ?: return@Thread
if (version == "Failed to fetch") return@Thread
if (VERSION.toDouble() < version.toDouble()) {
logger.info("New version detected!")
UChat.chat(
UTextComponent("""
§4§l-----------------------------------------
§cSkySkipped §f:: §eNew Version Detected: §c ${version.toDouble()}
§b[Download]
§cSkySkipped §f:: §eNew Version Detected: §c ${version.toDouble()} §8(Click to Download)
§4§l-----------------------------------------
""".trimIndent())
.setClick(ClickEvent.Action.OPEN_URL, "https://github.com/Cephetir/SkySkipped/releases/latest")
)
}
} else logger.info("Latest version!")
}
}
}

0 comments on commit 9815cae

Please sign in to comment.