-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
119 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
src/main/kotlin/me/quantiom/advancedvanish/util/Extensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/me/quantiom/advancedvanish/util/UpdateChecker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package me.quantiom.advancedvanish.util | ||
|
||
import me.quantiom.advancedvanish.AdvancedVanish | ||
import org.bukkit.Bukkit | ||
import java.io.IOException | ||
import java.net.URL | ||
import java.util.* | ||
import java.util.function.Consumer | ||
|
||
// credit: https://www.spigotmc.org/wiki/creating-an-update-checker-that-checks-for-updates/ | ||
|
||
object UpdateChecker { | ||
private const val RESOURCE_ID = 86036 | ||
|
||
fun getVersion(consumer: Consumer<String?>) { | ||
Bukkit.getScheduler().runTaskAsynchronously(AdvancedVanish.instance!!, Runnable { | ||
try { | ||
URL("https://api.spigotmc.org/legacy/update.php?resource=${RESOURCE_ID}").openStream() | ||
.use { inputStream -> | ||
Scanner(inputStream).use { scanner -> | ||
if (scanner.hasNext()) { | ||
consumer.accept(scanner.next()) | ||
} | ||
} | ||
} | ||
} catch (exception: IOException) { | ||
AdvancedVanish.instance!!.logger.info("Unable to check for updates: " + exception.message) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters