diff --git a/src/main/java/dev/plex/command/impl/PlexCMD.java b/src/main/java/dev/plex/command/impl/PlexCMD.java index 458060d..37c663a 100644 --- a/src/main/java/dev/plex/command/impl/PlexCMD.java +++ b/src/main/java/dev/plex/command/impl/PlexCMD.java @@ -35,6 +35,7 @@ public class PlexCMD extends PlexCommand send(sender, mmString("Authors: Telesphoreo, Taahh")); send(sender, mmString("Built by: " + Plex.build.author + " on " + Plex.build.date)); send(sender, mmString("Run /plex modules to see a list of modules.")); + plugin.getUpdateChecker().getUpdateStatusMessage(sender); return null; } if (args[0].equalsIgnoreCase("reload")) diff --git a/src/main/java/dev/plex/services/impl/UpdateCheckerService.java b/src/main/java/dev/plex/services/impl/UpdateCheckerService.java index a9c59c7..80815b6 100644 --- a/src/main/java/dev/plex/services/impl/UpdateCheckerService.java +++ b/src/main/java/dev/plex/services/impl/UpdateCheckerService.java @@ -1,6 +1,7 @@ package dev.plex.services.impl; import dev.plex.services.AbstractService; +import org.bukkit.Bukkit; public class UpdateCheckerService extends AbstractService { @@ -16,7 +17,7 @@ public class UpdateCheckerService extends AbstractService { if (!newVersion) { - if (plugin.getUpdateChecker().getUpdateStatusMessage("plexusorg/Plex", "master")) + if (plugin.getUpdateChecker().getUpdateStatusMessage(Bukkit.getConsoleSender())) { newVersion = true; } diff --git a/src/main/java/dev/plex/util/UpdateChecker.java b/src/main/java/dev/plex/util/UpdateChecker.java index 66cd2dd..454f84f 100644 --- a/src/main/java/dev/plex/util/UpdateChecker.java +++ b/src/main/java/dev/plex/util/UpdateChecker.java @@ -14,7 +14,7 @@ import java.net.URL; import javax.annotation.Nonnull; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; -import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; 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; - distance = fetchDistanceFromGitHub(repo, branch, Plex.build.head); + distance = fetchDistanceFromGitHub("plexusorg/Plex", "master", Plex.build.head); switch (distance) { 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; } 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; } 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; } default -> { - PlexLog.log(Component.text("Your version of Plex is not up to date!", NamedTextColor.RED) - .append(Component.newline()) - .append(Component.text("Download the new version at: ") - .append(Component.text(DOWNLOAD_PAGE, NamedTextColor.RED)))); + sender.sendMessage(Component.text("Your version of Plex is not up to date!", NamedTextColor.RED)); + sender.sendMessage(Component.text("Download a new version at: ") + .append(Component.text(DOWNLOAD_PAGE, NamedTextColor.RED))); return true; } }