mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 11:15:51 +00:00
Add update warning to /sf versions (#4096)
This commit is contained in:
parent
da9c2ac4cc
commit
86fa6f8900
2
pom.xml
2
pom.xml
@ -349,7 +349,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.baked-libs.dough</groupId>
|
||||
<artifactId>dough-api</artifactId>
|
||||
<version>fcdbd45aa0</version>
|
||||
<version>1108163a49</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -65,11 +65,25 @@ class VersionsCommand extends SubCommand {
|
||||
.append(serverSoftware)
|
||||
.color(ChatColor.GREEN)
|
||||
.append(" " + Bukkit.getVersion() + '\n')
|
||||
.color(ChatColor.DARK_GREEN)
|
||||
.color(ChatColor.DARK_GREEN);
|
||||
|
||||
builder
|
||||
.append("Slimefun ")
|
||||
.color(ChatColor.GREEN)
|
||||
.append(Slimefun.getVersion() + '\n')
|
||||
.append(Slimefun.getVersion())
|
||||
.color(ChatColor.DARK_GREEN);
|
||||
if (!Slimefun.getUpdater().isLatestVersion()) {
|
||||
builder
|
||||
.append(" (").color(ChatColor.GRAY)
|
||||
.append("Update available").color(ChatColor.RED).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
||||
"Your Slimefun version is out of date!\n" +
|
||||
"Please update to get the latest bug fixes and performance improvements.\n" +
|
||||
"Please do not report any bugs without updating first."
|
||||
)))
|
||||
.append(")").color(ChatColor.GRAY);
|
||||
}
|
||||
|
||||
builder.append("\n");
|
||||
// @formatter:on
|
||||
|
||||
if (Slimefun.getMetricsService().getVersion() != null) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.services;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -110,6 +111,29 @@ public class UpdaterService {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getLatestVersion() {
|
||||
if (updater != null && updater.getLatestVersion().isDone()) {
|
||||
PrefixedVersion version;
|
||||
try {
|
||||
version = updater.getLatestVersion().get();
|
||||
return version.getVersionNumber();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean isLatestVersion() {
|
||||
if (getBuildNumber() == -1 || getLatestVersion() == -1) {
|
||||
// We don't know if we're latest so just report we are
|
||||
return true;
|
||||
}
|
||||
|
||||
return getBuildNumber() == getLatestVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* This will start the {@link UpdaterService} and check for updates.
|
||||
* If it can find an update it will automatically be installed.
|
||||
|
Loading…
Reference in New Issue
Block a user