From 59cac59fe924074378aad0c17b78ed46d07edcb7 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 25 Jan 2020 12:51:29 +0100 Subject: [PATCH 1/4] Revert "Hotfix static instanciation" This reverts commit 86254479 --- SpigotCore_Main/src/de/steamwar/sql/SchematicType.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java index f421352..c1e6f9e 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java @@ -113,9 +113,9 @@ public enum SchematicType { return kuerzel; } - public String toDB(){ - return name().toLowerCase(); - } + /*public String toDB(){ + return name.toLowerCase(); + }*/ public static SchematicType fromDB(String input){ return fromDB.getOrDefault(input.toLowerCase(), null); From f34cfdd254e6f2912793b9ee514e0e6ec198d0d3 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 25 Jan 2020 12:51:45 +0100 Subject: [PATCH 2/4] Revert "Hotrevert to static instanciation" This reverts commit 9eb46e7a --- .../src/de/steamwar/sql/SchematicType.java | 73 +++++-------------- 1 file changed, 18 insertions(+), 55 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java index c1e6f9e..32c81dd 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java @@ -1,49 +1,16 @@ package de.steamwar.sql; -import java.util.HashMap; -import java.util.Map; +import de.steamwar.core.Core; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; -public enum SchematicType { - Normal("", Type.NORMAL), - CAirShip("CAS", Type.CHECK_TYPE), - CWarGear("CWG", Type.CHECK_TYPE), - 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), +import java.io.File; +import java.util.*; - CMPPWarGear1_12("CMPPWG", Type.CHECK_TYPE), - CSGWarShip("CSGWS", Type.CHECK_TYPE), - 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) +public class SchematicType { + public static final SchematicType Normal = new SchematicType("Normal", "", Type.NORMAL, null); //Has to stay publicly availible - ; - - - - //public static final SchematicType Normal = new SchematicType("Normal", "", Type.NORMAL, null); //Has to stay publicly availible - - private static final Map fromDB = new HashMap<>(); - static{ - for(SchematicType type : values()){ - fromDB.put(type.name().toLowerCase(), type); - } - } - /*private static final Map fromDB; + private static final Map fromDB; private static final List types; static{ @@ -67,19 +34,15 @@ public enum SchematicType { fromDB = Collections.unmodifiableMap(tmpFromDB); types = Collections.unmodifiableList(tmpTypes); - }*/ + } - //private final String name; + private final String name; private final String kuerzel; private final Type type; private SchematicType checkType; - private SchematicType(String kuerzel, Type type){ - this(kuerzel, type, null); - } - - private SchematicType(String kuerzel, Type type, SchematicType checkType){ - //this.name = name; + private SchematicType(String name, String kuerzel, Type type, SchematicType checkType){ + this.name = name; this.kuerzel = kuerzel; this.type = type; this.checkType = checkType; @@ -105,25 +68,25 @@ public enum SchematicType { return type == Type.NORMAL; } - /*public String name(){ + public String name(){ return name; - }*/ + } public String getKuerzel() { return kuerzel; } - /*public String toDB(){ + public String toDB(){ return name.toLowerCase(); - }*/ + } public static SchematicType fromDB(String input){ return fromDB.getOrDefault(input.toLowerCase(), null); } - /*public static List values(){ + public static List values(){ return types; - }*/ + } enum Type{ NORMAL, From f883220618b3876dcd743a92ac7ecf2fca86537d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 25 Jan 2020 13:47:16 +0100 Subject: [PATCH 3/4] Fixing dynamic implementation --- SpigotCore_Main/src/de/steamwar/sql/SchematicType.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java index 32c81dd..9d3cadd 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java @@ -23,11 +23,15 @@ public class SchematicType { List tmpTypes = new LinkedList<>(); Map tmpFromDB = new HashMap<>(); + + tmpTypes.add(Normal); + tmpFromDB.put(Normal.name().toLowerCase(), Normal); + for(String type : config.getKeys(false)){ ConfigurationSection section = config.getConfigurationSection(type); assert section != null; String checktype = section.getString("checktype"); - SchematicType current = new SchematicType(type, section.getString("kuerzel"), Type.valueOf(section.getString("type")), checktype != null ? fromDB(checktype) : null); + SchematicType current = new SchematicType(type, section.getString("kuerzel"), Type.valueOf(section.getString("type")), checktype != null ? tmpFromDB.get(checktype) : null); tmpTypes.add(current); tmpFromDB.put(type.toLowerCase(), current); } From ef01e8f68550d23d3cbc401d9c7b56ac5746a2d6 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 25 Jan 2020 14:04:07 +0100 Subject: [PATCH 4/4] Fixing checktype classification --- SpigotCore_Main/src/de/steamwar/sql/SchematicType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java index 9d3cadd..b51dc38 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java @@ -31,7 +31,7 @@ public class SchematicType { ConfigurationSection section = config.getConfigurationSection(type); assert section != null; String checktype = section.getString("checktype"); - SchematicType current = new SchematicType(type, section.getString("kuerzel"), Type.valueOf(section.getString("type")), checktype != null ? tmpFromDB.get(checktype) : null); + SchematicType current = new SchematicType(type, section.getString("kuerzel"), Type.valueOf(section.getString("type")), checktype != null ? tmpFromDB.get(checktype.toLowerCase()) : null); tmpTypes.add(current); tmpFromDB.put(type.toLowerCase(), current); }