From 09adc97a2018d7ee6d99284794d1c8c62c18d506 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 18 Jan 2023 21:37:04 +0100 Subject: [PATCH] added arena afk stopper --- FightSystem_Core/src/config.yml | 2 +- .../src/de/steamwar/fightsystem/Config.java | 2 +- .../countdown/NoPlayersOnlineCountdown.java | 21 +++---------------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/FightSystem_Core/src/config.yml b/FightSystem_Core/src/config.yml index 711d1d2..14a9fed 100644 --- a/FightSystem_Core/src/config.yml +++ b/FightSystem_Core/src/config.yml @@ -20,7 +20,7 @@ Ranks: [] # Disables ranks for this schematic type if missing Times: # Time in seconds the server stops after starting if nobody joins - NoPlayersOnlineDuration: 30 # defaults to 30 if missing + NoPlayersOnlineDuration: 300 # defaults to 300 if missing # Time in seconds the team leaders have to choose their schematic PreSchemPasteDuration: 120 # defaults to 120 if missing # Time in seconds for preparing diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/Config.java b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java index 1123289..f1affb4 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java @@ -155,7 +155,7 @@ public class Config { } FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile); - NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration", 30); + NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration", 300); PreSchemPasteDuration = config.getInt("Times.PreSchemPasteDuration", 120); SetupDuration = config.getInt("Times.SetupDuration", 300); PreFightDuration = config.getInt("Times.PreFightDuration", 30); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java index 11cb3c9..94e54e2 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java @@ -23,31 +23,16 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; -import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.Message; import org.bukkit.Bukkit; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -public class NoPlayersOnlineCountdown extends Countdown implements Listener { +public class NoPlayersOnlineCountdown extends Countdown { public NoPlayersOnlineCountdown() { super(Config.NoPlayerOnlineDuration, new Message("SHUTDOWN_COUNTDOWN"), null, false); - new StateDependentListener(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this); - new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this) { - @Override - public void enable() { - if(Bukkit.getOnlinePlayers().isEmpty()) - super.enable(); - } - }; - } - - @EventHandler - public void handlePlayerJoin(PlayerJoinEvent event) { - disable(); + if (!Config.ArenaLeaveable) + new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this); } @Override -- 2.39.2