SteamWar/SpigotCore
Archiviert
13
0

Merge branch 'reduceErrorSpam' of SteamWar/SpigotCore into master

Dieser Commit ist enthalten in:
Lixfel 2020-01-20 06:39:17 +01:00 committet von Gitea
Commit 58f26a5b3f
2 geänderte Dateien mit 42 neuen und 41 gelöschten Zeilen

Datei anzeigen

@ -20,6 +20,10 @@ public class SWException {
throwable = throwable.getCause(); throwable = throwable.getCause();
} }
SQL.update("INSERT INTO Exception (server, message, stacktrace) VALUES ('" + server + "', '" + SQL.disarmString(logEvent.getMessage().getFormattedMessage()) + "', '" + SQL.disarmString(stacktrace.toString()) + "')"); String message = logEvent.getMessage().getFormattedMessage();
if(message.startsWith("Block at"))
return;
SQL.update("INSERT INTO Exception (server, message, stacktrace) VALUES ('" + server + "', '" + SQL.disarmString(message) + "', '" + SQL.disarmString(stacktrace.toString()) + "')");
} }
} }

Datei anzeigen

@ -1,56 +1,45 @@
package de.steamwar.sql; package de.steamwar.sql;
import java.util.HashMap; import de.steamwar.core.Core;
import java.util.Map; import org.bukkit.configuration.file.YamlConfiguration;
public enum SchematicType { import java.io.File;
Normal("", Type.NORMAL), import java.util.*;
CAirShip("CAS", Type.CHECK_TYPE), public class SchematicType {
CWarGear("CWG", Type.CHECK_TYPE), public static final SchematicType Normal = new SchematicType("Normal", "", Type.NORMAL, null); //Has to stay publicly availible
CWarShip("CWS", Type.CHECK_TYPE),
CMiniWarGear("CMWG", Type.CHECK_TYPE),
AirShip("AS", Type.FIGHT_TYPE, CAirShip),
WarGear("WG", Type.FIGHT_TYPE, CWarGear),
WarShip("WS", Type.FIGHT_TYPE, CWarShip),
MiniWarGear("MWG", Type.FIGHT_TYPE, CMiniWarGear),
CMPPWarGear1_12("CMPPWG", Type.CHECK_TYPE), private static final Map<String, SchematicType> fromDB;
CSGWarShip("CSGWS", Type.CHECK_TYPE), private static final List<SchematicType> types;
CWarGear1_10("CWG1.10", Type.CHECK_TYPE),
CWarShip1_9("CWS1.9", Type.CHECK_TYPE),
CWarShip1_8("CWS1.8", Type.CHECK_TYPE),
CWarGear1_7("CWG1.7", Type.CHECK_TYPE),
WarGear1_14("WG1.14", Type.FIGHT_TYPE, null),
MPPWarGear1_12("MPPWG", Type.FIGHT_TYPE, CMPPWarGear1_12),
SGWarShip("SGWS", Type.FIGHT_TYPE, CSGWarShip),
WarGear1_12("WG1.12", Type.FIGHT_TYPE, null),
WarShip1_12("WS1.12", Type.FIGHT_TYPE, null),
MiniWarGear1_12("MWG1.12", Type.FIGHT_TYPE, null),
WarGear1_10("WG1.10", Type.FIGHT_TYPE, CWarGear1_10),
WarShip1_9("WS1.9", Type.FIGHT_TYPE, CWarShip1_9),
WarShip1_8("WS1.8", Type.FIGHT_TYPE, CWarShip1_8),
WarGear1_7("WG1.7", Type.FIGHT_TYPE, CWarGear1_7)
;
private static Map<String, SchematicType> fromDB = new HashMap<>();
static{ static{
for(SchematicType type : values()){ File file = new File(Core.getInstance().getDataFolder(), "SchematicTypes.yml");
fromDB.put(type.toDB(), type);
} if(!file.exists())
throw new SecurityException("SchematicType-ConfigFile not found!");
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
List<SchematicType> tmpTypes = new LinkedList<>();
Map<String, SchematicType> tmpFromDB = new HashMap<>();
for(String type : config.getKeys(false)){
String checktype = config.getString("checktype");
SchematicType current = new SchematicType(type, config.getString("kuerzel"), Type.valueOf(config.getString("type")), checktype != null ? fromDB(checktype) : null);
tmpTypes.add(current);
tmpFromDB.put(type, current);
} }
fromDB = Collections.unmodifiableMap(tmpFromDB);
types = Collections.unmodifiableList(tmpTypes);
}
private final String name;
private final String kuerzel; private final String kuerzel;
private final Type type; private final Type type;
private SchematicType checkType; private SchematicType checkType;
SchematicType(String kuerzel, Type type){ private SchematicType(String name, String kuerzel, Type type, SchematicType checkType){
this(kuerzel, type, null); this.name = name;
}
SchematicType(String kuerzel, Type type, SchematicType checkType){
this.kuerzel = kuerzel; this.kuerzel = kuerzel;
this.type = type; this.type = type;
this.checkType = checkType; this.checkType = checkType;
@ -76,18 +65,26 @@ public enum SchematicType {
return type == Type.NORMAL; return type == Type.NORMAL;
} }
public String name(){
return name;
}
public String getKuerzel() { public String getKuerzel() {
return kuerzel; return kuerzel;
} }
public String toDB(){ public String toDB(){
return name().toLowerCase(); return name.toLowerCase();
} }
public static SchematicType fromDB(String input){ public static SchematicType fromDB(String input){
return fromDB.get(input.toLowerCase()); return fromDB.get(input.toLowerCase());
} }
public static List<SchematicType> values(){
return types;
}
enum Type{ enum Type{
NORMAL, NORMAL,
CHECK_TYPE, CHECK_TYPE,