mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 01:27:37 +00:00
Set different verbosity levels for the update messages
This commit is contained in:
parent
294f8db528
commit
898dace3c1
@ -38,7 +38,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, true, true);
|
plugin.getUpdateChecker().getUpdateStatusMessage(sender, true, 2);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("reload"))
|
if (args[0].equalsIgnoreCase("reload"))
|
||||||
@ -95,7 +95,7 @@ public class PlexCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
return messageComponent("noPermissionRank", "a developer");
|
return messageComponent("noPermissionRank", "a developer");
|
||||||
}
|
}
|
||||||
if (!plugin.getUpdateChecker().getUpdateStatusMessage(sender, false, false))
|
if (!plugin.getUpdateChecker().getUpdateStatusMessage(sender, false, 0))
|
||||||
{
|
{
|
||||||
return mmString("<red>Plex is already up to date!");
|
return mmString("<red>Plex is already up to date!");
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class UpdateCheckerService extends AbstractService
|
|||||||
{
|
{
|
||||||
if (!newVersion)
|
if (!newVersion)
|
||||||
{
|
{
|
||||||
if (plugin.getUpdateChecker().getUpdateStatusMessage(Bukkit.getConsoleSender(), false, false))
|
if (plugin.getUpdateChecker().getUpdateStatusMessage(Bukkit.getConsoleSender(), false, 1))
|
||||||
{
|
{
|
||||||
newVersion = true;
|
newVersion = true;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,10 @@ public class UpdateChecker extends PlexBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getUpdateStatusMessage(CommandSender sender, boolean cached, boolean verbose)
|
// If verbose is 0, it will display nothing
|
||||||
|
// If verbose is 1, it will only display a message if there is an update available
|
||||||
|
// If verbose is 2, it will display all messages
|
||||||
|
public boolean getUpdateStatusMessage(CommandSender sender, boolean cached, int verbosity)
|
||||||
{
|
{
|
||||||
if (branch == null)
|
if (branch == null)
|
||||||
{
|
{
|
||||||
@ -112,30 +115,33 @@ public class UpdateChecker extends PlexBase
|
|||||||
switch (distance)
|
switch (distance)
|
||||||
{
|
{
|
||||||
case -1 -> {
|
case -1 -> {
|
||||||
if (verbose)
|
if (verbosity == 2)
|
||||||
{
|
{
|
||||||
sender.sendMessage(Component.text("There was an error checking for updates.").color(NamedTextColor.RED));
|
sender.sendMessage(Component.text("There was an error checking for updates.").color(NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case 0 -> {
|
case 0 -> {
|
||||||
if (verbose)
|
if (verbosity == 2)
|
||||||
{
|
{
|
||||||
sender.sendMessage(Component.text("Your version of Plex is up to date!").color(NamedTextColor.GREEN));
|
sender.sendMessage(Component.text("Plex is up to date!").color(NamedTextColor.GREEN));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case -2 -> {
|
case -2 -> {
|
||||||
if (verbose)
|
if (verbosity == 2)
|
||||||
{
|
{
|
||||||
sender.sendMessage(Component.text("Unknown version, unable to check for updates.").color(NamedTextColor.RED));
|
sender.sendMessage(Component.text("Unknown version, unable to check for updates.").color(NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
sender.sendMessage(Component.text("Your version of Plex is not up to date!", NamedTextColor.RED));
|
if (verbosity >= 1)
|
||||||
sender.sendMessage(Component.text("Download a new version at: " + DOWNLOAD_PAGE).color(NamedTextColor.RED));
|
{
|
||||||
sender.sendMessage(Component.text("Or run: /plex update").color(NamedTextColor.RED));
|
sender.sendMessage(Component.text("Plex is not up to date!", NamedTextColor.RED));
|
||||||
|
sender.sendMessage(Component.text("Download a new version at: " + DOWNLOAD_PAGE).color(NamedTextColor.RED));
|
||||||
|
sender.sendMessage(Component.text("Or run: /plex update").color(NamedTextColor.RED));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user