forked from SteamWar/SteamWar
Add Unified GameModeConfig
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.data;
|
||||
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class YMLWrapperImpl<ST> extends YMLWrapper<String, ST, String> {
|
||||
|
||||
public static YMLWrapperImpl<SchematicType> ofTyped(File file) {
|
||||
return new YMLWrapperImpl<>(file, ToSchematicType);
|
||||
}
|
||||
|
||||
public static YMLWrapperImpl<String> ofRaw(File file) {
|
||||
return new YMLWrapperImpl<>(file, ToString);
|
||||
}
|
||||
|
||||
private final boolean canLoad;
|
||||
private final Map<String, Object> document;
|
||||
|
||||
private YMLWrapperImpl(File file, Function<String, ST> schematicTypeMapper) {
|
||||
super(file, ToString, schematicTypeMapper, ToString);
|
||||
if (file == null || !file.exists()) {
|
||||
canLoad = false;
|
||||
document = new HashMap<>();
|
||||
} else {
|
||||
canLoad = true;
|
||||
Yaml yaml = new Yaml();
|
||||
try {
|
||||
document = yaml.load(new FileInputStream(file));
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private YMLWrapperImpl(boolean canLoad, Map<String, Object> document, Function<String, ST> schematicTypeMapper) {
|
||||
super(null, ToString, schematicTypeMapper, ToString);
|
||||
this.canLoad = canLoad;
|
||||
this.document = document;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canLoad() {
|
||||
return canLoad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YMLWrapper<String, ST, String> with(String path) {
|
||||
if (document.containsKey(path)) {
|
||||
Object value = this.document.get(path);
|
||||
if (value instanceof Map) {
|
||||
return new YMLWrapperImpl(this.canLoad, (Map) value, schematicTypeMapper);
|
||||
}
|
||||
}
|
||||
return new YMLWrapperImpl(false, Collections.emptyMap(), schematicTypeMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultGameName() {
|
||||
return file.getName().replace(".yml", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String path, String defaultValue) {
|
||||
Object value = this.document.get(path);
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(String path, int defaultValue) {
|
||||
Object value = this.document.get(path);
|
||||
if (value instanceof Integer) {
|
||||
return (Integer) value;
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String path, double defaultValue) {
|
||||
Object value = this.document.get(path);
|
||||
if (value instanceof Double) {
|
||||
return (Double) value;
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(String path, boolean defaultValue) {
|
||||
Object value = this.document.get(path);
|
||||
if (value instanceof Boolean) {
|
||||
return (Boolean) value;
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getStringList(String path) {
|
||||
Object value = this.document.get(path);
|
||||
if (value instanceof List) {
|
||||
return Collections.unmodifiableList((List<String>) value);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getIntList(String path) {
|
||||
Object value = this.document.get(path);
|
||||
if (value instanceof List) {
|
||||
return Collections.unmodifiableList((List<Integer>) value);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<?, ?>> getMapList(String path) {
|
||||
Object value = this.document.get(path);
|
||||
if (value instanceof List) {
|
||||
return Collections.unmodifiableList((List<Map<?, ?>>) value);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,52 +21,46 @@ package de.steamwar.sql;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.steamwar.velocitycore.GameModeConfig;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.data.YMLWrapperImpl;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.commands.CheckCommand;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SQLWrapperImpl implements SQLWrapper {
|
||||
private static final SimpleDateFormat deadlineFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||
private static Date parseDeadline(String deadline) {
|
||||
if(deadline == null)
|
||||
return null;
|
||||
|
||||
try {
|
||||
return deadlineFormat.parse(deadline);
|
||||
} catch (ParseException e) {
|
||||
throw new SecurityException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadSchemTypes(List<SchematicType> tmpTypes, Map<String, SchematicType> tmpFromDB) {
|
||||
GameModeConfig.loadAll(GameModeConfig.class, (file, config) -> {
|
||||
if(config.getSchematic() == null || tmpFromDB.containsKey(config.getSchemType().toLowerCase()))
|
||||
return;
|
||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||
if(!folder.exists())
|
||||
return;
|
||||
|
||||
String shortcut = config.getSchematic().getShortcut();
|
||||
String material = config.getSchematic().getMaterial();
|
||||
for(File file : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().toList()) {
|
||||
GameModeConfig<String, String, String> gameModeConfig = new GameModeConfig<>(YMLWrapperImpl.ofRaw(file));
|
||||
if (!gameModeConfig.Schematic.loaded) continue;
|
||||
if (tmpFromDB.containsKey(gameModeConfig.Schematic.Type.toLowerCase())) continue;
|
||||
|
||||
String shortcut = gameModeConfig.Schematic.Shortcut;
|
||||
String material = gameModeConfig.Schematic.Material;
|
||||
|
||||
SchematicType checktype = null;
|
||||
if(!config.getCheckQuestions().isEmpty()) {
|
||||
checktype = new SchematicType("C" + config.getSchemType(), "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material, true);
|
||||
if (!gameModeConfig.CheckQuestions.isEmpty()) {
|
||||
checktype = new SchematicType("C" + gameModeConfig.Schematic.Type, "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material, true);
|
||||
tmpTypes.add(checktype);
|
||||
tmpFromDB.put(checktype.toDB(), checktype);
|
||||
CheckCommand.setCheckQuestions(checktype, config.getCheckQuestions());
|
||||
CheckCommand.setCheckQuestions(checktype, gameModeConfig.CheckQuestions);
|
||||
}
|
||||
|
||||
SchematicType current = new SchematicType(config.getSchemType(), shortcut, config.getServer() != null ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material, parseDeadline(config.getDeadline()), config.getSchematic().isManualCheck());
|
||||
SchematicType current = new SchematicType(gameModeConfig.Schematic.Type, shortcut, gameModeConfig.Server.loaded ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material, gameModeConfig.Deadline, gameModeConfig.Schematic.ManualCheck);
|
||||
tmpTypes.add(current);
|
||||
tmpFromDB.put(config.getSchemType().toLowerCase(), current);
|
||||
tmpFromDB.put(gameModeConfig.Schematic.Type.toLowerCase(), current);
|
||||
if(checktype != null)
|
||||
CheckCommand.addFightType(checktype, current);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,21 +19,23 @@
|
||||
|
||||
package de.steamwar.velocitycore;
|
||||
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.data.YMLWrapperImpl;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class ArenaMode extends GameModeConfig {
|
||||
@UtilityClass
|
||||
public class ArenaMode {
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
private static final Map<String, ArenaMode> byChat = new HashMap<>();
|
||||
private static final Map<String, ArenaMode> byInternal = new HashMap<>();
|
||||
private static final Map<SchematicType, ArenaMode> bySchemType = new HashMap<>();
|
||||
private static final Map<String, GameModeConfig<String, SchematicType, String>> byChat = new HashMap<>();
|
||||
private static final Map<String, GameModeConfig<String, SchematicType, String>> byInternal = new HashMap<>();
|
||||
private static final Map<SchematicType, GameModeConfig<String, SchematicType, String>> bySchemType = new HashMap<>();
|
||||
@Getter
|
||||
private static final List<ArenaMode> allModes = new LinkedList<>();
|
||||
private static final List<GameModeConfig<String, SchematicType, String>> allModes = new LinkedList<>();
|
||||
|
||||
static {
|
||||
init();
|
||||
@@ -45,90 +47,43 @@ public class ArenaMode extends GameModeConfig {
|
||||
bySchemType.clear();
|
||||
allModes.clear();
|
||||
|
||||
GameModeConfig.loadAll(ArenaMode.class, (file, mode) -> {
|
||||
if(mode.getServer() == null)
|
||||
return;
|
||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||
if(!folder.exists())
|
||||
return;
|
||||
|
||||
mode.config = file.getName();
|
||||
mode.internalName = file.getName().replace(".yml", "");
|
||||
mode.getMaps().forEach(map -> mode.lowerToRealMapNames.put(map.toLowerCase(), map));
|
||||
if(mode.getGameName() == null)
|
||||
mode.setGameName(mode.internalName);
|
||||
for(File file : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().toList()) {
|
||||
de.steamwar.data.GameModeConfig<String, SchematicType, String> gameModeConfig = new de.steamwar.data.GameModeConfig<>(YMLWrapperImpl.ofTyped(file));
|
||||
if (!gameModeConfig.Server.loaded) continue;
|
||||
|
||||
allModes.add(mode);
|
||||
byInternal.put(mode.internalName, mode);
|
||||
for(String name : mode.getServer().getChatNames()){
|
||||
byChat.put(name.toLowerCase(), mode);
|
||||
allModes.add(gameModeConfig);
|
||||
byInternal.put(file.getName().replace(".yml", ""), gameModeConfig);
|
||||
for (String name : gameModeConfig.Server.ChatNames) {
|
||||
byChat.put(name.toLowerCase(), gameModeConfig);
|
||||
}
|
||||
|
||||
if(mode.getSchematic() != null && mode.getSchemType() != null)
|
||||
bySchemType.put(SchematicType.fromDB(mode.getSchemType()), mode);
|
||||
});
|
||||
if (gameModeConfig.Schematic.loaded && gameModeConfig.Schematic.Type != SchematicType.Normal) {
|
||||
bySchemType.put(gameModeConfig.Schematic.Type, gameModeConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ArenaMode getByChat(String name){
|
||||
public static GameModeConfig<String, SchematicType, String> getByChat(String name){
|
||||
return byChat.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public static ArenaMode getByInternal(String name){
|
||||
public static GameModeConfig<String, SchematicType, String> getByInternal(String name){
|
||||
return byInternal.get(name);
|
||||
}
|
||||
|
||||
public static List<String> getAllChatNames(boolean historic) {
|
||||
List<String> chatNames = new LinkedList<>();
|
||||
for(ArenaMode mode : byInternal.values()){
|
||||
if(mode.isActive() && historic == mode.isHistoric())
|
||||
chatNames.addAll(mode.getServer().getChatNames());
|
||||
for(GameModeConfig<String, SchematicType, String> mode : byInternal.values()){
|
||||
if(mode.isActive() && historic == mode.Server.Historic)
|
||||
chatNames.addAll(mode.Server.ChatNames);
|
||||
}
|
||||
return chatNames;
|
||||
}
|
||||
|
||||
public static ArenaMode getBySchemType(SchematicType schemType){
|
||||
public static GameModeConfig<String, SchematicType, String> getBySchemType(SchematicType schemType){
|
||||
return bySchemType.get(schemType);
|
||||
}
|
||||
|
||||
|
||||
private final Map<String, String> lowerToRealMapNames = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
private String internalName;
|
||||
@Getter
|
||||
private String config;
|
||||
|
||||
@Getter
|
||||
private List<Integer> ActiveMonths = Collections.emptyList();
|
||||
|
||||
public String hasMap(String map){
|
||||
for(String m : getMaps()) {
|
||||
if(m.equalsIgnoreCase(map))
|
||||
return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getRandomMap(){
|
||||
return getMaps().get(random.nextInt(getMaps().size()));
|
||||
}
|
||||
|
||||
public String convertToRealMapName(String map){
|
||||
return lowerToRealMapNames.get(map.toLowerCase());
|
||||
}
|
||||
|
||||
public String getChatName(){
|
||||
return getServer().getChatNames().get(0);
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
if (getServer().getChatNames().isEmpty()) return false;
|
||||
if (ActiveMonths.isEmpty()) return true;
|
||||
return ActiveMonths.contains(LocalDateTime.now().getMonth().getValue());
|
||||
}
|
||||
|
||||
public String getSchemTypeOrInternalName() {
|
||||
Schematic schematic = getSchematic();
|
||||
if (schematic == null) {
|
||||
return internalName;
|
||||
}
|
||||
return schematic.getType();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.velocitycore;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Getter
|
||||
public class GameModeConfig {
|
||||
|
||||
private static final Pattern terminatingNumber = Pattern.compile("(\\d+)$");
|
||||
|
||||
public static <T extends GameModeConfig> void loadAll(Class<T> config, BiConsumer<File, T> consumer) {
|
||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||
if(!folder.exists())
|
||||
return;
|
||||
|
||||
for(File file : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().toList()) {
|
||||
consumer.accept(file, Config.load(config, file, description -> {}));
|
||||
}
|
||||
}
|
||||
|
||||
private Server Server = null;
|
||||
private List<String> CheckQuestions = Collections.emptyList();
|
||||
private String deadline = null;
|
||||
private Schematic Schematic = null;
|
||||
@Setter
|
||||
private String GameName;
|
||||
|
||||
@Getter
|
||||
public static class Server {
|
||||
private String Folder;
|
||||
private List<String> ChatNames = Collections.emptyList();
|
||||
private List<String> Maps;
|
||||
private boolean Spigot = false;
|
||||
private boolean Ranked = false;
|
||||
private boolean Historic = false;
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class Schematic {
|
||||
private String Type;
|
||||
private String Shortcut;
|
||||
private String Material;
|
||||
private boolean ManualCheck = true;
|
||||
}
|
||||
|
||||
public ServerVersion getVersion() {
|
||||
Matcher matcher = terminatingNumber.matcher(getServer().getFolder());
|
||||
matcher.find();
|
||||
return ServerVersion.valueOf((getServer().isSpigot() ? "SPIGOT_" : "PAPER_") + matcher.group(1));
|
||||
}
|
||||
|
||||
public String getFolder() {
|
||||
return getServer().getFolder();
|
||||
}
|
||||
|
||||
public List<String> getMaps() {
|
||||
return getServer().getMaps();
|
||||
}
|
||||
|
||||
public boolean isHistoric() {
|
||||
return getServer().isHistoric();
|
||||
}
|
||||
|
||||
public boolean isRanked() {
|
||||
return getServer().isRanked();
|
||||
}
|
||||
|
||||
public String getSchemType() {
|
||||
return getSchematic().getType();
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ package de.steamwar.velocitycore;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.velocity.platform.VelocityViaConfig;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.persistent.Arenaserver;
|
||||
import de.steamwar.persistent.Bauserver;
|
||||
@@ -79,16 +80,16 @@ public class ServerStarter {
|
||||
private final Set<Player> playersToSend = new HashSet<>();
|
||||
private final Map<String, String> arguments = new HashMap<>();
|
||||
|
||||
public ServerStarter arena(ArenaMode mode, String map) {
|
||||
public ServerStarter arena(GameModeConfig<String, SchematicType, String> mode, String map) {
|
||||
portrange = ARENA_PORTS;
|
||||
serverNameProvider = port -> mode.getGameName() + (port - portrange.start);
|
||||
version = mode.getVersion();
|
||||
serverNameProvider = port -> mode.GameName + (port - portrange.start);
|
||||
version = ServerVersion.from(mode);
|
||||
allowMerge = true;
|
||||
fightMap = map;
|
||||
gameMode = mode.getInternalName();
|
||||
directory = new File(SERVER_PATH, mode.getFolder());
|
||||
arguments.put("config", mode.getConfig());
|
||||
tempWorld(SERVER_PATH + mode.getFolder() + "/arenas/" + map);
|
||||
gameMode = mode.configFile.getName().replace(".yml", "");
|
||||
directory = new File(SERVER_PATH, mode.Server.Folder);
|
||||
arguments.put("config", mode.configFile.getName());
|
||||
tempWorld(SERVER_PATH + mode.Server.Folder + "/arenas/" + map);
|
||||
startCondition = () -> {
|
||||
if(playersToSend.stream().anyMatch(player -> Subserver.isArena(Subserver.getSubserver(player)))) {
|
||||
playersToSend.forEach(player -> Chatter.of(player).system("FIGHT_IN_ARENA"));
|
||||
@@ -115,7 +116,7 @@ public class ServerStarter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerStarter test(ArenaMode mode, String map, Player owner) {
|
||||
public ServerStarter test(GameModeConfig<String, SchematicType, String> mode, String map, Player owner) {
|
||||
arena(mode, map);
|
||||
buildWithTemp(owner);
|
||||
portrange = BAU_PORTS;
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
package de.steamwar.velocitycore;
|
||||
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -27,6 +29,8 @@ import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@@ -108,4 +112,12 @@ public enum ServerVersion {
|
||||
public File getServerDirectory(String base) {
|
||||
return new File(ServerStarter.SERVER_PATH, base + versionSuffix);
|
||||
}
|
||||
|
||||
private static final Pattern terminatingNumber = Pattern.compile("(\\d+)$");
|
||||
|
||||
public static ServerVersion from(GameModeConfig<String, SchematicType, String> type) {
|
||||
Matcher matcher = terminatingNumber.matcher(type.Server.Folder);
|
||||
matcher.find();
|
||||
return ServerVersion.valueOf((type.Server.Spigot ? "SPIGOT_" : "PAPER_") + matcher.group(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.linkage.EventMode;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
@@ -32,6 +33,7 @@ import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||
import de.steamwar.persistent.Bauserver;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.velocitycore.*;
|
||||
import de.steamwar.velocitycore.inventory.SWInventory;
|
||||
@@ -238,7 +240,7 @@ public class BauCommand extends SWCommand {
|
||||
|
||||
@Register("test")
|
||||
@Register("testarena")
|
||||
public void testarena(PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
public void testarena(PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig<String, SchematicType, String> arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
FightCommand.createArena(sender, "/bau testarena ", false, arenaMode, map, false, (chatter, mode, m) ->
|
||||
new ServerStarter().test(mode, m, sender.getPlayer()).start()
|
||||
);
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import de.steamwar.velocitycore.ServerStarter;
|
||||
import de.steamwar.velocitycore.ServerVersion;
|
||||
@@ -85,14 +87,14 @@ public class BuilderCloudCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(value = "deploy", description = "BUILDERCLOUD_DEPLOY_USAGE")
|
||||
public void deploy(Chatter sender, @Mapper("nonHistoricArenaMode") ArenaMode arenaMode, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map) {
|
||||
public void deploy(Chatter sender, @Mapper("nonHistoricArenaMode") GameModeConfig<String, SchematicType, String> arenaMode, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map) {
|
||||
if(!mapFile(version, map).exists()) {
|
||||
sender.system("BUILDERCLOUD_UNKNOWN_MAP");
|
||||
return;
|
||||
}
|
||||
|
||||
VelocityCore.schedule(() -> {
|
||||
VelocityCore.local.execute("deployarena.py", arenaMode.getConfig(), Integer.toString(version.getVersionSuffix()), map);
|
||||
VelocityCore.local.execute("deployarena.py", arenaMode.configFile.getName(), Integer.toString(version.getVersionSuffix()), map);
|
||||
ArenaMode.init();
|
||||
sender.system("BUILDERCLOUD_DEPLOY_FINISHED");
|
||||
}).schedule();
|
||||
|
||||
@@ -22,6 +22,7 @@ package de.steamwar.velocitycore.commands;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.linkage.EventMode;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
@@ -29,6 +30,7 @@ import de.steamwar.messages.Message;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.persistent.Subserver;
|
||||
import de.steamwar.sql.IgnoreSystem;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import de.steamwar.velocitycore.ServerStarter;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
@@ -46,7 +48,7 @@ public class ChallengeCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(description = "CHALLENGE_USAGE")
|
||||
public void challenge(@Validator("arenaPlayer") PlayerChatter sender, @Validator("target") Player target, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
public void challenge(@Validator("arenaPlayer") PlayerChatter sender, @Validator("target") Player target, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig<String, SchematicType, String> arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
FightCommand.createArena(sender, "/challenge " + target.getUsername() + " ", false, arenaMode, map, false, (chatter, mode, m) -> {
|
||||
Player p = sender.getPlayer();
|
||||
if(challenges.containsKey(target) && challenges.get(target).contains(p)){
|
||||
@@ -54,7 +56,7 @@ public class ChallengeCommand extends SWCommand {
|
||||
challenges.remove(p);
|
||||
|
||||
new ServerStarter().arena(mode, map).blueLeader(sender.getPlayer()).redLeader(target).callback(
|
||||
arena -> Chatter.broadcast().system("CHALLENGE_BROADCAST", new Message("CHALLENGE_BROADCAST_HOVER"), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.getGameName(), p, target)
|
||||
arena -> Chatter.broadcast().system("CHALLENGE_BROADCAST", new Message("CHALLENGE_BROADCAST_HOVER"), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.GameName, p, target)
|
||||
).start();
|
||||
}else{
|
||||
if(!challenges.containsKey(p)){
|
||||
@@ -63,8 +65,8 @@ public class ChallengeCommand extends SWCommand {
|
||||
|
||||
challenges.get(p).add(target);
|
||||
|
||||
sender.system("CHALLENGE_CHALLENGED", target, mode.getGameName());
|
||||
Chatter.of(target).system("CHALLENGE_CHALLENGED_TARGET", p, mode.getGameName(), mode.getMaps().size() != 1 ? new Message("CHALLENGE_CHALLENGED_MAP", m) : "");
|
||||
sender.system("CHALLENGE_CHALLENGED", target, mode.GameName);
|
||||
Chatter.of(target).system("CHALLENGE_CHALLENGED_TARGET", p, mode.GameName, mode.Server.Maps.size() != 1 ? new Message("CHALLENGE_CHALLENGED_MAP", m) : "");
|
||||
|
||||
Chatter.of(target).system("CHALLENGE_ACCEPT", new Message("CHALLENGE_ACCEPT_HOVER"), ClickEvent.runCommand("/challenge " + p.getUsername() + " " + mode.getChatName() + " " + m));
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package de.steamwar.velocitycore.commands;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.Message;
|
||||
@@ -39,8 +40,8 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import java.awt.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.logging.Level;
|
||||
@@ -220,7 +221,7 @@ public class CheckCommand extends SWCommand {
|
||||
this.startTime = Timestamp.from(Instant.now());
|
||||
this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator();
|
||||
|
||||
ArenaMode mode = ArenaMode.getBySchemType(fightTypes.get(schematic.getSchemtype()));
|
||||
GameModeConfig<String, SchematicType, String> mode = ArenaMode.getBySchemType(fightTypes.get(schematic.getSchemtype()));
|
||||
new ServerStarter().test(mode, mode.getRandomMap(), checker.getPlayer()).check(schematic.getId()).callback(subserver -> {
|
||||
currentCheckers.put(checker.user().getUUID(), this);
|
||||
currentSchems.put(schematic.getId(), this);
|
||||
|
||||
@@ -21,6 +21,7 @@ package de.steamwar.velocitycore.commands;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.linkage.EventMode;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
@@ -28,6 +29,7 @@ import de.steamwar.messages.Message;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.persistent.Arenaserver;
|
||||
import de.steamwar.persistent.Subserver;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import de.steamwar.velocitycore.ServerStarter;
|
||||
import de.steamwar.velocitycore.inventory.SWInventory;
|
||||
@@ -48,8 +50,8 @@ 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.isActive() || mode.isHistoric() != historic)
|
||||
for(GameModeConfig<String, SchematicType, String> mode : ArenaMode.getAllModes()){
|
||||
if (!mode.isActive() || mode.Server.Historic != historic)
|
||||
continue;
|
||||
|
||||
String command = precommand + mode.getChatName();
|
||||
@@ -64,7 +66,7 @@ public class FightCommand extends SWCommand {
|
||||
sender.sendMessage(start);
|
||||
}
|
||||
|
||||
static void createArena(PlayerChatter sender, String precommand, boolean allowMerging, ArenaMode arenaMode, String map, boolean historic, FightCallback callback) {
|
||||
static void createArena(PlayerChatter sender, String precommand, boolean allowMerging, GameModeConfig<String, SchematicType, String> arenaMode, String map, boolean historic, FightCallback callback) {
|
||||
if (arenaMode == null) {
|
||||
getModes(sender, precommand, historic);
|
||||
return;
|
||||
@@ -80,12 +82,12 @@ public class FightCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private static void suggestMerging(PlayerChatter sender, ArenaMode mode, String map, FightCallback declineMerge) {
|
||||
private static void suggestMerging(PlayerChatter sender, GameModeConfig<String, SchematicType, String> mode, String map, FightCallback declineMerge) {
|
||||
Arenaserver mergable = null;
|
||||
synchronized (Subserver.getServerList()) {
|
||||
for (Subserver subserver : Subserver.getServerList()) {
|
||||
if(subserver instanceof Arenaserver arenaserver &&
|
||||
(mode.getInternalName().equals(arenaserver.getMode()) && arenaserver.isAllowMerge() && arenaserver.getRegisteredServer().getPlayersConnected().size() == 1)) {
|
||||
(mode.configFile.getName().replace(".yml", "").equals(arenaserver.getMode()) && arenaserver.isAllowMerge() && arenaserver.getRegisteredServer().getPlayersConnected().size() == 1)) {
|
||||
mergable = arenaserver;
|
||||
break;
|
||||
}
|
||||
@@ -103,7 +105,7 @@ public class FightCommand extends SWCommand {
|
||||
declineMerge.run(sender, mode, map);
|
||||
});
|
||||
Arenaserver finalMergable = mergable;
|
||||
SWItem item = new SWItem(new Message("FIGHT_MERGE_INFO", mode.getGameName(), finalMergable.getMap()), 11);
|
||||
SWItem item = new SWItem(new Message("FIGHT_MERGE_INFO", mode.GameName, finalMergable.getMap()), 11);
|
||||
item.addLore(new Message("FIGHT_MERGE_INFO_LORE_1", finalMergable.getRegisteredServer().getPlayersConnected().toArray(new Player[1])[0].getUsername()));
|
||||
inventory.addItem(4, item, click -> {});
|
||||
inventory.addItem(8, new SWItem(new Message("FIGHT_MERGE_ACCEPT"), 10), click -> {
|
||||
@@ -118,15 +120,15 @@ public class FightCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void fight(@Validator("arenaPlayer") PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
public void fight(@Validator("arenaPlayer") PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig<String, SchematicType, String> arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
createArena(sender, "/fight ", true, arenaMode, map, false,
|
||||
(p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p.getPlayer()).callback(
|
||||
arena -> Chatter.broadcast().system("FIGHT_BROADCAST", new Message("FIGHT_BROADCAST_HOVER", p.getPlayer().getUsername()), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.getGameName(), p.getPlayer().getUsername())
|
||||
arena -> Chatter.broadcast().system("FIGHT_BROADCAST", new Message("FIGHT_BROADCAST_HOVER", p.getPlayer().getUsername()), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.GameName, p.getPlayer().getUsername())
|
||||
).start()
|
||||
);
|
||||
}
|
||||
|
||||
public interface FightCallback {
|
||||
void run(PlayerChatter player, ArenaMode mode, String map);
|
||||
void run(PlayerChatter player, GameModeConfig<String, SchematicType, String> mode, String map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,13 @@
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.linkage.EventMode;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.Message;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import de.steamwar.velocitycore.ServerStarter;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
@@ -37,9 +39,9 @@ public class HistoricCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void historic(@Validator("arenaPlayer") PlayerChatter player, @Mapper("historicArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
public void historic(@Validator("arenaPlayer") PlayerChatter player, @Mapper("historicArenaMode") @OptionalValue("") @AllowNull GameModeConfig<String, SchematicType, String> arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
FightCommand.createArena(player, "/historic ", true, arenaMode, map, true, (p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p.getPlayer()).callback(
|
||||
arena -> Chatter.broadcast().system("HISTORIC_BROADCAST", new Message("HISTORIC_BROADCAST_HOVER", p), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.getGameName(), p.getPlayer())
|
||||
arena -> Chatter.broadcast().system("HISTORIC_BROADCAST", new Message("HISTORIC_BROADCAST_HOVER", p), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.GameName, p.getPlayer())
|
||||
).start());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,11 @@
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.Message;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserElo;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
@@ -46,8 +48,8 @@ public class RankCommand extends SWCommand {
|
||||
if (!sender.user().equals(user))
|
||||
sender.prefixless("RANK_PLAYER_FOUND", user);
|
||||
|
||||
for(ArenaMode mode : ArenaMode.getAllModes()) {
|
||||
if (!mode.isRanked())
|
||||
for(GameModeConfig<String, SchematicType, String> mode : ArenaMode.getAllModes()) {
|
||||
if (!mode.Server.Ranked)
|
||||
continue;
|
||||
|
||||
Optional<Integer> elo = UserElo.getElo(user.getId(), mode.getSchemTypeOrInternalName());
|
||||
|
||||
@@ -19,17 +19,18 @@
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.linkage.EventMode;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import de.steamwar.messages.Message;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.sql.*;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import de.steamwar.velocitycore.ServerStarter;
|
||||
import de.steamwar.velocitycore.inventory.SWItem;
|
||||
import de.steamwar.velocitycore.inventory.SWListInv;
|
||||
import de.steamwar.velocitycore.inventory.SWStreamInv;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.sql.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -68,7 +69,7 @@ public class ReplayCommand extends SWCommand {
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
return;
|
||||
|
||||
ArenaMode mode = ArenaMode.getBySchemType(fight.getSchemType());
|
||||
GameModeConfig<String, SchematicType, String> mode = ArenaMode.getBySchemType(fight.getSchemType());
|
||||
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(sender.getPlayer());
|
||||
|
||||
String map = mode.getRandomMap();
|
||||
|
||||
@@ -19,14 +19,16 @@
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -45,13 +47,13 @@ public class TypeMappers {
|
||||
return (sender, player, messageSender) -> !PunishmentCommand.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer);
|
||||
}
|
||||
|
||||
private static TypeMapper<ArenaMode> arenaModeTypeMapper(boolean historic) {
|
||||
private static TypeMapper<GameModeConfig<String, SchematicType, String>> arenaModeTypeMapper(boolean historic) {
|
||||
return new TypeMapper<>() {
|
||||
@Override
|
||||
public ArenaMode map(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||
ArenaMode arenaMode = ArenaMode.getByChat(s);
|
||||
public GameModeConfig<String, SchematicType, String> map(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||
GameModeConfig<String, SchematicType, String> arenaMode = ArenaMode.getByChat(s);
|
||||
if (arenaMode == null) return null;
|
||||
if (arenaMode.isHistoric() != historic) return null;
|
||||
if (arenaMode.Server.Historic != historic) return null;
|
||||
if (!arenaMode.isActive()) return null;
|
||||
return arenaMode;
|
||||
}
|
||||
@@ -74,9 +76,9 @@ public class TypeMappers {
|
||||
@Override
|
||||
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||
if (previousArguments.userArgs.length == 0) return null;
|
||||
ArenaMode arenaMode = ArenaMode.getByChat(previousArguments.userArgs[previousArguments.userArgs.length - 1]);
|
||||
GameModeConfig<String, SchematicType, String> arenaMode = ArenaMode.getByChat(previousArguments.userArgs[previousArguments.userArgs.length - 1]);
|
||||
if (arenaMode == null) return null;
|
||||
return arenaMode.getMaps();
|
||||
return arenaMode.Server.Maps;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.ChatterGroup;
|
||||
@@ -56,7 +57,7 @@ public class ChatListener extends BasicListener {
|
||||
|
||||
private static final Logger cmdLogger = Logger.getLogger("Command logger");
|
||||
|
||||
private static final List<String> rankedModes = ArenaMode.getAllModes().stream().filter(ArenaMode::isRanked).map(ArenaMode::getSchemTypeOrInternalName).toList();
|
||||
private static final List<String> rankedModes = ArenaMode.getAllModes().stream().filter(gameModeConfig -> gameModeConfig.Server.Ranked).map(GameModeConfig::getSchemTypeOrInternalName).toList();
|
||||
|
||||
private static final Set<String> noLogCommands = Set.of("webpw", "webpassword", "web");
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package de.steamwar.velocitycore.network.handlers;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.linkage.EventMode;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
@@ -56,14 +56,14 @@ public class EloPlayerHandler extends PacketHandler {
|
||||
@Handler
|
||||
public void handle(FightEndsPacket fightEndsPacket) {
|
||||
SchematicType schematicType = SchematicType.fromDB(fightEndsPacket.getGameMode());
|
||||
ArenaMode arenaMode;
|
||||
GameModeConfig<String, SchematicType, String> arenaMode;
|
||||
if (schematicType == null) {
|
||||
arenaMode = ArenaMode.getByInternal(fightEndsPacket.getGameMode());
|
||||
} else {
|
||||
arenaMode = ArenaMode.getBySchemType(schematicType);
|
||||
}
|
||||
if (arenaMode == null) return;
|
||||
if (!arenaMode.isRanked()) return;
|
||||
if (!arenaMode.Server.Ranked) return;
|
||||
|
||||
if (EloSchemHandler.publicVsPrivate(fightEndsPacket))
|
||||
return;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.velocitycore.network.handlers;
|
||||
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
||||
@@ -45,8 +46,8 @@ public class EloSchemHandler extends PacketHandler {
|
||||
public void handle(FightEndsPacket fightEndsPacket) {
|
||||
SchematicType type = SchematicType.fromDB(fightEndsPacket.getGameMode());
|
||||
if (type == null) return;
|
||||
ArenaMode arenaMode = ArenaMode.getBySchemType(type);
|
||||
if (!arenaMode.isRanked()) return;
|
||||
GameModeConfig<String, SchematicType, String> arenaMode = ArenaMode.getBySchemType(type);
|
||||
if (!arenaMode.Server.Ranked) return;
|
||||
|
||||
if (publicVsPrivate(fightEndsPacket))
|
||||
return;
|
||||
|
||||
@@ -20,14 +20,15 @@
|
||||
package de.steamwar.velocitycore.network.handlers;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import de.steamwar.velocitycore.ServerStarter;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.client.PrepareSchemPacket;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import de.steamwar.velocitycore.ServerStarter;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
|
||||
@Linked
|
||||
public class PrepareSchemHandler extends PacketHandler {
|
||||
@@ -36,7 +37,7 @@ public class PrepareSchemHandler extends PacketHandler {
|
||||
public void handle(PrepareSchemPacket packet) {
|
||||
Player player = VelocityCore.getProxy().getPlayer(SteamwarUser.get(packet.getPlayer()).getUUID()).orElse(null);
|
||||
int schematicID = packet.getSchem();
|
||||
ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType()));
|
||||
GameModeConfig<String, SchematicType, String> mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType()));
|
||||
|
||||
new ServerStarter().test(mode, mode.getRandomMap(), player).prepare(schematicID).start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user