forked from SteamWar/SteamWar
Merge pull request 'Add ActiveMonths to ArenaMode for rotating modes' (#45) from VelocityCore/ActiveMonthsForRotatingGameModes into main
Reviewed-on: SteamWar/SteamWar#45
This commit is contained in:
@@ -22,6 +22,7 @@ package de.steamwar.velocitycore;
|
|||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ArenaMode extends GameModeConfig {
|
public class ArenaMode extends GameModeConfig {
|
||||||
@@ -76,7 +77,7 @@ public class ArenaMode extends GameModeConfig {
|
|||||||
public static List<String> getAllChatNames(boolean historic) {
|
public static List<String> getAllChatNames(boolean historic) {
|
||||||
List<String> chatNames = new LinkedList<>();
|
List<String> chatNames = new LinkedList<>();
|
||||||
for(ArenaMode mode : byInternal.values()){
|
for(ArenaMode mode : byInternal.values()){
|
||||||
if(historic == mode.isHistoric())
|
if(mode.isActive() && historic == mode.isHistoric())
|
||||||
chatNames.addAll(mode.getServer().getChatNames());
|
chatNames.addAll(mode.getServer().getChatNames());
|
||||||
}
|
}
|
||||||
return chatNames;
|
return chatNames;
|
||||||
@@ -94,6 +95,9 @@ public class ArenaMode extends GameModeConfig {
|
|||||||
@Getter
|
@Getter
|
||||||
private String config;
|
private String config;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private List<Integer> ActiveMonths = Collections.emptyList();
|
||||||
|
|
||||||
public String hasMap(String map){
|
public String hasMap(String map){
|
||||||
for(String m : getMaps()) {
|
for(String m : getMaps()) {
|
||||||
if(m.equalsIgnoreCase(map))
|
if(m.equalsIgnoreCase(map))
|
||||||
@@ -114,8 +118,10 @@ public class ArenaMode extends GameModeConfig {
|
|||||||
return getServer().getChatNames().get(0);
|
return getServer().getChatNames().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean withoutChatName(){
|
public boolean isActive() {
|
||||||
return getServer().getChatNames().isEmpty();
|
if (getServer().getChatNames().isEmpty()) return false;
|
||||||
|
if (ActiveMonths.isEmpty()) return true;
|
||||||
|
return ActiveMonths.contains(LocalDateTime.now().getMonth().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSchemTypeOrInternalName() {
|
public String getSchemTypeOrInternalName() {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class FightCommand extends SWCommand {
|
|||||||
private static void getModes(Chatter sender, String precommand, boolean historic){
|
private static void getModes(Chatter sender, String precommand, boolean historic){
|
||||||
Component start = Component.empty();
|
Component start = Component.empty();
|
||||||
for(ArenaMode mode : ArenaMode.getAllModes()){
|
for(ArenaMode mode : ArenaMode.getAllModes()){
|
||||||
if(mode.withoutChatName() || mode.isHistoric() != historic)
|
if (!mode.isActive() || mode.isHistoric() != historic)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String command = precommand + mode.getChatName();
|
String command = precommand + mode.getChatName();
|
||||||
|
|||||||
@@ -49,7 +49,11 @@ public class TypeMappers {
|
|||||||
return new TypeMapper<>() {
|
return new TypeMapper<>() {
|
||||||
@Override
|
@Override
|
||||||
public ArenaMode map(Chatter sender, PreviousArguments previousArguments, String s) {
|
public ArenaMode map(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
return ArenaMode.getByChat(s);
|
ArenaMode arenaMode = ArenaMode.getByChat(s);
|
||||||
|
if (arenaMode == null) return null;
|
||||||
|
if (arenaMode.isHistoric() != historic) return null;
|
||||||
|
if (!arenaMode.isActive()) return null;
|
||||||
|
return arenaMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user