Signed-off-by: Lixfel <git-5w3l@lixfel.de>
Dieser Commit ist enthalten in:
Ursprung
f6f568ee40
Commit
61d42c7cca
@ -21,15 +21,12 @@ package de.steamwar.bungeecore;
|
|||||||
|
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import net.md_5.bungee.config.Configuration;
|
|
||||||
import net.md_5.bungee.config.ConfigurationProvider;
|
|
||||||
import net.md_5.bungee.config.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ArenaMode {
|
public class ArenaMode {
|
||||||
|
|
||||||
@ -51,17 +48,17 @@ public class ArenaMode {
|
|||||||
bySchemType.clear();
|
bySchemType.clear();
|
||||||
allModes.clear();
|
allModes.clear();
|
||||||
|
|
||||||
|
Yaml yaml = new Yaml();
|
||||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||||
|
|
||||||
for(File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().toList()) {
|
for(File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().toList()) {
|
||||||
Configuration config;
|
Map<String, Object> config;
|
||||||
try {
|
try {
|
||||||
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
config = yaml.load(new FileInputStream(configFile));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new SecurityException("Could not load SchematicTypes", e);
|
throw new SecurityException("Could not load SchematicTypes", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config.contains("Server"))
|
if(config.containsKey("Server"))
|
||||||
new ArenaMode(configFile.getName().replace(".yml", ""), config);
|
new ArenaMode(configFile.getName().replace(".yml", ""), config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,19 +115,22 @@ public class ArenaMode {
|
|||||||
@Getter
|
@Getter
|
||||||
private final String schemType;
|
private final String schemType;
|
||||||
|
|
||||||
private ArenaMode(String internalName, Configuration config) {
|
private ArenaMode(String internalName, Map<String, Object> config) {
|
||||||
this.internalName = internalName;
|
this.internalName = internalName;
|
||||||
this.folder = config.getString("Server.Folder");
|
|
||||||
this.serverJar = config.getString("Server.ServerJar");
|
|
||||||
this.config = internalName + ".yml";
|
this.config = internalName + ".yml";
|
||||||
this.maps = config.getStringList("Server.Maps");
|
|
||||||
maps.forEach(map -> lowerToRealMapNames.put(map.toLowerCase(), map));
|
|
||||||
this.displayName = config.getString("GameName", internalName);
|
|
||||||
this.chatNames = config.getStringList("Server.ChatNames");
|
|
||||||
this.schemType = config.getString("Schematic.Type", "").toLowerCase();
|
|
||||||
|
|
||||||
this.ranked = config.getBoolean("Server.Ranked", false);
|
this.displayName = get(config, "GameName", internalName);
|
||||||
this.historic = config.getBoolean("Server.Historic", false);
|
Map<String, Object> server = get(config, "Server");
|
||||||
|
|
||||||
|
this.folder = get(server, "Folder");
|
||||||
|
this.serverJar = get(server, "ServerJar");
|
||||||
|
this.chatNames = get(server, "ChatNames");
|
||||||
|
this.maps = get(server, "Maps");
|
||||||
|
this.ranked = get(server, "Ranked", false);
|
||||||
|
this.historic = get(server, "Historic", false);
|
||||||
|
maps.forEach(map -> lowerToRealMapNames.put(map.toLowerCase(), map));
|
||||||
|
|
||||||
|
this.schemType = get(get(config, "Schematic"), "Type", "").toLowerCase();
|
||||||
|
|
||||||
allModes.add(this);
|
allModes.add(this);
|
||||||
byInternal.put(internalName, this);
|
byInternal.put(internalName, this);
|
||||||
@ -138,10 +138,17 @@ public class ArenaMode {
|
|||||||
byChat.put(name.toLowerCase(), this);
|
byChat.put(name.toLowerCase(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.schemType.equals(""))
|
if(!this.schemType.isEmpty())
|
||||||
bySchemType.put(SchematicType.fromDB(this.schemType), this);
|
bySchemType.put(SchematicType.fromDB(this.schemType), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <T> T get(Map<String, Object> config, String key) {
|
||||||
|
return (T) config.get(key);
|
||||||
|
}
|
||||||
|
private <T> T get(Map<String, Object> config, String key, T def) {
|
||||||
|
return (T) config.getOrDefault(key, def);
|
||||||
|
}
|
||||||
|
|
||||||
public String hasMap(String map){
|
public String hasMap(String map){
|
||||||
for(String m : maps){
|
for(String m : maps){
|
||||||
if(m.equalsIgnoreCase(map))
|
if(m.equalsIgnoreCase(map))
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren