File tree Expand file tree Collapse file tree 4 files changed +40
-2
lines changed
java/xyz/jpenilla/dsgraph Expand file tree Collapse file tree 4 files changed +40
-2
lines changed Original file line number Diff line number Diff line change 66
77 <groupId >xyz.jpenilla</groupId >
88 <artifactId >DynamicShop-Graph</artifactId >
9- <version >0.2.2-SNAPSHOT.{BUILD_NUMBER} </version >
9+ <version >0.2.2</version >
1010 <packaging >jar</packaging >
1111
1212 <name >DynamicShop Graph</name >
Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ public void onEnable() {
4343 Metrics metrics = new Metrics (this , pluginId );
4444 metrics .addCustomChart (new Metrics .SimplePie ("amount_of_items_tracked" , () -> String .valueOf (cfg .getFiles ().size ())));
4545
46+ new UpdateChecker (this , 80638 ).getVersion (version -> {
47+ if (!this .getDescription ().getVersion ().equalsIgnoreCase (version )) {
48+ getLogger ().info ("There is an update available for DynamicShop-Graph (" + version + ") at https://www.spigotmc.org/resources/dynamicshop-graph.80638/" );
49+ }
50+ });
4651 }
4752
4853 @ Override
Original file line number Diff line number Diff line change 1+ package xyz .jpenilla .dsgraph ;
2+
3+ import org .bukkit .Bukkit ;
4+ import org .bukkit .plugin .Plugin ;
5+ import org .bukkit .util .Consumer ;
6+
7+ import java .io .IOException ;
8+ import java .io .InputStream ;
9+ import java .net .URL ;
10+ import java .util .Scanner ;
11+
12+ public class UpdateChecker {
13+
14+ private final Plugin plugin ;
15+ private final int resourceId ;
16+
17+ public UpdateChecker (Plugin plugin , int resourceId ) {
18+ this .plugin = plugin ;
19+ this .resourceId = resourceId ;
20+ }
21+
22+ public void getVersion (final Consumer <String > consumer ) {
23+ Bukkit .getScheduler ().runTaskAsynchronously (this .plugin , () -> {
24+ try (InputStream inputStream = new URL ("https://api.spigotmc.org/legacy/update.php?resource=" + this .resourceId ).openStream (); Scanner scanner = new Scanner (inputStream )) {
25+ if (scanner .hasNext ()) {
26+ consumer .accept (scanner .next ());
27+ }
28+ } catch (IOException exception ) {
29+ this .plugin .getLogger ().info ("Cannot look for updates: " + exception .getMessage ());
30+ }
31+ });
32+ }
33+ }
Original file line number Diff line number Diff line change 7171 < ul >
7272 < li > < a class ="grey-text text-lighten-3 " href ="https://github.com/jmanpenilla/DynamicShop-Graph "> GitHub</ a >
7373 </ li >
74- < li > < a class ="grey-text text-lighten-3 " href ="#! "> Spigot</ a > </ li >
74+ < li > < a class ="grey-text text-lighten-3 " href ="https://www.spigotmc.org/resources/dynamicshop-graph.80638/ "> Spigot</ a > </ li >
7575 </ ul >
7676 </ div >
7777 </ div >
You can’t perform that action at this time.
0 commit comments