From 7802fdd7d9fabdabc474166d19ba46cee9f6eb8a Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 18 Apr 2025 09:13:23 +0200 Subject: [PATCH 1/3] Add ActiveMonths to ArenaMode for rotating modes --- .../src/de/steamwar/velocitycore/ArenaMode.java | 12 +++++++++--- .../steamwar/velocitycore/commands/FightCommand.java | 2 +- .../steamwar/velocitycore/commands/TypeMappers.java | 5 ++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java b/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java index 5595d9d9..035263f4 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java +++ b/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java @@ -22,6 +22,7 @@ package de.steamwar.velocitycore; import de.steamwar.sql.SchematicType; import lombok.Getter; +import java.time.LocalDateTime; import java.util.*; public class ArenaMode extends GameModeConfig { @@ -76,7 +77,7 @@ public class ArenaMode extends GameModeConfig { public static List getAllChatNames(boolean historic) { List chatNames = new LinkedList<>(); for(ArenaMode mode : byInternal.values()){ - if(historic == mode.isHistoric()) + if(!mode.isNotActive() && historic == mode.isHistoric()) chatNames.addAll(mode.getServer().getChatNames()); } return chatNames; @@ -94,6 +95,9 @@ public class ArenaMode extends GameModeConfig { @Getter private String config; + @Getter + private List ActiveMonths = Collections.emptyList(); + public String hasMap(String map){ for(String m : getMaps()) { if(m.equalsIgnoreCase(map)) @@ -114,8 +118,10 @@ public class ArenaMode extends GameModeConfig { return getServer().getChatNames().get(0); } - public boolean withoutChatName(){ - return getServer().getChatNames().isEmpty(); + public boolean isNotActive() { + if (getServer().getChatNames().isEmpty()) return true; + if (ActiveMonths.isEmpty()) return false; + return !ActiveMonths.contains(LocalDateTime.now().getMonth().getValue()); } public String getSchemTypeOrInternalName() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java index 6c320758..2e8405cc 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java @@ -45,7 +45,7 @@ public class FightCommand extends SWCommand { private static void getModes(Chatter sender, String precommand, boolean historic){ Component start = Component.empty(); for(ArenaMode mode : ArenaMode.getAllModes()){ - if(mode.withoutChatName() || mode.isHistoric() != historic) + if (mode.isNotActive() || mode.isHistoric() != historic) continue; String command = precommand + mode.getChatName(); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java b/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java index 8036272f..af160323 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java @@ -49,7 +49,10 @@ public class TypeMappers { return new TypeMapper<>() { @Override public ArenaMode map(Chatter sender, PreviousArguments previousArguments, String s) { - return ArenaMode.getByChat(s); + ArenaMode arenaMode = ArenaMode.getByChat(s); + if (arenaMode.isHistoric() != historic) return null; + if (arenaMode.isNotActive()) return null; + return arenaMode; } @Override From e5bdbac3c73031e94bef0d4ed12e813a9fae26fc Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 18 Apr 2025 16:50:16 +0200 Subject: [PATCH 2/3] Change isNotActive to isActive --- .../src/de/steamwar/velocitycore/ArenaMode.java | 10 +++++----- .../steamwar/velocitycore/commands/FightCommand.java | 2 +- .../de/steamwar/velocitycore/commands/TypeMappers.java | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java b/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java index 035263f4..4490c172 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java +++ b/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java @@ -77,7 +77,7 @@ public class ArenaMode extends GameModeConfig { public static List getAllChatNames(boolean historic) { List chatNames = new LinkedList<>(); for(ArenaMode mode : byInternal.values()){ - if(!mode.isNotActive() && historic == mode.isHistoric()) + if(mode.isActive() && historic == mode.isHistoric()) chatNames.addAll(mode.getServer().getChatNames()); } return chatNames; @@ -118,10 +118,10 @@ public class ArenaMode extends GameModeConfig { return getServer().getChatNames().get(0); } - public boolean isNotActive() { - if (getServer().getChatNames().isEmpty()) return true; - if (ActiveMonths.isEmpty()) return false; - return !ActiveMonths.contains(LocalDateTime.now().getMonth().getValue()); + public boolean isActive() { + if (getServer().getChatNames().isEmpty()) return false; + if (ActiveMonths.isEmpty()) return true; + return ActiveMonths.contains(LocalDateTime.now().getMonth().getValue()); } public String getSchemTypeOrInternalName() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java index 2e8405cc..ee82988c 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java @@ -45,7 +45,7 @@ public class FightCommand extends SWCommand { private static void getModes(Chatter sender, String precommand, boolean historic){ Component start = Component.empty(); for(ArenaMode mode : ArenaMode.getAllModes()){ - if (mode.isNotActive() || mode.isHistoric() != historic) + if (!mode.isActive() || mode.isHistoric() != historic) continue; String command = precommand + mode.getChatName(); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java b/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java index af160323..a9b8e37b 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java @@ -51,7 +51,7 @@ public class TypeMappers { public ArenaMode map(Chatter sender, PreviousArguments previousArguments, String s) { ArenaMode arenaMode = ArenaMode.getByChat(s); if (arenaMode.isHistoric() != historic) return null; - if (arenaMode.isNotActive()) return null; + if (!arenaMode.isActive()) return null; return arenaMode; } From 43621b18b435eb012141bed725227160f3fae626 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 18 Apr 2025 16:57:35 +0200 Subject: [PATCH 3/3] Fix TypeMappers.arenaMapTypeMapper --- .../src/de/steamwar/velocitycore/commands/TypeMappers.java | 1 + 1 file changed, 1 insertion(+) diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java b/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java index a9b8e37b..e2c1176a 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java @@ -50,6 +50,7 @@ public class TypeMappers { @Override public ArenaMode map(Chatter sender, PreviousArguments previousArguments, String s) { ArenaMode arenaMode = ArenaMode.getByChat(s); + if (arenaMode == null) return null; if (arenaMode.isHistoric() != historic) return null; if (!arenaMode.isActive()) return null; return arenaMode;