mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 01:27:37 +00:00
Attempt to fix updater
This commit is contained in:
parent
ca18b12164
commit
eaa40e7013
@ -40,7 +40,7 @@ public class PlexCMD extends PlexCommand
|
||||
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>Run <gold>/plex modules <light_purple>to see a list of modules."));
|
||||
plugin.getUpdateChecker().getUpdateStatusMessage(sender, true);
|
||||
plugin.getUpdateChecker().getUpdateStatusMessage(sender, true, true);
|
||||
return null;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reload"))
|
||||
@ -88,7 +88,7 @@ public class PlexCMD extends PlexCommand
|
||||
plugin.getModuleManager().loadAllModules();
|
||||
plugin.getModuleManager().loadModules();
|
||||
plugin.getModuleManager().enableModules();
|
||||
return componentFromString("All modules reloaded!");
|
||||
return mmString("<green>All modules reloaded!");
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("update"))
|
||||
@ -97,9 +97,9 @@ public class PlexCMD extends PlexCommand
|
||||
{
|
||||
return messageComponent("noPermissionConsole");
|
||||
}
|
||||
if (!plugin.getUpdateChecker().getUpdateStatus(false))
|
||||
if (!plugin.getUpdateChecker().getUpdateStatusMessage(sender, false, false))
|
||||
{
|
||||
return MiniMessage.miniMessage().deserialize("<red>Plex is already up to date!");
|
||||
return mmString("<red>Plex is already up to date!");
|
||||
}
|
||||
plugin.getUpdateChecker().updateJar();
|
||||
return null;
|
||||
|
@ -47,11 +47,13 @@ public class ServiceManager
|
||||
{
|
||||
BukkitTask task = Bukkit.getScheduler().runTask(Plex.get(), service::run);
|
||||
service.setTaskId(task.getTaskId());
|
||||
} else if (service.isRepeating() && service.isAsynchronous())
|
||||
}
|
||||
else if (service.isRepeating() && service.isAsynchronous())
|
||||
{
|
||||
BukkitTask task = Bukkit.getScheduler().runTaskTimerAsynchronously(Plex.get(), service::run, 0, 20L * service.repeatInSeconds());
|
||||
service.setTaskId(task.getTaskId());
|
||||
} else if (service.isRepeating() && !service.isAsynchronous())
|
||||
}
|
||||
else if (service.isRepeating() && !service.isAsynchronous())
|
||||
{
|
||||
BukkitTask task = Bukkit.getScheduler().runTaskTimer(Plex.get(), service::run, 0, 20L * service.repeatInSeconds());
|
||||
service.setTaskId(task.getTaskId());
|
||||
|
@ -17,7 +17,7 @@ public class UpdateCheckerService extends AbstractService
|
||||
{
|
||||
if (!newVersion)
|
||||
{
|
||||
if (plugin.getUpdateChecker().getUpdateStatusMessage(Bukkit.getConsoleSender(), false))
|
||||
if (plugin.getUpdateChecker().getUpdateStatusMessage(Bukkit.getConsoleSender(), false, false))
|
||||
{
|
||||
newVersion = true;
|
||||
}
|
||||
|
@ -80,45 +80,7 @@ public class UpdateChecker extends PlexBase
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getUpdateStatus(boolean cached)
|
||||
{
|
||||
if (distance == -4)
|
||||
{
|
||||
distance = fetchDistanceFromGitHub("plexusorg/Plex", "master", Plex.build.head);
|
||||
PlexLog.debug("Never checked for updates, checking now...");
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the request isn't asked to be cached, fetch it
|
||||
if (!cached)
|
||||
{
|
||||
distance = fetchDistanceFromGitHub("plexusorg/Plex", "master", Plex.build.head);
|
||||
PlexLog.debug("We have checked for updates before, but this request was not asked to be cached.");
|
||||
}
|
||||
else
|
||||
{
|
||||
PlexLog.debug("We have checked for updates before, using cache.");
|
||||
}
|
||||
}
|
||||
|
||||
switch (distance)
|
||||
{
|
||||
case -1 -> {
|
||||
return false;
|
||||
}
|
||||
case 0 -> {
|
||||
return false;
|
||||
}
|
||||
case -2 -> {
|
||||
return false;
|
||||
}
|
||||
default -> {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getUpdateStatusMessage(CommandSender sender, boolean cached)
|
||||
public boolean getUpdateStatusMessage(CommandSender sender, boolean cached, boolean verbose)
|
||||
{
|
||||
// If it's -4, it hasn't checked for updates yet
|
||||
if (distance == -4)
|
||||
@ -143,15 +105,24 @@ public class UpdateChecker extends PlexBase
|
||||
switch (distance)
|
||||
{
|
||||
case -1 -> {
|
||||
sender.sendMessage(Component.text("There was an error checking for updates.").color(NamedTextColor.RED));
|
||||
if (verbose)
|
||||
{
|
||||
sender.sendMessage(Component.text("There was an error checking for updates.").color(NamedTextColor.RED));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case 0 -> {
|
||||
sender.sendMessage(Component.text("Your version of Plex is up to date!").color(NamedTextColor.GREEN));
|
||||
if (verbose)
|
||||
{
|
||||
sender.sendMessage(Component.text("Your version of Plex is up to date!").color(NamedTextColor.GREEN));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case -2 -> {
|
||||
sender.sendMessage(Component.text("Unknown version, unable to check for updates.").color(NamedTextColor.RED));
|
||||
if (verbose)
|
||||
{
|
||||
sender.sendMessage(Component.text("Unknown version, unable to check for updates.").color(NamedTextColor.RED));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
default -> {
|
||||
|
Loading…
Reference in New Issue
Block a user