diff --git a/SpigotCore_Main/src/de/steamwar/inventory/SWListInv.java b/SpigotCore_Main/src/de/steamwar/inventory/SWListInv.java index 6803257..8d8cdc8 100644 --- a/SpigotCore_Main/src/de/steamwar/inventory/SWListInv.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SWListInv.java @@ -19,6 +19,7 @@ package de.steamwar.inventory; +import de.steamwar.sql.Schematic; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicType; import org.bukkit.Bukkit; @@ -115,7 +116,29 @@ public class SWListInv extends SWInventory { return onlinePlayers; } - public static List> getSchemList(SchematicType type, int steamwarUserId){ + public static List> getSchemList(SchematicType type, int steamwarUserId){ + List> schemList = new ArrayList<>(); + + List schems; + if(type == null) + schems = Schematic.getSchemsAccessibleByUser(steamwarUserId); + else + schems = Schematic.getSchemsOfType(steamwarUserId, type); + + for(Schematic s : schems){ + Material m; + if(s.getItem().isEmpty()) + m = SWItem.getMaterial("CAULDRON_ITEM"); + else + m = SWItem.getMaterial(s.getItem()); + SWItem item = new SWItem(m,"§e" + s.getSchemName()); + item.setEnchanted(s.getSchemType().fightType()); + schemList.add(new SWListEntry<>(item, s)); + } + return schemList; + } + + public static List> getSchemnodeList(SchematicType type, int steamwarUserId){ List> schemList = new ArrayList<>(); List schems; diff --git a/SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java index df2c121..58ff88d 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java @@ -160,7 +160,7 @@ public class SchematicNode { } public static List getAllSchematicsOfType(int owner, String schemType) { - ResultSet set = SQL.select("SELECT * FROM SchematicNode WHERE NodeOwner = ? AND SchemType = ?", owner, schemType); + ResultSet set = SQL.select("SELECT * FROM SchematicNode WHERE NodeOwner = ? AND NodeType = ?", owner, schemType); try { List nodes = new ArrayList<>(); while (set.next()) @@ -172,7 +172,7 @@ public class SchematicNode { } public static List getAllSchematicsOfType(String schemType) { - ResultSet set = SQL.select("SELECT * FROM SchematicNode WHERE SchemType = ?", schemType); + ResultSet set = SQL.select("SELECT * FROM SchematicNode WHERE NodeType = ?", schemType); try { List nodes = new ArrayList<>(); while (set.next()) @@ -184,8 +184,6 @@ public class SchematicNode { } public static List getSchematicsOfType(int owner, String schemType, Integer parent) { - if(parent != null && parent == 0) - parent = null; List schems = getAllSchematicsOfType(owner, schemType); Map nodesInParent = new LinkedHashMap<>(); for (SchematicNode schematicNode : schems) { @@ -354,8 +352,8 @@ public class SchematicNode { } private void updateDB() { - SQL.update("UPDATE SchematicNode SET NodeName = ?, NodeOwner = ?, ParentNode = ?, NodeItem = ?, NodeType = ? WHERE NodeId = ?", - name, owner, parent, item, type, id); + SQL.update("UPDATE SchematicNode SET NodeName = ?, NodeOwner = ?, ParentNode = ?, NodeItem = ?, NodeType = ?, NodeRank = ? WHERE NodeId = ?", + name, owner, parent, item, type, rank, id); } public void delete() {