Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
1588e74116
Commit
e32a223476
@ -20,8 +20,13 @@
|
|||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.sql.SchematicType;
|
import de.steamwar.bungeecore.sql.SchematicType;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.config.Configuration;
|
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.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ArenaMode {
|
public class ArenaMode {
|
||||||
@ -32,9 +37,18 @@ public class ArenaMode {
|
|||||||
private static final List<ArenaMode> allModes = new LinkedList<>();
|
private static final List<ArenaMode> allModes = new LinkedList<>();
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
|
|
||||||
static void init(Configuration config){
|
static {
|
||||||
for(String internalName : config.getKeys()){
|
File folder = new File(ProxyServer.getInstance().getPluginsFolder(), "FightSystem");
|
||||||
new ArenaMode(internalName, config.getSection(internalName));
|
|
||||||
|
for(File configFile : folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))) {
|
||||||
|
Configuration config;
|
||||||
|
try {
|
||||||
|
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new SecurityException("Could not load SchematicTypes", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
new ArenaMode(configFile.getName().replace(".yml", ""), config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,19 +98,16 @@ public class ArenaMode {
|
|||||||
private final String schemType;
|
private final String schemType;
|
||||||
|
|
||||||
private ArenaMode(String internalName, Configuration config){
|
private ArenaMode(String internalName, Configuration config){
|
||||||
this.folder = config.getString("folder");
|
this.folder = config.getString("Server.Folder");
|
||||||
this.serverJar = config.getString("serverJar");
|
this.serverJar = config.getString("Server.ServerJar");
|
||||||
this.config = config.getString("config");
|
this.config = internalName + ".yml";
|
||||||
this.maps = config.getStringList("maps");
|
this.maps = config.getStringList("Server.Maps");
|
||||||
this.displayName = config.getString("displayName", internalName);
|
this.displayName = config.getString("GameName", internalName);
|
||||||
if(config.contains("chatNames"))
|
this.chatNames = config.getStringList("Server.ChatNames");
|
||||||
this.chatNames = config.getStringList("chatNames");
|
this.schemType = config.getString("Schematic.Type", "").toLowerCase();
|
||||||
else
|
|
||||||
this.chatNames = Collections.emptyList();
|
|
||||||
this.historic = config.getBoolean("historic", false);
|
|
||||||
this.schemType = config.getString("schemType", "").toLowerCase();
|
|
||||||
|
|
||||||
this.ranked = config.getBoolean("ranked", false);
|
this.ranked = config.getBoolean("Server.Ranked", false);
|
||||||
|
this.historic = config.getBoolean("Server.Historic", false);
|
||||||
|
|
||||||
allModes.add(this);
|
allModes.add(this);
|
||||||
byInternal.put(internalName, this);
|
byInternal.put(internalName, this);
|
||||||
|
@ -269,8 +269,6 @@ public class BungeeCore extends Plugin {
|
|||||||
EVENT_MODE = config.getBoolean("eventmode");
|
EVENT_MODE = config.getBoolean("eventmode");
|
||||||
Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1]));
|
Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1]));
|
||||||
PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers"));
|
PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers"));
|
||||||
CheckCommand.loadCheckQuestions(config.getSection("checkquestions"));
|
|
||||||
CheckCommand.loadRanks(config.getSection("checkranks"));
|
|
||||||
Persistent.setChatPrefix(CHAT_PREFIX);
|
Persistent.setChatPrefix(CHAT_PREFIX);
|
||||||
Persistent.setLobbyServer(LOBBY_SERVER);
|
Persistent.setLobbyServer(LOBBY_SERVER);
|
||||||
|
|
||||||
@ -280,7 +278,6 @@ public class BungeeCore extends Plugin {
|
|||||||
config.getString("db.password")
|
config.getString("db.password")
|
||||||
);
|
);
|
||||||
|
|
||||||
ArenaMode.init(config.getSection("games"));
|
|
||||||
if (config.getSection("discord") != null) {
|
if (config.getSection("discord") != null) {
|
||||||
SteamwarDiscordBotConfig.loadConfig(config.getSection("discord"));
|
SteamwarDiscordBotConfig.loadConfig(config.getSection("discord"));
|
||||||
}
|
}
|
||||||
|
@ -47,16 +47,9 @@ public class CheckCommand extends BasicCommand {
|
|||||||
private static Map<UUID, CheckSession> currentCheckers = new HashMap<>();
|
private static Map<UUID, CheckSession> currentCheckers = new HashMap<>();
|
||||||
private static Map<Integer, CheckSession> currentSchems = new HashMap<>();
|
private static Map<Integer, CheckSession> currentSchems = new HashMap<>();
|
||||||
|
|
||||||
public static void loadCheckQuestions(Configuration config){
|
public static void setCheckQuestions(SchematicType checkType, Configuration config) {
|
||||||
for(String schemType : config.getKeys()){
|
checkQuestions.put(checkType, config.getStringList("CheckQuestions"));
|
||||||
checkQuestions.put(SchematicType.fromDB(schemType), config.getStringList(schemType));
|
ranks.put(checkType, config.getStringList("Ranks"));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadRanks(Configuration config){
|
|
||||||
for(String schemType : config.getKeys()){
|
|
||||||
ranks.put(SchematicType.fromDB(schemType), config.getStringList(schemType));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isChecking(ProxiedPlayer player){
|
public static boolean isChecking(ProxiedPlayer player){
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.sql;
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.config.Configuration;
|
import net.md_5.bungee.config.Configuration;
|
||||||
import net.md_5.bungee.config.ConfigurationProvider;
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
import net.md_5.bungee.config.YamlConfiguration;
|
import net.md_5.bungee.config.YamlConfiguration;
|
||||||
@ -35,18 +36,8 @@ public class SchematicType {
|
|||||||
private static final Map<SchematicType, SchematicType> fightType;
|
private static final Map<SchematicType, SchematicType> fightType;
|
||||||
private static final List<SchematicType> types;
|
private static final List<SchematicType> types;
|
||||||
|
|
||||||
static{
|
static {
|
||||||
File file = new File(BungeeCore.get().getDataFolder(), "SchematicTypes.yml");
|
File folder = new File(ProxyServer.getInstance().getPluginsFolder(), "FightSystem");
|
||||||
|
|
||||||
if(!file.exists())
|
|
||||||
throw new SecurityException("SchematicType-ConfigFile not found!");
|
|
||||||
|
|
||||||
Configuration config;
|
|
||||||
try {
|
|
||||||
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new SecurityException("Could not load SchematicTypes", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<SchematicType> tmpTypes = new LinkedList<>();
|
List<SchematicType> tmpTypes = new LinkedList<>();
|
||||||
Map<String, SchematicType> tmpFromDB = new HashMap<>();
|
Map<String, SchematicType> tmpFromDB = new HashMap<>();
|
||||||
@ -55,15 +46,37 @@ public class SchematicType {
|
|||||||
tmpTypes.add(Normal);
|
tmpTypes.add(Normal);
|
||||||
tmpFromDB.put(Normal.name().toLowerCase(), Normal);
|
tmpFromDB.put(Normal.name().toLowerCase(), Normal);
|
||||||
|
|
||||||
for(String type : config.getKeys()){
|
if(folder.exists()) {
|
||||||
Configuration section = config.getSection(type);
|
for(File configFile : folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))) {
|
||||||
assert section != null;
|
Configuration config;
|
||||||
String checktype = section.getString("checktype");
|
try {
|
||||||
SchematicType current = new SchematicType(type, section.getString("kuerzel"), Type.valueOf(section.getString("type")), checktype != null ? tmpFromDB.get(checktype.toLowerCase()) : null);
|
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||||
tmpTypes.add(current);
|
} catch (IOException e) {
|
||||||
if(current.checkType != null)
|
throw new SecurityException("Could not load SchematicTypes", e);
|
||||||
tmpFightType.put(current.checkType, current);
|
}
|
||||||
tmpFromDB.put(type.toLowerCase(), current);
|
|
||||||
|
if(!config.contains("Schematic"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String type = config.getString("Schematic.Type");
|
||||||
|
assert type != null;
|
||||||
|
String shortcut = config.getString("Schematic.Shortcut");
|
||||||
|
if(tmpFromDB.containsKey(type.toLowerCase()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
SchematicType checktype = null;
|
||||||
|
if(!config.getStringList("CheckQuestions").isEmpty()) {
|
||||||
|
checktype = new SchematicType("C" + type, "C" + shortcut, Type.CHECK_TYPE, null);
|
||||||
|
tmpTypes.add(checktype);
|
||||||
|
tmpFromDB.put(checktype.toDB(), checktype);
|
||||||
|
CheckCommand.setCheckQuestions(checktype, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
SchematicType current = new SchematicType(type, shortcut, config.getKeys().contains("Server") ? Type.FIGHT_TYPE : Type.NORMAL, checktype);
|
||||||
|
if(checktype != null)
|
||||||
|
tmpFightType.put(checktype, current);
|
||||||
|
tmpFromDB.put(type.toLowerCase(), current);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fromDB = Collections.unmodifiableMap(tmpFromDB);
|
fromDB = Collections.unmodifiableMap(tmpFromDB);
|
||||||
@ -74,7 +87,7 @@ public class SchematicType {
|
|||||||
private final String name;
|
private final String name;
|
||||||
private final String kuerzel;
|
private final String kuerzel;
|
||||||
private final Type type;
|
private final Type type;
|
||||||
private SchematicType checkType;
|
private final SchematicType checkType;
|
||||||
|
|
||||||
private SchematicType(String name, String kuerzel, Type type, SchematicType checkType){
|
private SchematicType(String name, String kuerzel, Type type, SchematicType checkType){
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren