Skip to content

Commit

Permalink
Added Version Comparator
Browse files Browse the repository at this point in the history
  • Loading branch information
beanbeanjuice committed May 29, 2024
1 parent 5b7a0a4 commit 983e0b8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
14 changes: 10 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group = "com.beanbeanjuice"
version = "0.4.2"
version = "0.5.0"

java {
sourceCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -101,6 +101,9 @@ dependencies {

// Timestamp
implementation("joda-time", "joda-time", "2.12.7")

// Artifact Version Comparison
implementation("org.apache.maven", "maven-artifact", "3.9.7")
}

configure<ProcessResources>("processResources") {
Expand Down Expand Up @@ -233,10 +236,13 @@ hangarPublish {
}

tasks.withType<ShadowJar> {
minimize()
relocate("dev.dejvokep.boostedyaml", "com.beanbeanjuice.simpleproxychat.libs.dev.dejvokep.boostedyaml")
relocate("org.bstats", "com.beanbeanjuice.simpleproxychat.libs.org.bstats")
relocate("net.kyori", "com.beanbeanjuice.simpleproxychat.libs.net.kyori")
relocate("net.dv8tion", "com.beanbeanjuice.simpleproxychat.libs.net.dv8tion")
relocate("dev.dejvokep", "com.beanbeanjuice.simpleproxychat.libs.dev.dejvokep")
relocate("org.bstats", "com.beanbeanjuice.simpleproxychat.libs.org.bstats")
relocate("joda-time", "com.beanbeanjuice.simpleproxychat.libs.joda-time")
relocate("org.apache.maven", "com.beanbeanjuice.simpleproxychat.libs.org.apache.maven")
minimize()
archiveBaseName.set(rootProject.name)
archiveClassifier.set("")
archiveVersion.set(version as String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ public void onEnable() {

// bStats Stuff
this.getLogger().info("Starting bStats... (IF ENABLED)");
int pluginId = 21146;
this.metrics = new Metrics(this, pluginId);
this.metrics = new Metrics(this, 21146);

startPluginMessaging();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) {

// bStats Stuff
this.getLogger().info("Starting bStats... (IF ENABLED)");
int pluginId = 21147;
this.metrics = metricsFactory.make(this, pluginId);
this.metrics = metricsFactory.make(this, 21147);

// Plugin has started.
this.getLogger().info("The plugin has been started.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.beanbeanjuice.simpleproxychat.utility.config.Config;
import com.beanbeanjuice.simpleproxychat.utility.config.ConfigDataKey;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -32,7 +33,7 @@ public Optional<String> getUpdate() {

public void checkUpdate() {
getUpdate().ifPresent((spigotVersion) -> {
if (currentVersion.equalsIgnoreCase(spigotVersion)) return;
if (compare(currentVersion, spigotVersion) >= 0) return;

String message = Helper.replaceKeys(
config.getAsString(ConfigDataKey.UPDATE_MESSAGE),
Expand All @@ -46,4 +47,11 @@ public void checkUpdate() {
});
}

public static int compare(final String version1, final String version2) {
DefaultArtifactVersion v1 = new DefaultArtifactVersion(version1);
DefaultArtifactVersion v2 = new DefaultArtifactVersion(version2);

return v1.compareTo(v2);
}

}

0 comments on commit 983e0b8

Please sign in to comment.