Dieser Commit ist enthalten in:
Ursprung
84eba0a156
Commit
05cd8fd648
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.sql;
|
package de.steamwar.sql;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -33,12 +32,7 @@ public class SchematicType {
|
|||||||
private static final List<SchematicType> types;
|
private static final List<SchematicType> types;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
File file = new File(Core.getInstance().getDataFolder(), "SchematicTypes.yml");
|
File folder = new File(Core.getInstance().getDataFolder().getParentFile(), "FightSystem");
|
||||||
|
|
||||||
if(!file.exists())
|
|
||||||
throw new SecurityException("SchematicType-ConfigFile not found!");
|
|
||||||
|
|
||||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
|
|
||||||
|
|
||||||
List<SchematicType> tmpTypes = new LinkedList<>();
|
List<SchematicType> tmpTypes = new LinkedList<>();
|
||||||
Map<String, SchematicType> tmpFromDB = new HashMap<>();
|
Map<String, SchematicType> tmpFromDB = new HashMap<>();
|
||||||
@ -46,14 +40,31 @@ 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(false)){
|
if(folder.exists()) {
|
||||||
ConfigurationSection section = config.getConfigurationSection(type);
|
for(File configFile : folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))) {
|
||||||
assert section != null;
|
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
String checktype = section.getString("checktype");
|
if(!config.isConfigurationSection("Schematic"))
|
||||||
SchematicType current = new SchematicType(type, section.getString("kuerzel"), Type.valueOf(section.getString("type")), checktype != null ? tmpFromDB.get(checktype.toLowerCase()) : null);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
SchematicType current = new SchematicType(type, shortcut, config.isConfigurationSection("Server") ? Type.FIGHT_TYPE : Type.NORMAL, checktype);
|
||||||
tmpTypes.add(current);
|
tmpTypes.add(current);
|
||||||
tmpFromDB.put(type.toLowerCase(), current);
|
tmpFromDB.put(type.toLowerCase(), current);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fromDB = Collections.unmodifiableMap(tmpFromDB);
|
fromDB = Collections.unmodifiableMap(tmpFromDB);
|
||||||
types = Collections.unmodifiableList(tmpTypes);
|
types = Collections.unmodifiableList(tmpTypes);
|
||||||
@ -62,7 +73,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