From d31f3a31d13a53ca7462c9c8655bae964e1970bb Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 20 Nov 2021 21:05:34 +0100 Subject: [PATCH] Fix CheckCommand Signed-off-by: Chaoscaot --- .../steamwar/bungeecore/commands/CheckCommand.java | 2 +- src/de/steamwar/bungeecore/sql/SchematicNode.java | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java index 3ae1626..b44da4e 100644 --- a/src/de/steamwar/bungeecore/commands/CheckCommand.java +++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java @@ -239,7 +239,7 @@ public class CheckCommand extends BasicCommand { return; } - ArenaMode mode = ArenaMode.getBySchemType(schematic.getSchemtype()); + ArenaMode mode = ArenaMode.getBySchemType(schematic.getSchemtype().fightType()); SubserverSystem.startTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getId(), 0); currentCheckers.put(checker.getUniqueId(), this); currentSchems.put(schematic.getId(), this); diff --git a/src/de/steamwar/bungeecore/sql/SchematicNode.java b/src/de/steamwar/bungeecore/sql/SchematicNode.java index 83e9391..cea408c 100644 --- a/src/de/steamwar/bungeecore/sql/SchematicNode.java +++ b/src/de/steamwar/bungeecore/sql/SchematicNode.java @@ -32,7 +32,6 @@ import java.util.function.Predicate; import java.util.zip.GZIPInputStream; public class SchematicNode { - private static final Statement createNode = new Statement("INSERT INTO SchematicNode (NodeName, NodeOwner, ParentNode, NodeType, NodeItem) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE NodeName = VALUES(NodeName), ParentNode = VALUES(ParentNode), NodeItem = VALUES(NodeItem), NodeType = VALUES(NodeType), NodeItem = VALUES(NodeItem)"); private static final Statement getSchematicNode_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeName = ? AND ParentNode is NULL"); private static final Statement getSchematicNode = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeName = ? AND ParentNode = ?"); @@ -69,7 +68,7 @@ public class SchematicNode { } public static SchematicNode createSchematicNode(int owner, String name, Integer parent, String type, String item) { - if (parent == 0) + if (parent != null && parent == 0) parent = null; createNode.update(name, owner, parent, type, item); return getSchematicNode(owner, name, parent); @@ -86,6 +85,9 @@ public class SchematicNode { owner = set.getInt("NodeOwner"); name = set.getString("NodeName"); parent = set.getInt("ParentNode"); + if(set.wasNull()) { + parent = null; + } item = set.getString("NodeItem"); type = set.getString("NodeType"); lastUpdate = set.getTimestamp("LastUpdate"); @@ -409,6 +411,7 @@ public class SchematicNode { } public SchematicNode getParentNode() { + if(parent == null) return null; return SchematicNode.getSchematicNode(parent); } @@ -449,6 +452,13 @@ public class SchematicNode { this.brCache.clear(); } + public void delete() { + if (isDir()) { + getSchematicNodeInNode(getId()).forEach(SchematicNode::delete); + } + deleteNode.update(id); + } + @Override public boolean equals(Object obj) { if (!(obj instanceof SchematicNode))