-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
61 additions
and
1 deletion.
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
36 changes: 36 additions & 0 deletions
36
src/main/java/me/justindevb/VulcanReplpay/util/UpdateChecker.java
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,36 @@ | ||
package me.justindevb.VulcanReplpay.util; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.util.Scanner; | ||
import java.util.function.Consumer; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
//From: https://www.spigotmc.org/wiki/creating-an-update-checker-that-checks-for-updates | ||
public class UpdateChecker { | ||
|
||
private final JavaPlugin plugin; | ||
private final int resourceId; | ||
|
||
public UpdateChecker(JavaPlugin plugin, int resourceId) { | ||
this.plugin = plugin; | ||
this.resourceId = resourceId; | ||
} | ||
|
||
public void getVersion(final Consumer<String> consumer) { | ||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> { | ||
try (InputStream inputStream = new URL( | ||
"https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream(); | ||
Scanner scanner = new Scanner(inputStream)) { | ||
if (scanner.hasNext()) { | ||
consumer.accept(scanner.next()); | ||
} | ||
} catch (IOException exception) { | ||
plugin.getLogger().info("Unable to check for updates: " + exception.getMessage()); | ||
} | ||
}); | ||
} | ||
} |
Binary file modified
BIN
+1.05 KB
(120%)
target/classes/me/justindevb/VulcanReplay/VulcanReplay.class
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#Generated by Maven | ||
#Wed Nov 24 09:35:49 CST 2021 | ||
#Wed Nov 24 10:02:13 CST 2021 | ||
groupId=me.justindevb | ||
artifactId=VulcanReplay | ||
version=1.3 |
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
1 change: 1 addition & 0 deletions
1
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
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
Binary file not shown.