From 118a8e8277dca28ea4489ac46d021342b025f6b3 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 17 Dec 2021 20:15:19 +0100 Subject: [PATCH 1/3] Add optional Material to SchematicType --- .../src/de/steamwar/sql/SchematicType.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java index 5fe5715..aba29ad 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java @@ -20,6 +20,8 @@ package de.steamwar.sql; import de.steamwar.core.Core; +import de.steamwar.inventory.SWItem; +import org.bukkit.Material; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; @@ -27,7 +29,7 @@ import java.util.*; import java.util.stream.Collectors; 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, null); //Has to stay publicly availible private static final Map fromDB; private static final List types; @@ -54,14 +56,16 @@ public class SchematicType { continue; SchematicType checktype = null; + String materialString = config.getString("material"); + Material material = materialString != null ? SWItem.getMaterial(materialString) : null; if(!config.getStringList("CheckQuestions").isEmpty()) { - checktype = new SchematicType("C" + type, "C" + shortcut, Type.CHECK_TYPE, null); + checktype = new SchematicType("C" + type, "C" + shortcut, Type.CHECK_TYPE, null, material); tmpTypes.add(checktype); tmpFromDB.put(checktype.toDB(), checktype); } - SchematicType current = new SchematicType(type, shortcut, config.isConfigurationSection("Server") ? Type.FIGHT_TYPE : Type.NORMAL, checktype); + SchematicType current = new SchematicType(type, shortcut, config.isConfigurationSection("Server") ? Type.FIGHT_TYPE : Type.NORMAL, checktype, material); tmpTypes.add(current); tmpFromDB.put(type.toLowerCase(), current); } @@ -75,12 +79,14 @@ public class SchematicType { private final String kuerzel; private final Type type; private final SchematicType checkType; + private final Material material; - private SchematicType(String name, String kuerzel, Type type, SchematicType checkType){ + private SchematicType(String name, String kuerzel, Type type, SchematicType checkType, Material material){ this.name = name; this.kuerzel = kuerzel; this.type = type; this.checkType = checkType; + this.material = material == null ? Material.STONE_BUTTON : material; } public boolean isAssignable(){ @@ -111,6 +117,10 @@ public class SchematicType { return kuerzel; } + public Material getMaterial() { + return material; + } + public String toDB(){ return name.toLowerCase(); } From a63dbafd2b395942987ca481d086612a6b47b06c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 19 Dec 2021 11:05:35 +0100 Subject: [PATCH 2/3] Fix SchematicType --- SpigotCore_Main/src/de/steamwar/sql/SchematicType.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java index aba29ad..241beff 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java @@ -29,7 +29,7 @@ import java.util.*; import java.util.stream.Collectors; public class SchematicType { - public static final SchematicType Normal = new SchematicType("Normal", "", Type.NORMAL, null, null); //Has to stay publicly availible + public static final SchematicType Normal = new SchematicType("Normal", "", Type.NORMAL, null, SWItem.getMaterial("STONE_BUTTON")); //Has to stay publicly availible private static final Map fromDB; private static final List types; @@ -56,8 +56,8 @@ public class SchematicType { continue; SchematicType checktype = null; - String materialString = config.getString("material"); - Material material = materialString != null ? SWItem.getMaterial(materialString) : null; + String materialString = config.getString("Schematic.Material"); + Material material = materialString != null ? SWItem.getMaterial(materialString) : SWItem.getMaterial("STONE_BUTTON"); if(!config.getStringList("CheckQuestions").isEmpty()) { checktype = new SchematicType("C" + type, "C" + shortcut, Type.CHECK_TYPE, null, material); @@ -86,7 +86,7 @@ public class SchematicType { this.kuerzel = kuerzel; this.type = type; this.checkType = checkType; - this.material = material == null ? Material.STONE_BUTTON : material; + this.material = material; } public boolean isAssignable(){ From af956db60b4c80ef119e858ea73d16f3b80dcd8d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 19 Dec 2021 17:54:44 +0100 Subject: [PATCH 3/3] Fix SchematicType --- SpigotCore_Main/src/de/steamwar/sql/SchematicType.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java index 241beff..5b5bd0d 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java @@ -56,8 +56,7 @@ public class SchematicType { continue; SchematicType checktype = null; - String materialString = config.getString("Schematic.Material"); - Material material = materialString != null ? SWItem.getMaterial(materialString) : SWItem.getMaterial("STONE_BUTTON"); + Material material = SWItem.getMaterial(config.getString("Schematic.Material", "STONE_BUTTON")); if(!config.getStringList("CheckQuestions").isEmpty()) { checktype = new SchematicType("C" + type, "C" + shortcut, Type.CHECK_TYPE, null, material);