Add enable-updates config option

This commit is contained in:
Luna 2022-07-11 13:08:49 -03:00
parent 4a14f94158
commit 7f5e706d5e
4 changed files with 27 additions and 5 deletions

View File

@ -162,8 +162,11 @@ public class Plex extends PlexPlugin implements PlexApiProvider
this.setPermissionHandler(new NativePermissionHandler());
}
updateChecker = new UpdateChecker();
PlexLog.log("Update checking enabled");
if (config.getBoolean("enable-updates"))
{
updateChecker = new UpdateChecker();
PlexLog.log("Update checking enabled");
}
// https://bstats.org/plugin/bukkit/Plex/14143
Metrics metrics = new Metrics(this, 14143);

View File

@ -39,7 +39,10 @@ public class PlexCMD extends PlexCommand
send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh"));
send(sender, mmString("<light_purple>Built by: <gold>" + BuildInfo.getAuthor() + " <light_purple>on <gold>" + BuildInfo.getDate()));
send(sender, mmString("<light_purple>Run <gold>/plex modules <light_purple>to see a list of modules."));
plugin.getUpdateChecker().getUpdateStatusMessage(sender, true, 2);
if (plugin.config.getBoolean("enable-updates"))
{
plugin.getUpdateChecker().getUpdateStatusMessage(sender, true, 2);
}
return null;
}
if (args[0].equalsIgnoreCase("reload"))
@ -100,6 +103,10 @@ public class PlexCMD extends PlexCommand
{
return messageComponent("noPermissionRank", "an Owner or Developer");
}
if (!plugin.getConfig().getBoolean("enable-updates"))
{
return mmString("<red>Updating has been disabled in the config.");
}
for (PlexModule module : plugin.getModuleManager().getModules())
{
plugin.getUpdateChecker().updateJar(sender, module.getPlexModuleFile().getName(), true);
@ -114,6 +121,10 @@ public class PlexCMD extends PlexCommand
{
return messageComponent("noPermissionRank", "an Owner or Developer");
}
if (!plugin.getConfig().getBoolean("enable-updates"))
{
return mmString("<red>Updating has been disabled in the config.");
}
if (!plugin.getUpdateChecker().getUpdateStatusMessage(sender, false, 0))
{
return mmString("<red>Plex is already up to date!");

View File

@ -2,6 +2,7 @@ package dev.plex.services;
import com.google.common.collect.Lists;
import dev.plex.Plex;
import dev.plex.PlexBase;
import dev.plex.services.impl.AutoWipeService;
import dev.plex.services.impl.BanService;
import dev.plex.services.impl.CommandBlockerService;
@ -12,7 +13,7 @@ import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask;
public class ServiceManager
public class ServiceManager implements PlexBase
{
private final List<AbstractService> services = Lists.newArrayList();
@ -23,7 +24,11 @@ public class ServiceManager
registerService(new CommandBlockerService());
registerService(new GameRuleService());
registerService(new TimingService());
registerService(new UpdateCheckerService());
if (plugin.config.getBoolean("enable-updates"))
{
registerService(new UpdateCheckerService());
}
}
public void startServices()

View File

@ -225,6 +225,9 @@ worlds:
stone: 16
bedrock: 1
# Should the plugin should enable updating features?
enable-updates: true
# If you are running a custom fork of Plex, you may wish to check for updates from a different repository.
update_repo: "plexusorg/Plex"