|
|
|
@ -50,26 +50,6 @@ public class SchematicCommand extends SWCommand {
|
|
|
|
|
super("schematic", "/schematic", "schem", "/schem");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<String> getNodeTabcomplete(SteamwarUser user, String[] strings, String s) {
|
|
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
|
boolean sws = s.startsWith("/");
|
|
|
|
|
if (sws) {
|
|
|
|
|
s = s.substring(1);
|
|
|
|
|
}
|
|
|
|
|
if (s.contains("/")) {
|
|
|
|
|
String preTab = s.substring(0, s.lastIndexOf("/") + 1);
|
|
|
|
|
SchematicNode pa = mapNode(user, strings, preTab);
|
|
|
|
|
if (pa == null) return Collections.emptyList();
|
|
|
|
|
List<SchematicNode> nodes = SchematicNode.getSchematicNodeInNode(pa);
|
|
|
|
|
nodes.forEach(node -> list.add(node.generateBreadcrumbs(user)));
|
|
|
|
|
} else {
|
|
|
|
|
List<SchematicNode> nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0);
|
|
|
|
|
nodes.forEach(node -> list.add((sws ? "/" : "") + node.getName() + (node.isDir() ? "/" : "")));
|
|
|
|
|
}
|
|
|
|
|
list.remove("//copy");
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("gui")
|
|
|
|
|
public void gui(Player player) {
|
|
|
|
|
GUI.open(player);
|
|
|
|
@ -87,45 +67,6 @@ public class SchematicCommand extends SWCommand {
|
|
|
|
|
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(SteamwarUser.get(player.getUniqueId()).getId(), 0), page, "", false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static SchematicNode mapNode(SteamwarUser user, String[] previousArguments, String s) {
|
|
|
|
|
if (s.startsWith("/")) {
|
|
|
|
|
s = s.substring(1);
|
|
|
|
|
}
|
|
|
|
|
if (s.isEmpty()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (s.contains("/")) {
|
|
|
|
|
String[] layers = s.split("/");
|
|
|
|
|
SchematicNode currentNode = null;
|
|
|
|
|
for (int i = 0; i < layers.length; i++) {
|
|
|
|
|
int finalI = i;
|
|
|
|
|
List<SchematicNode> nodes;
|
|
|
|
|
if (currentNode == null) {
|
|
|
|
|
nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0).stream().filter(node -> node.getName().equals(layers[finalI])).collect(Collectors.toList());
|
|
|
|
|
} else {
|
|
|
|
|
nodes = SchematicNode.getSchematicNodeInNode(currentNode).stream().filter(node -> node.getName().equals(layers[finalI])).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
if (nodes.isEmpty()) {
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
currentNode = nodes.get(0);
|
|
|
|
|
if (!currentNode.isDir() && i != layers.length - 1) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return currentNode;
|
|
|
|
|
} else {
|
|
|
|
|
String finalS = s;
|
|
|
|
|
List<SchematicNode> nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0).stream().filter(node -> node.getName().equals(finalS)).collect(Collectors.toList());
|
|
|
|
|
if (nodes.isEmpty()) {
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
return nodes.get(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register(help = true)
|
|
|
|
|
public void genericHelp(Player player, String... args) {
|
|
|
|
|
player.sendMessage(SchematicSystem.PREFIX + "Befehle§8:");
|
|
|
|
@ -893,4 +834,63 @@ public class SchematicCommand extends SWCommand {
|
|
|
|
|
AUSFAHREN,
|
|
|
|
|
NORMAL
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<String> getNodeTabcomplete(SteamwarUser user, String[] strings, String s) {
|
|
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
|
boolean sws = s.startsWith("/");
|
|
|
|
|
if (sws) {
|
|
|
|
|
s = s.substring(1);
|
|
|
|
|
}
|
|
|
|
|
if (s.contains("/")) {
|
|
|
|
|
String preTab = s.substring(0, s.lastIndexOf("/") + 1);
|
|
|
|
|
SchematicNode pa = mapNode(user, strings, preTab);
|
|
|
|
|
if (pa == null) return Collections.emptyList();
|
|
|
|
|
List<SchematicNode> nodes = SchematicNode.getSchematicNodeInNode(pa);
|
|
|
|
|
nodes.forEach(node -> list.add(node.generateBreadcrumbs(user)));
|
|
|
|
|
} else {
|
|
|
|
|
List<SchematicNode> nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0);
|
|
|
|
|
nodes.forEach(node -> list.add((sws ? "/" : "") + node.getName() + (node.isDir() ? "/" : "")));
|
|
|
|
|
}
|
|
|
|
|
list.remove("//copy");
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static SchematicNode mapNode(SteamwarUser user, String[] previousArguments, String s) {
|
|
|
|
|
if (s.startsWith("/")) {
|
|
|
|
|
s = s.substring(1);
|
|
|
|
|
}
|
|
|
|
|
if (s.isEmpty()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (s.contains("/")) {
|
|
|
|
|
String[] layers = s.split("/");
|
|
|
|
|
SchematicNode currentNode = null;
|
|
|
|
|
for (int i = 0; i < layers.length; i++) {
|
|
|
|
|
int finalI = i;
|
|
|
|
|
List<SchematicNode> nodes;
|
|
|
|
|
if (currentNode == null) {
|
|
|
|
|
nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0).stream().filter(node -> node.getName().equals(layers[finalI])).collect(Collectors.toList());
|
|
|
|
|
} else {
|
|
|
|
|
nodes = SchematicNode.getSchematicNodeInNode(currentNode).stream().filter(node -> node.getName().equals(layers[finalI])).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
if (nodes.isEmpty()) {
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
currentNode = nodes.get(0);
|
|
|
|
|
if (!currentNode.isDir() && i != layers.length - 1) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return currentNode;
|
|
|
|
|
} else {
|
|
|
|
|
String finalS = s;
|
|
|
|
|
List<SchematicNode> nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0).stream().filter(node -> node.getName().equals(finalS)).collect(Collectors.toList());
|
|
|
|
|
if (nodes.isEmpty()) {
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
return nodes.get(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|