From 688f3886a37b92f2ade65003cb5003e4f7f93589 Mon Sep 17 00:00:00 2001 From: UserNugget Date: Fri, 18 Oct 2024 20:48:21 +0300 Subject: [PATCH] Add config option to disable updates checker Fixes #44 --- .../java/net/elytrium/velocitytools/Settings.java | 3 +++ .../net/elytrium/velocitytools/VelocityTools.java | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/elytrium/velocitytools/Settings.java b/src/main/java/net/elytrium/velocitytools/Settings.java index c0c5980..dcfb69a 100644 --- a/src/main/java/net/elytrium/velocitytools/Settings.java +++ b/src/main/java/net/elytrium/velocitytools/Settings.java @@ -47,6 +47,9 @@ public class Settings extends YamlSerializable { public static class MAIN { + @Comment(@CommentValue("Should this plugin check for new updates?")) + public boolean CHECK_FOR_UPDATES = true; + @Comment({ @CommentValue("VelocityTools will consume more RAM if this option is enabled, but compatibility with other plugins will be better"), @CommentValue("Enable it if you have a plugin installed that bypasses compression (e.g. Geyser)") diff --git a/src/main/java/net/elytrium/velocitytools/VelocityTools.java b/src/main/java/net/elytrium/velocitytools/VelocityTools.java index 60fd638..30cd9f9 100644 --- a/src/main/java/net/elytrium/velocitytools/VelocityTools.java +++ b/src/main/java/net/elytrium/velocitytools/VelocityTools.java @@ -120,11 +120,15 @@ public void onProxyInitialization(ProxyInitializeEvent event) { HooksInitializer.init(this.server); - if (!UpdatesChecker.checkVersionByURL("https://raw.githubusercontent.com/Elytrium/VelocityTools/master/VERSION", Settings.IMP.VERSION)) { - LOGGER.error("****************************************"); - LOGGER.warn("The new VelocityTools update was found, please update."); - LOGGER.error("https://github.com/Elytrium/VelocityTools/releases/"); - LOGGER.error("****************************************"); + if (Settings.IMP.MAIN.CHECK_FOR_UPDATES) { + this.server.getScheduler().buildTask(this, () -> { + if (!UpdatesChecker.checkVersionByURL("https://raw.githubusercontent.com/Elytrium/VelocityTools/master/VERSION", Settings.IMP.VERSION)) { + LOGGER.error("****************************************"); + LOGGER.warn("The new VelocityTools update was found, please update."); + LOGGER.error("https://github.com/Elytrium/VelocityTools/releases/"); + LOGGER.error("****************************************"); + } + }).schedule(); } this.metricsFactory.make(this, 12708); }