SteamWar/SpigotCore
Archiviert
13
0

Fixing minor bugs

Dieser Commit ist enthalten in:
Chaoscaot 2021-03-14 18:08:03 +01:00
Ursprung 8ca2d97034
Commit a2d8d1eb3a

Datei anzeigen

@ -30,6 +30,7 @@ import java.sql.Blob;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.function.Predicate;
public class SchematicNode {
@ -184,7 +185,8 @@ public class SchematicNode {
}
public static List<SchematicNode> getSchematicsOfType(int owner, String schemType, Integer parent) {
List<SchematicNode> schems = getAllSchematicsOfType(owner, schemType);
List<SchematicNode> schems = getAllSchematicsAccessibleByUser(owner);
schems.removeIf(node -> !node.getType().equals(schemType));
Map<Integer, SchematicNode> nodesInParent = new LinkedHashMap<>();
for (SchematicNode schematicNode : schems) {
SchematicNode currentNode = schematicNode;
@ -222,7 +224,7 @@ public class SchematicNode {
throw new SecurityException("Failed listing schematics", e);
}
}
return null;
return Collections.emptyList();
}
public static List<SchematicNode> getAllSchematicsAccessibleByUser(int user) {
@ -237,15 +239,29 @@ public class SchematicNode {
}
}
public static List<SchematicNode> deepGet(Integer parent, Predicate<SchematicNode> filter) {
List<SchematicNode> finalList = new ArrayList<>();
List<SchematicNode> nodes = SchematicNode.getSchematicNodeInNode(parent);
nodes.forEach(node -> {
if(node.isDir()) {
finalList.addAll(deepGet(node.getId(), filter));
}else {
if(filter.test(node))
finalList.add(node);
}
});
return finalList;
}
private final int id;
private final int owner;
private String name;
private int parent;
private Integer parent;
private String item;
private String type;
private boolean schemFormat;
private int rank;
private boolean isDir;
private final boolean isDir;
private SchematicNode(ResultSet set) throws SQLException {
id = set.getInt("NodeId");
@ -353,7 +369,7 @@ public class SchematicNode {
private void updateDB() {
SQL.update("UPDATE SchematicNode SET NodeName = ?, NodeOwner = ?, ParentNode = ?, NodeItem = ?, NodeType = ?, NodeRank = ? WHERE NodeId = ?",
name, owner, parent, item, type, rank, id);
name, owner, parent == 0?null:parent, item, type, rank, id);
}
public void delete() {