Skip to content

Commit 412293c

Browse files
committed
1.4.3
1 parent e3cb593 commit 412293c

File tree

3 files changed

+48
-64
lines changed

3 files changed

+48
-64
lines changed

pom.xml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<groupId>lol.hyper</groupId>
2525
<artifactId>anarchystats</artifactId>
26-
<version>1.4.2</version>
26+
<version>1.4.3</version>
2727
<packaging>jar</packaging>
2828

2929
<name>AnarchyStats</name>
@@ -34,8 +34,20 @@
3434
</properties>
3535

3636
<build>
37-
<defaultGoal>clean package</defaultGoal>
3837
<plugins>
38+
<plugin>
39+
<artifactId>maven-clean-plugin</artifactId>
40+
<version>3.1.0</version>
41+
<executions>
42+
<execution>
43+
<id>auto-clean</id>
44+
<phase>initialize</phase>
45+
<goals>
46+
<goal>clean</goal>
47+
</goals>
48+
</execution>
49+
</executions>
50+
</plugin>
3951
<plugin>
4052
<groupId>org.apache.maven.plugins</groupId>
4153
<artifactId>maven-compiler-plugin</artifactId>
@@ -95,5 +107,10 @@
95107
<version>2.2.1</version>
96108
<scope>compile</scope>
97109
</dependency>
110+
<dependency>
111+
<groupId>lol.hyper</groupId>
112+
<artifactId>github-release-api</artifactId>
113+
<version>1.0.0</version>
114+
</dependency>
98115
</dependencies>
99116
</project>

src/main/java/lol/hyper/anarchystats/AnarchyStats.java

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@
2121
import lol.hyper.anarchystats.commands.CommandReload;
2222
import lol.hyper.anarchystats.tools.AbstractCommand;
2323
import lol.hyper.anarchystats.tools.MessageParser;
24-
import lol.hyper.anarchystats.tools.Updater;
2524
import lol.hyper.anarchystats.tools.WorldSize;
25+
import lol.hyper.githubreleaseapi.GitHubRelease;
26+
import lol.hyper.githubreleaseapi.GitHubReleaseAPI;
2627
import org.bstats.bukkit.Metrics;
2728
import org.bukkit.Bukkit;
2829
import org.bukkit.configuration.file.FileConfiguration;
2930
import org.bukkit.configuration.file.YamlConfiguration;
3031
import org.bukkit.plugin.java.JavaPlugin;
3132

3233
import java.io.File;
34+
import java.io.IOException;
3335
import java.nio.file.Path;
3436
import java.nio.file.Paths;
3537
import java.util.ArrayList;
@@ -62,15 +64,9 @@ public void onEnable() {
6264
this.getCommand("anarchystats").setExecutor(commandReload);
6365
Bukkit.getScheduler().runTaskAsynchronously(this, this::updateWorldSize);
6466

65-
new Updater(this, 66089).getVersion(version -> {
66-
if (this.getDescription().getVersion().equalsIgnoreCase(version)) {
67-
logger.info("You are running the latest version.");
68-
} else {
69-
logger.info(
70-
"There is a new version available! Please download at https://www.spigotmc.org/resources/anarchystats.66089/");
71-
}
72-
});
73-
Metrics metrics = new Metrics(this, 6877);
67+
new Metrics(this, 6877);
68+
69+
Bukkit.getScheduler().runTaskAsynchronously(this, this::checkForUpdates);
7470
}
7571

7672
public void updateWorldSize() {
@@ -96,4 +92,27 @@ public void loadConfig() {
9692
logger.warning("You configuration is out of date! Some features may not work!");
9793
}
9894
}
95+
96+
public void checkForUpdates() {
97+
GitHubReleaseAPI api;
98+
try {
99+
api = new GitHubReleaseAPI("AnarchyStats", "hyperdefined");
100+
} catch (IOException e) {
101+
logger.warning("Unable to check updates!");
102+
e.printStackTrace();
103+
return;
104+
}
105+
GitHubRelease current = api.getReleaseByTag(this.getDescription().getVersion());
106+
GitHubRelease latest = api.getLatestVersion();
107+
if (current == null) {
108+
logger.warning("You are running a version that does not exist on GitHub. If you are in a dev environment, you can ignore this. Otherwise, this is a bug!");
109+
return;
110+
}
111+
int buildsBehind = api.getBuildsBehind(current);
112+
if (buildsBehind == 0) {
113+
logger.info("You are running the latest version.");
114+
} else {
115+
logger.warning("A new version is available (" + latest.getTagVersion() + ")! You are running version " + current.getTagVersion() + ". You are " + buildsBehind + " version(s) behind.");
116+
}
117+
}
99118
}

src/main/java/lol/hyper/anarchystats/tools/Updater.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)