From 268474d5caf6271681000a4286d485059c91c01d Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Tue, 21 Aug 2018 09:46:43 +0300 Subject: [PATCH] Added config settings for ping delays #691 --- .../java/com/djrapitops/plan/system/settings/Settings.java | 2 ++ .../plan/system/settings/network/NetworkSettings.java | 4 +++- .../com/djrapitops/plan/system/tasks/BukkitTaskSystem.java | 5 ++++- .../djrapitops/plan/system/tasks/server/PingCountTimer.java | 3 ++- Plan/src/main/resources/bungeeconfig.yml | 3 +++ Plan/src/main/resources/config.yml | 3 +++ 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java index 3a8d7e63f..0b283d009 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java @@ -52,6 +52,8 @@ public enum Settings { AFK_THRESHOLD_MINUTES("Data.AFKThresholdMinutes"), KEEP_LOGS_DAYS("Plugin.KeepLogsForXDays"), KEEP_INACTIVE_PLAYERS_DAYS("Data.KeepInactivePlayerDataForDays"), + PING_SERVER_ENABLE_DELAY("Data.Ping.ServerEnableDelaySeconds"), + PING_PLAYER_LOGIN_DELAY("Data.Ping.PlayerLoginDelaySeconds"), // String DEBUG("Plugin.Debug"), diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/network/NetworkSettings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/network/NetworkSettings.java index 7bc6990ad..985df52c5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/network/NetworkSettings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/network/NetworkSettings.java @@ -174,7 +174,9 @@ public class NetworkSettings { AFK_THRESHOLD_MINUTES, DATA_GEOLOCATIONS, KEEP_LOGS_DAYS, - KEEP_INACTIVE_PLAYERS_DAYS + KEEP_INACTIVE_PLAYERS_DAYS, + PING_SERVER_ENABLE_DELAY, + PING_PLAYER_LOGIN_DELAY }; Log.debug("NetworkSettings: Adding Config Values.."); for (Settings setting : sameStrings) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java index dfe9bd493..508efa0d4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java @@ -5,10 +5,12 @@ package com.djrapitops.plan.system.tasks; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.tasks.server.BukkitTPSCountTimer; import com.djrapitops.plan.system.tasks.server.PaperTPSCountTimer; import com.djrapitops.plan.system.tasks.server.PingCountTimer; import com.djrapitops.plugin.api.Check; +import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.task.RunnableFactory; import org.bukkit.Bukkit; @@ -33,8 +35,9 @@ public class BukkitTaskSystem extends ServerTaskSystem { try { PingCountTimer pingCountTimer = new PingCountTimer(); ((Plan) plugin).registerListener(pingCountTimer); + long startDelay = TimeAmount.SECOND.ms() * (long) Settings.PING_SERVER_ENABLE_DELAY.getNumber(); RunnableFactory.createNew("PingCountTimer", pingCountTimer) - .runTaskTimer(20L, PingCountTimer.PING_INTERVAL); + .runTaskTimer(startDelay, PingCountTimer.PING_INTERVAL); } catch (ExceptionInInitializerError | NoClassDefFoundError ignore) { // Running CraftBukkit } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/PingCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/PingCountTimer.java index 8e1e360c0..37c0b728b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/PingCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/PingCountTimer.java @@ -26,6 +26,7 @@ package com.djrapitops.plan.system.tasks.server; import com.djrapitops.plan.data.store.objects.DateObj; import com.djrapitops.plan.system.processing.Processing; import com.djrapitops.plan.system.processing.processors.player.PingInsertProcessor; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.java.Reflection; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; @@ -160,7 +161,7 @@ public class PingCountTimer extends AbsRunnable implements Listener { addPlayer(player); } } - }).runTaskLater(TimeAmount.SECOND.ticks() * 15L); + }).runTaskLater(TimeAmount.SECOND.ticks() * (long) Settings.PING_PLAYER_LOGIN_DELAY.getNumber()); } @EventHandler diff --git a/Plan/src/main/resources/bungeeconfig.yml b/Plan/src/main/resources/bungeeconfig.yml index 0e4be559d..02d582993 100644 --- a/Plan/src/main/resources/bungeeconfig.yml +++ b/Plan/src/main/resources/bungeeconfig.yml @@ -67,6 +67,9 @@ Data: LogUnknownCommands: false CombineCommandAliases: true Geolocations: true + Ping: + ServerEnableDelaySeconds: 300 + PlayerLoginDelaySeconds: 30 KeepInactivePlayerDataForDays: 180 # ----------------------------------------------------- Customization: diff --git a/Plan/src/main/resources/config.yml b/Plan/src/main/resources/config.yml index be15fa519..266672566 100644 --- a/Plan/src/main/resources/config.yml +++ b/Plan/src/main/resources/config.yml @@ -81,6 +81,9 @@ Data: LogUnknownCommands: false CombineCommandAliases: true Geolocations: true + Ping: + ServerEnableDelaySeconds: 300 + PlayerLoginDelaySeconds: 30 KeepInactivePlayerDataForDays: 180 # ----------------------------------------------------- Customization: