Skip to content
This repository was archived by the owner on Dec 14, 2024. It is now read-only.

Commit 53679c6

Browse files
committed
1.1.1
1 parent c008cb1 commit 53679c6

3 files changed

Lines changed: 47 additions & 17 deletions

File tree

partychat.iml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.4" level="project" />
2727
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.28" level="project" />
2828
<orderEntry type="library" name="Maven: org.json:json:20210307" level="project" />
29-
<orderEntry type="library" name="Maven: commons-io:commons-io:2.10.0" level="project" />
29+
<orderEntry type="library" name="Maven: commons-io:commons-io:2.11.0" level="project" />
3030
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:2.2.1" level="project" />
3131
<orderEntry type="library" name="Maven: org.bstats:bstats-base:2.2.1" level="project" />
32+
<orderEntry type="library" name="Maven: lol.hyper:github-release-api:1.0.0" level="project" />
33+
<orderEntry type="library" name="Maven: org.jetbrains:annotations:23.0.0" level="project" />
3234
</component>
3335
</module>

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>partychat</artifactId>
26-
<version>1.1</version>
26+
<version>1.1.1</version>
2727
<packaging>jar</packaging>
2828

2929
<name>PartyChat</name>
@@ -35,8 +35,20 @@
3535
</properties>
3636

3737
<build>
38-
<defaultGoal>clean package</defaultGoal>
3938
<plugins>
39+
<plugin>
40+
<artifactId>maven-clean-plugin</artifactId>
41+
<version>3.1.0</version>
42+
<executions>
43+
<execution>
44+
<id>auto-clean</id>
45+
<phase>initialize</phase>
46+
<goals>
47+
<goal>clean</goal>
48+
</goals>
49+
</execution>
50+
</executions>
51+
</plugin>
4052
<plugin>
4153
<groupId>org.apache.maven.plugins</groupId>
4254
<artifactId>maven-compiler-plugin</artifactId>
@@ -115,5 +127,10 @@
115127
<version>2.2.1</version>
116128
<scope>compile</scope>
117129
</dependency>
130+
<dependency>
131+
<groupId>lol.hyper</groupId>
132+
<artifactId>github-release-api</artifactId>
133+
<version>1.0.0</version>
134+
</dependency>
118135
</dependencies>
119136
</project>

src/main/java/lol/hyper/partychat/PartyChat.java

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package lol.hyper.partychat;
1919

20+
import lol.hyper.githubreleaseapi.GitHubRelease;
21+
import lol.hyper.githubreleaseapi.GitHubReleaseAPI;
2022
import lol.hyper.partychat.commands.CommandParty;
2123
import lol.hyper.partychat.commands.CommandPartyChatMessage;
2224
import lol.hyper.partychat.tools.PartyManagement;
@@ -28,6 +30,7 @@
2830
import org.bukkit.plugin.java.JavaPlugin;
2931

3032
import java.io.File;
33+
import java.io.IOException;
3134
import java.nio.file.Path;
3235
import java.nio.file.Paths;
3336
import java.util.logging.Logger;
@@ -50,7 +53,7 @@ public void onEnable() {
5053
this.getCommand("party").setExecutor(commandParty);
5154
this.getCommand("pc").setExecutor(commandPartyChatMessage);
5255

53-
Metrics metrics = new Metrics(this, 10306);
56+
new Metrics(this, 10306);
5457

5558
if (!partyFolder.toFile().exists()) {
5659
if (!partyFolder.toFile().mkdirs()) {
@@ -60,22 +63,30 @@ public void onEnable() {
6063
logger.info("Creating parties folder for data storage.");
6164
}
6265
}
66+
67+
Bukkit.getScheduler().runTaskAsynchronously(this, this::checkForUpdates);
6368
}
6469

65-
/**
66-
* @param player player to check if vanished
67-
* @return returns if player is vanished or not
68-
*/
69-
public boolean isVanished(String player) {
70-
if (Bukkit.getPlayerExact(player) == null) {
71-
return false;
70+
public void checkForUpdates() {
71+
GitHubReleaseAPI api;
72+
try {
73+
api = new GitHubReleaseAPI("PartyChat", "hyperdefined");
74+
} catch (IOException e) {
75+
logger.warning("Unable to check updates!");
76+
e.printStackTrace();
77+
return;
78+
}
79+
GitHubRelease current = api.getReleaseByTag(this.getDescription().getVersion());
80+
GitHubRelease latest = api.getLatestVersion();
81+
if (current == null) {
82+
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!");
83+
return;
84+
}
85+
int buildsBehind = api.getBuildsBehind(current);
86+
if (buildsBehind == 0) {
87+
logger.info("You are running the latest version.");
7288
} else {
73-
Player player2 = Bukkit.getPlayerExact(player);
74-
assert player2 != null;
75-
for (MetadataValue meta : player2.getMetadata("vanished")) {
76-
if (meta.asBoolean()) return true;
77-
}
89+
logger.warning("A new version is available (" + latest.getTagVersion() + ")! You are running version " + current.getTagVersion() + ". You are " + buildsBehind + " version(s) behind.");
7890
}
79-
return false;
8091
}
8192
}

0 commit comments

Comments
 (0)