From 1758b4b9aa47f06fceb01ac3aab0129345820407 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 26 Jul 2021 19:57:00 +0200 Subject: [PATCH] More [TM] Signed-off-by: Chaoscaot --- SchematicSystem_Main/pom.xml | 9 -- .../schematicsystem/CheckSchemType.java | 1 - .../commands/SchematicCommand.java | 118 +++++++++--------- SchematicSystem_Main/src/plugin.yml | 5 - 4 files changed, 59 insertions(+), 74 deletions(-) diff --git a/SchematicSystem_Main/pom.xml b/SchematicSystem_Main/pom.xml index 17cb6e0..4b5ab42 100644 --- a/SchematicSystem_Main/pom.xml +++ b/SchematicSystem_Main/pom.xml @@ -48,15 +48,6 @@ schematicsystem - - - - maven-restlet - Public online Restlet repository - http://maven.restlet.org - - - steamwar diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java index 4858dfe..1cfb616 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java @@ -20,7 +20,6 @@ package de.steamwar.schematicsystem; import de.steamwar.core.VersionedCallable; -import de.steamwar.sql.Schematic; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicType; import org.bukkit.configuration.ConfigurationSection; diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index 61b6aff..9da5f6a 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -50,26 +50,6 @@ public class SchematicCommand extends SWCommand { super("schematic", "/schematic", "schem", "/schem"); } - private static List getNodeTabcomplete(SteamwarUser user, String[] strings, String s) { - List 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 nodes = SchematicNode.getSchematicNodeInNode(pa); - nodes.forEach(node -> list.add(node.generateBreadcrumbs(user))); - } else { - List 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 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 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 getNodeTabcomplete(SteamwarUser user, String[] strings, String s) { + List 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 nodes = SchematicNode.getSchematicNodeInNode(pa); + nodes.forEach(node -> list.add(node.generateBreadcrumbs(user))); + } else { + List 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 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 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); + } + } + } } diff --git a/SchematicSystem_Main/src/plugin.yml b/SchematicSystem_Main/src/plugin.yml index 3855305..9670206 100644 --- a/SchematicSystem_Main/src/plugin.yml +++ b/SchematicSystem_Main/src/plugin.yml @@ -7,9 +7,4 @@ website: steamwar.de api-version: "1.13" commands: - #schem: - # aliases: - # - schematic - # - /schematic - # - /schem check: \ No newline at end of file