From 3805d433f9546a92ce68eff8df458c35dfce45a2 Mon Sep 17 00:00:00 2001 From: RayzsYT <51991564+RayzsYT@users.noreply.github.com> Date: Tue, 25 Feb 2025 16:21:58 +0100 Subject: [PATCH] Add "disable sync" option --- .../de/rayzs/pat/api/storage/Storage.java | 1 + .../config/settings/DisableSyncSection.java | 22 +++++++++++++++++++ .../de/rayzs/pat/plugin/BungeeLoader.java | 4 +++- .../de/rayzs/pat/plugin/VelocityLoader.java | 4 +++- src/main/resources/files/proxy-config.yml | 4 ++++ 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/rayzs/pat/api/storage/config/settings/DisableSyncSection.java diff --git a/src/main/java/de/rayzs/pat/api/storage/Storage.java b/src/main/java/de/rayzs/pat/api/storage/Storage.java index 7dcdf724..46f4775b 100644 --- a/src/main/java/de/rayzs/pat/api/storage/Storage.java +++ b/src/main/java/de/rayzs/pat/api/storage/Storage.java @@ -114,6 +114,7 @@ public class Storage { public static CancelCommandSection CANCEL_COMMAND = new CancelCommandSection(); public static CustomPluginsSection CUSTOM_PLUGIN = new CustomPluginsSection(); public static CustomVersionSection CUSTOM_VERSION = new CustomVersionSection(); + public static DisableSyncSection DISABLE_SYNC = new DisableSyncSection(); public static CustomProtocolPingSection CUSTOM_PROTOCOL_PING = new CustomProtocolPingSection(); public static CustomUnknownCommandSection CUSTOM_UNKNOWN_COMMAND = new CustomUnknownCommandSection(); public static TurnBlacklistToWhitelistSection TURN_BLACKLIST_TO_WHITELIST = new TurnBlacklistToWhitelistSection(); diff --git a/src/main/java/de/rayzs/pat/api/storage/config/settings/DisableSyncSection.java b/src/main/java/de/rayzs/pat/api/storage/config/settings/DisableSyncSection.java new file mode 100644 index 00000000..fed97878 --- /dev/null +++ b/src/main/java/de/rayzs/pat/api/storage/config/settings/DisableSyncSection.java @@ -0,0 +1,22 @@ +package de.rayzs.pat.api.storage.config.settings; + +import de.rayzs.pat.utils.Reflection; +import de.rayzs.pat.api.storage.storages.ConfigStorage; +import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; + +public class DisableSyncSection extends ConfigStorage { + + public boolean DISABLED; + + public DisableSyncSection() { + super("disable-sync"); + } + + @Override + public void load() { + super.load(); + + if(!Reflection.isProxyServer()) return; + DISABLED = new ConfigSectionHelper(this, null, false).getOrSet(); + } +} diff --git a/src/main/java/de/rayzs/pat/plugin/BungeeLoader.java b/src/main/java/de/rayzs/pat/plugin/BungeeLoader.java index ec3691c4..a561649b 100644 --- a/src/main/java/de/rayzs/pat/plugin/BungeeLoader.java +++ b/src/main/java/de/rayzs/pat/plugin/BungeeLoader.java @@ -71,7 +71,9 @@ public class BungeeLoader extends Plugin { manager.registerListener(this, new WaterfallAntiTabListener()); startUpdaterTask(); - ProxyServer.getInstance().getScheduler().schedule(this, Communicator::syncData, 5, TimeUnit.SECONDS); + + if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) + ProxyServer.getInstance().getScheduler().schedule(this, Communicator::syncData, 5, TimeUnit.SECONDS); Storage.PLUGIN_OBJECT = this; diff --git a/src/main/java/de/rayzs/pat/plugin/VelocityLoader.java b/src/main/java/de/rayzs/pat/plugin/VelocityLoader.java index f16e2ddd..51952db0 100644 --- a/src/main/java/de/rayzs/pat/plugin/VelocityLoader.java +++ b/src/main/java/de/rayzs/pat/plugin/VelocityLoader.java @@ -89,7 +89,9 @@ public class VelocityLoader { server.getEventManager().register(this, new VelocityPingListener(server)); startUpdaterTask(); - server.getScheduler().buildTask(this, Communicator::syncData).delay(5, TimeUnit.SECONDS).schedule(); + + if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) + server.getScheduler().buildTask(this, Communicator::syncData).delay(5, TimeUnit.SECONDS).schedule(); Storage.PLUGIN_OBJECT = this; diff --git a/src/main/resources/files/proxy-config.yml b/src/main/resources/files/proxy-config.yml index 12361b44..35554ab5 100644 --- a/src/main/resources/files/proxy-config.yml +++ b/src/main/resources/files/proxy-config.yml @@ -20,6 +20,10 @@ updater: - '&8[&4PAT &7| &4Proxy&8] &cGet the newest version here:' - '&8[&4PAT &7| &4Proxy&8] &ehttps://www.rayzs.de/products/proantitab/page' +# If this value is set to true, the proxy won't communicate with the backend servers anymore. +# Not recommended to change this value until you know what you are doing. +disable-sync: false + # This is a very necessary feature if you have way too many commands to block and instead decide # to whitelist specific commands. # Enabling this will disable ALL commands except for those that are in the (group-)list.