Skip to content

Commit

Permalink
Ver 1.0.3-1
Browse files Browse the repository at this point in the history
✅ New UpdateChecker
🛠Fix command reload can't refresh new hologram
  • Loading branch information
L1-An committed Jan 12, 2024
1 parent e417dec commit 484204a
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 2 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added src/.DS_Store
Binary file not shown.
Binary file added src/main/.DS_Store
Binary file not shown.
Binary file added src/main/kotlin/.DS_Store
Binary file not shown.
Binary file added src/main/kotlin/com/.DS_Store
Binary file not shown.
Binary file added src/main/kotlin/com/github/.DS_Store
Binary file not shown.
Binary file added src/main/kotlin/com/github/l1an/.DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.l1an.yuspawnerhologram

import com.github.l1an.yuspawnerhologram.api.UpdateChecker
import io.lumine.mythic.bukkit.MythicBukkit
import org.bukkit.Bukkit
import taboolib.common.platform.Platform
Expand All @@ -17,14 +18,26 @@ object YuSpawnerHologram : Plugin() {
mythicMobsPlugin as MythicBukkit
}

val messagePrefix = "&f[ &5YuSpawnerHologram &f]"

override fun onLoad() {
Language.default = "zh_CN"
}

override fun onEnable() {
Metrics(20123, BukkitPlugin.getInstance().description.version, Platform.BUKKIT)

console().sendMessage("&aYuSpawnerHologram has been loaded!".colored())
console().sendMessage("&bAuthor by L1An".colored())
console().sendMessage("$messagePrefix &aYuSpawnerHologram has been loaded!".colored())
console().sendMessage("$messagePrefix &bAuthor by L1An".colored())

// 检查更新
UpdateChecker(113207).getVersion { version: String? ->
if (BukkitPlugin.getInstance().description.version == version) {
console().sendMessage("$messagePrefix &cThere is not a new update available.".colored())
} else {
console().sendMessage("$messagePrefix &aThere is a new update available at:".colored())
console().sendMessage("&ahttps://www.spigotmc.org/resources/113207/".colored())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.l1an.yuspawnerhologram.api

import taboolib.common.platform.function.info
import taboolib.common.platform.function.submit
import java.io.IOException
import java.net.URL
import java.util.*
import java.util.function.Consumer

class UpdateChecker(private val resourceId: Int) {
fun getVersion(consumer: Consumer<String?>) {
submit(async = true) {
try {
URL("https://api.spigotmc.org/legacy/update.php?resource=" + resourceId + "/~")
.openStream().use { `is` ->
Scanner(`is`).use { scann ->
if (scann.hasNext()) {
consumer.accept(scann.next())
}
}
}
} catch (e: IOException) {
info("Unable to check for updates: " + e.message)
}
}
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ object AdyeshachHologram {
createHologramByADY(spawnerName, sender, tip)
sender.sendLang("holo-refresh-success", spawnerName)
} else {
createHologramByADY(spawnerName, sender, tip)
sender.sendLang("holo-refresh-fail", spawnerName)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ object DecentHologram {
createHologramByDH(spawnerName, sender)
sender.sendLang("holo-refresh-success", spawnerName)
} else {
createHologramByDH(spawnerName, sender)
sender.sendLang("holo-refresh-fail", spawnerName)
}
}
Expand Down

0 comments on commit 484204a

Please sign in to comment.