Skip to content

Commit

Permalink
Add support for pre-release versions of the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jmshal committed Feb 24, 2016
1 parent c884c36 commit 1662e64
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 67 deletions.
1 change: 1 addition & 0 deletions MelooonCensor.iml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
<orderEntry type="library" name="Maven: org.mcstats.bukkit:metrics:R8-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.bugsnag:bugsnag:1.3.0" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20151123" level="project" />
<orderEntry type="library" name="Maven: com.github.zafarkhaja:java-semver:0.9.0" level="project" />
</component>
</module>
5 changes: 5 additions & 0 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<include>org.mcstats.*:*</include>
<include>com.bugsnag:*</include>
<include>org.json:*</include>
<include>com.github.zafarkhaja:*</include>
</includes>
</artifactSet>
<relocations>
Expand All @@ -51,6 +52,10 @@
<pattern>org.json</pattern>
<shadedPattern>io.github.jacobmarshall.meloooncensor.lib.org.json</shadedPattern>
</relocation>
<relocation>
<pattern>com.github.zafarkhaja.semver</pattern>
<shadedPattern>io.github.jacobmarshall.meloooncensor.lib.com.github.zafarkhaja.semver</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
Expand Down
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<include>org.mcstats.*:*</include>
<include>com.bugsnag:*</include>
<include>org.json:*</include>
<include>com.github.zafarkhaja:*</include>
</includes>
</artifactSet>
<relocations>
Expand All @@ -49,6 +50,10 @@
<pattern>org.json</pattern>
<shadedPattern>io.github.jacobmarshall.meloooncensor.lib.org.json</shadedPattern>
</relocation>
<relocation>
<pattern>com.github.zafarkhaja.semver</pattern>
<shadedPattern>io.github.jacobmarshall.meloooncensor.lib.com.github.zafarkhaja.semver</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
Expand Down Expand Up @@ -111,6 +116,11 @@
<artifactId>json</artifactId>
<version>20151123</version>
</dependency>
<dependency>
<groupId>com.github.zafarkhaja</groupId>
<artifactId>java-semver</artifactId>
<version>0.9.0</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ public PlayerJoinEventListener (MelooonCensor plugin, CheckForUpdatesTask update
public void onPlayerJoin (PlayerJoinEvent event) {
Player player = event.getPlayer();

if (player.isOp() && updater.isUpdateAvailable()) {
Release release = updater.getLatestRelease();
player.sendMessage(ChatColor.GRAY + "You're currently running MelooonCensor v" + plugin.getDescription().getVersion() + ", which is currently not the latest version.");
if (release.hasSummary()) player.sendMessage(ChatColor.GRAY + release.getSummary());
if (player.isOp()) {
if (updater.isUpdateAvailable()) {
Release release = updater.getLatestRelease();
player.sendMessage(ChatColor.GRAY + "You're currently running MelooonCensor v" + plugin.getDescription().getVersion() + ", which is currently not the latest version.");
if (release.hasSummary()) player.sendMessage(ChatColor.GRAY + release.getSummary());
} else if (updater.isRunningPreRelease()) {
player.sendMessage(ChatColor.RED +
"You're currently running a pre-release version of MelooonCensor." +
"If you encounter any bugs or issues, please report them. " +
"This pre-release has been compiled for development/evaluation purposes ONLY.");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.jacobmarshall.meloooncensor.updater;

import com.bugsnag.Client;
import com.github.zafarkhaja.semver.Version;
import io.github.jacobmarshall.meloooncensor.MelooonCensor;
import org.json.JSONArray;

Expand All @@ -22,11 +23,13 @@ public class CheckForUpdatesTask implements Runnable {

private boolean isOutdated;
private Release latestRelease;
private boolean isRunningPreRelease;

public CheckForUpdatesTask (MelooonCensor plugin, Client bugsnag) {
this.plugin = plugin;
this.bugsnag = bugsnag;
this.version = new Version(plugin.getDescription().getVersion());
this.version = Version.valueOf(plugin.getDescription().getVersion());
this.isRunningPreRelease = this.version.getPreReleaseVersion() != null;
}

@Override
Expand All @@ -45,7 +48,7 @@ public void run () {
Release release = Release.from(releases.getJSONObject(index));

if ( ! release.isPreRelease()) {
Version releaseVersion = new Version(release.getVersion());
Version releaseVersion = Version.valueOf(release.getVersion());

if (releaseVersion.compareTo(version) > 0) {
isOutdated = true;
Expand Down Expand Up @@ -117,4 +120,8 @@ public Release getLatestRelease () {
return latestRelease;
}

public boolean isRunningPreRelease () {
return isRunningPreRelease;
}

}

This file was deleted.

0 comments on commit 1662e64

Please sign in to comment.