diff --git a/Plan/bukkit/src/main/java/com/djrapitops/plan/modules/bukkit/BukkitTaskModule.java b/Plan/bukkit/src/main/java/com/djrapitops/plan/modules/bukkit/BukkitTaskModule.java
index 1a496dde1..052d8ed05 100644
--- a/Plan/bukkit/src/main/java/com/djrapitops/plan/modules/bukkit/BukkitTaskModule.java
+++ b/Plan/bukkit/src/main/java/com/djrapitops/plan/modules/bukkit/BukkitTaskModule.java
@@ -29,6 +29,7 @@ import com.djrapitops.plan.gathering.timed.ServerTPSCounter;
import com.djrapitops.plan.gathering.timed.SystemUsageBuffer;
import com.djrapitops.plan.settings.upkeep.ConfigStoreTask;
import com.djrapitops.plan.storage.upkeep.DBCleanTask;
+import com.djrapitops.plan.storage.upkeep.ExtensionDisableOnGameServerTask;
import com.djrapitops.plan.storage.upkeep.LogsFolderCleanTask;
import com.djrapitops.plan.storage.upkeep.OldDependencyCacheDeletionTask;
import dagger.Binds;
@@ -98,4 +99,8 @@ public interface BukkitTaskModule {
@Binds
@IntoSet
TaskSystem.Task bindActiveCookieStoreExpiryTask(ActiveCookieExpiryCleanupTask activeCookieExpiryCleanupTask);
+
+ @Binds
+ @IntoSet
+ TaskSystem.Task bindExtensionDisableOnGameServerTask(ExtensionDisableOnGameServerTask extensionDisableOnGameServerTask);
}
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/queries/HasExtensionDataForPluginQuery.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/queries/HasExtensionDataForPluginQuery.java
new file mode 100644
index 000000000..2c9d66a0d
--- /dev/null
+++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/queries/HasExtensionDataForPluginQuery.java
@@ -0,0 +1,66 @@
+/*
+ * This file is part of Player Analytics (Plan).
+ *
+ * Plan is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License v3 as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plan is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Plan. If not, see .
+ */
+package com.djrapitops.plan.extension.implementation.storage.queries;
+
+import com.djrapitops.plan.identification.ServerUUID;
+import com.djrapitops.plan.storage.database.queries.HasMoreThanZeroQueryStatement;
+import com.djrapitops.plan.storage.database.sql.tables.ExtensionPluginTable;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.Objects;
+
+import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
+
+public class HasExtensionDataForPluginQuery extends HasMoreThanZeroQueryStatement {
+
+ private final String pluginName;
+ private final ServerUUID serverUUID;
+
+ public HasExtensionDataForPluginQuery(String pluginName, ServerUUID serverUUID) {
+ super(sql());
+ this.pluginName = pluginName;
+ this.serverUUID = serverUUID;
+ }
+
+ private static String sql() {
+ return SELECT + "COUNT(1) as c" +
+ FROM + ExtensionPluginTable.TABLE_NAME +
+ WHERE + ExtensionPluginTable.PLUGIN_NAME + "=?" +
+ AND + ExtensionPluginTable.SERVER_UUID + "=?";
+ }
+
+ @Override
+ public void prepare(PreparedStatement statement) throws SQLException {
+ statement.setString(1, pluginName);
+ statement.setString(2, serverUUID.toString());
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ if (!super.equals(o)) return false;
+ HasExtensionDataForPluginQuery that = (HasExtensionDataForPluginQuery) o;
+ return Objects.equals(pluginName, that.pluginName) && Objects.equals(serverUUID, that.serverUUID);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), pluginName, serverUUID);
+ }
+}
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/config/ExtensionSettings.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/config/ExtensionSettings.java
index af42794a6..c415eb721 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/settings/config/ExtensionSettings.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/config/ExtensionSettings.java
@@ -58,6 +58,10 @@ public class ExtensionSettings {
return section.getBoolean(pluginName + ".Enabled");
}
+ public void setEnabled(String pluginName, boolean value) {
+ getPluginsSection().set(pluginName + ".Enabled", value);
+ }
+
public Set getDisabled() {
ConfigNode section = getPluginsSection();
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/upkeep/ExtensionDisableOnGameServerTask.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/upkeep/ExtensionDisableOnGameServerTask.java
new file mode 100644
index 000000000..0d8d8fc10
--- /dev/null
+++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/upkeep/ExtensionDisableOnGameServerTask.java
@@ -0,0 +1,76 @@
+/*
+ * This file is part of Player Analytics (Plan).
+ *
+ * Plan is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License v3 as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plan is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Plan. If not, see .
+ */
+package com.djrapitops.plan.storage.upkeep;
+
+import com.djrapitops.plan.TaskSystem;
+import com.djrapitops.plan.extension.implementation.storage.queries.HasExtensionDataForPluginQuery;
+import com.djrapitops.plan.identification.Server;
+import com.djrapitops.plan.identification.ServerUUID;
+import com.djrapitops.plan.settings.config.ExtensionSettings;
+import com.djrapitops.plan.settings.config.PlanConfig;
+import com.djrapitops.plan.storage.database.DBSystem;
+import com.djrapitops.plan.storage.database.Database;
+import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
+import net.playeranalytics.plugin.scheduling.RunnableFactory;
+import net.playeranalytics.plugin.server.PluginLogger;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+@Singleton
+public class ExtensionDisableOnGameServerTask extends TaskSystem.Task {
+
+ private final PlanConfig config;
+ private final DBSystem dbSystem;
+ private final PluginLogger logger;
+
+ @Inject
+ public ExtensionDisableOnGameServerTask(PlanConfig config, DBSystem dbSystem, PluginLogger logger) {
+ this.config = config;
+ this.dbSystem = dbSystem;
+ this.logger = logger;
+ }
+
+ @Override
+ public void register(RunnableFactory runnableFactory) {
+ runnableFactory.create(this).runTaskAsynchronously();
+ }
+
+ @Override
+ public void run() {
+ String pluginName = "Litebans";
+ checkAndDisableProxyExtensions(pluginName);
+ }
+
+ private void checkAndDisableProxyExtensions(String pluginName) {
+ Database db = dbSystem.getDatabase();
+ db.query(ServerQueries.fetchProxyServerInformation())
+ .map(Server::getUuid)
+ .ifPresent(proxyUUID -> checkAndDisableProxyExtension(proxyUUID, pluginName));
+ }
+
+ private void checkAndDisableProxyExtension(ServerUUID proxyUUID, String pluginName) {
+ Database db = dbSystem.getDatabase();
+ ExtensionSettings extensionSettings = config.getExtensionSettings();
+
+ boolean isInstalledOnProxy = db.query(new HasExtensionDataForPluginQuery(pluginName, proxyUUID));
+ if (isInstalledOnProxy && extensionSettings.isEnabled(pluginName)) {
+ extensionSettings.setEnabled(pluginName, false);
+ logger.info("Set " + pluginName + " Extension as disabled in config since it is already enabled on the proxy server. This is to avoid duplicate data.");
+ }
+ }
+}