mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 01:27:37 +00:00
Make update checking better
This commit is contained in:
parent
9ebbeb3c15
commit
48fb4f919a
@ -35,6 +35,7 @@ public class PlexCMD extends PlexCommand
|
|||||||
send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh"));
|
send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh"));
|
||||||
send(sender, mmString("<light_purple>Built by: <gold>" + Plex.build.author + " <light_purple>on <gold>" + Plex.build.date));
|
send(sender, mmString("<light_purple>Built by: <gold>" + Plex.build.author + " <light_purple>on <gold>" + Plex.build.date));
|
||||||
send(sender, mmString("<light_purple>Run <gold>/plex modules <light_purple>to see a list of modules."));
|
send(sender, mmString("<light_purple>Run <gold>/plex modules <light_purple>to see a list of modules."));
|
||||||
|
plugin.getUpdateChecker().getUpdateStatusMessage(sender);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("reload"))
|
if (args[0].equalsIgnoreCase("reload"))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.plex.services.impl;
|
package dev.plex.services.impl;
|
||||||
|
|
||||||
import dev.plex.services.AbstractService;
|
import dev.plex.services.AbstractService;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class UpdateCheckerService extends AbstractService
|
public class UpdateCheckerService extends AbstractService
|
||||||
{
|
{
|
||||||
@ -16,7 +17,7 @@ public class UpdateCheckerService extends AbstractService
|
|||||||
{
|
{
|
||||||
if (!newVersion)
|
if (!newVersion)
|
||||||
{
|
{
|
||||||
if (plugin.getUpdateChecker().getUpdateStatusMessage("plexusorg/Plex", "master"))
|
if (plugin.getUpdateChecker().getUpdateStatusMessage(Bukkit.getConsoleSender()))
|
||||||
{
|
{
|
||||||
newVersion = true;
|
newVersion = true;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import java.net.URL;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class UpdateChecker extends PlexBase
|
public class UpdateChecker extends PlexBase
|
||||||
{
|
{
|
||||||
@ -55,30 +55,29 @@ public class UpdateChecker extends PlexBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch)
|
public boolean getUpdateStatusMessage(CommandSender sender)
|
||||||
{
|
{
|
||||||
int distance;
|
int distance;
|
||||||
distance = fetchDistanceFromGitHub(repo, branch, Plex.build.head);
|
distance = fetchDistanceFromGitHub("plexusorg/Plex", "master", Plex.build.head);
|
||||||
|
|
||||||
switch (distance)
|
switch (distance)
|
||||||
{
|
{
|
||||||
case -1 -> {
|
case -1 -> {
|
||||||
PlexLog.log(ChatColor.RED + "There was an error checking for updates.");
|
sender.sendMessage(Component.text("There was an error checking for updates.").color(NamedTextColor.RED));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case 0 -> {
|
case 0 -> {
|
||||||
PlexLog.log(ChatColor.GREEN + "Your version of Plex is up to date!");
|
sender.sendMessage(Component.text("Your version of Plex is up to date!").color(NamedTextColor.GREEN));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case -2 -> {
|
case -2 -> {
|
||||||
PlexLog.log(ChatColor.RED + "Unknown version, unable to check for updates.");
|
sender.sendMessage(Component.text("Unknown version, unable to check for updates.").color(NamedTextColor.RED));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
PlexLog.log(Component.text("Your version of Plex is not up to date!", NamedTextColor.RED)
|
sender.sendMessage(Component.text("Your version of Plex is not up to date!", NamedTextColor.RED));
|
||||||
.append(Component.newline())
|
sender.sendMessage(Component.text("Download a new version at: ")
|
||||||
.append(Component.text("Download the new version at: ")
|
.append(Component.text(DOWNLOAD_PAGE, NamedTextColor.RED)));
|
||||||
.append(Component.text(DOWNLOAD_PAGE, NamedTextColor.RED))));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user