Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update warning to /sf versions #4096

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,25 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) {
.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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -110,6 +111,29 @@ public int getBuildNumber() {
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.
Expand Down
Loading