From 26b7798b9300f6f0d9a093d3876a605865cbf897 Mon Sep 17 00:00:00 2001 From: Syrent <56670179+Syrent@users.noreply.github.com> Date: Sat, 31 Dec 2022 04:47:29 +0330 Subject: [PATCH] Add update checker --- build.gradle | 12 +++++++++-- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../spigot/VelocityVanishSpigot.kt | 21 +++++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index ed1857e0..0a45e1ff 100644 --- a/build.gradle +++ b/build.gradle @@ -64,6 +64,12 @@ repositories { maven { url = 'https://repo.essentialsx.net/releases/' } + + // Update checker + maven { + name = "jeff-media-public" + url = 'https://hub.jeff-media.com/nexus/repository/jeff-media-public/' + } } dependencies { @@ -74,8 +80,8 @@ dependencies { compileOnly 'xyz.jpenilla:squaremap-api:1.1.9' compileOnly 'net.essentialsx:EssentialsX:2.19.7' - compileOnly files("libs/SayanChat-2.8.3.jar") - compileOnly files('libs/ProCosmetics-13.7.jar') + compileOnly files("libs/SayanChat-2.8.1-all.jar") + compileOnly files('libs/ProCosmetics.jar') compileOnly files('libs/ServerListPlus-3.5.0-SNAPSHOT-Velocity.jar') implementation 'io.papermc:paperlib:1.0.7' @@ -91,6 +97,7 @@ dependencies { implementation 'net.kyori:adventure-api:4.12.0' implementation 'net.kyori:adventure-platform-bukkit:4.2.0' implementation 'net.kyori:adventure-text-minimessage:4.12.0' + implementation 'com.jeff_media:SpigotUpdateChecker:3.0.0' annotationProcessor 'com.velocitypowered:velocity-api:3.1.1' } @@ -114,6 +121,7 @@ shadowJar { relocate('me.mohamad82.ruom', 'ir.syrent.velocityvanish.ruom') relocate('com.cryptomorin.xseries', 'ir.syrent.velocityvanish.xseries') relocate('kotlin', 'ir.syrent.velocityvanish.kotlin') + relocate('com.jeff_media.updatechecker', 'ir.syrent.velocityvanish.updatechecker') relocate('com.google', 'ir.syrent.velocityvanish.google') // relocate('net.kyori.adventure', 'ir.syrent.velocityvanish.kyori.adventure') diff --git a/gradle.properties b/gradle.properties index c4354dab..aacfaa76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version=3.10.2 +version=3.11.0 plugin-name=VelocityVanish \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f398c33c..75668a30 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/ir/syrent/velocityvanish/spigot/VelocityVanishSpigot.kt b/src/main/java/ir/syrent/velocityvanish/spigot/VelocityVanishSpigot.kt index 0eaef0e6..5773a017 100644 --- a/src/main/java/ir/syrent/velocityvanish/spigot/VelocityVanishSpigot.kt +++ b/src/main/java/ir/syrent/velocityvanish/spigot/VelocityVanishSpigot.kt @@ -1,6 +1,8 @@ package ir.syrent.velocityvanish.spigot import com.google.gson.JsonObject +import com.jeff_media.updatechecker.UpdateCheckSource +import com.jeff_media.updatechecker.UpdateChecker import io.papermc.lib.PaperLib import ir.syrent.velocityvanish.spigot.bridge.BukkitBridge import ir.syrent.velocityvanish.spigot.bridge.BukkitBridgeManager @@ -40,6 +42,7 @@ class VelocityVanishSpigot : RUoMPlugin() { resetData(true) sendFiglet() sendWarningMessages() + checkUpdate() initializeCommands() initializeListeners() @@ -77,6 +80,24 @@ class VelocityVanishSpigot : RUoMPlugin() { DependencyManager } + private fun checkUpdate() { + Thread { + try { + UpdateChecker(this, UpdateCheckSource.SPIGOT, 105992.toString()) + .setDownloadLink("https://www.spigotmc.org/resources/velocityvanish-1-8-1-19-3-no-database-required.105992/") + .checkEveryXHours(24.0) + .setChangelogLink(105992.toString()) + .setNotifyOpsOnJoin(true) + .setNotifyByPermissionOnJoin("velocityvanish.updatechecker") + .setTimeout(30 * 1000) + .setSupportLink("https://discord.gg/xZyYGU4EG4") + .checkNow() + } catch (_: Exception) { + Ruom.warn("Could not check for updates, check your connection.") + } + }.start() + } + private fun resetData(startup: Boolean) { try { for (player in Ruom.getOnlinePlayers()) {