13
0

Schemnodes Schematic System #93

Zusammengeführt
Lixfel hat 30 Commits von nodes nach master 2021-12-27 16:30:26 +01:00 zusammengeführt
3 geänderte Dateien mit 15 neuen und 54 gelöschten Zeilen
Nur Änderungen aus Commit c22109daa9 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -26,7 +26,7 @@ import de.steamwar.inventory.SWListInv;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.sql.*; import de.steamwar.sql.*;
import de.steamwar.util.SchematicSelector; import de.steamwar.util.SchematicSelector;
import de.steamwar.util.SchematicSelectorInjectableAdapter; import de.steamwar.util.SchematicSelectorInjectable;
import de.steamwar.util.UtilGui; import de.steamwar.util.UtilGui;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -34,8 +34,7 @@ import org.bukkit.event.inventory.ClickType;
import java.util.*; import java.util.*;
import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.getUser; import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.*;
import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.invalidSchemName;
public class GUI { public class GUI {
@ -44,7 +43,7 @@ public class GUI {
} }
private static void list(Player player) { private static void list(Player player) {
SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectSchematic(), new SchematicSelectorInjectableAdapter() { SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectSchematic(), new SchematicSelectorInjectable() {
@Override @Override
public void onListRender(SchematicSelector selector, SWListInv<SchematicNode> inv, SchematicNode parent) { public void onListRender(SchematicSelector selector, SWListInv<SchematicNode> inv, SchematicNode parent) {
if(parent == null) { if(parent == null) {
@ -58,7 +57,8 @@ public class GUI {
}, node -> { }, node -> {
info(player, node); info(player, node);
}); });
selector.setTitle("Schematic GUI: {1}"); selector.setSingleDirOpen(false);
selector.setTitle(player1 -> "Schematic GUI: {1}");
selector.open(); selector.open();
} }

Datei anzeigen

@ -384,7 +384,7 @@ public class SchematicCommand extends SWCommand {
player.closeInventory(); player.closeInventory();
}); });
inv.setItem(8, SWItem.getDye(7), (byte) 7, "§eDirekt einsenden", click -> { inv.setItem(8, SWItem.getDye(7), (byte) 7, "§eDirekt einsenden", click -> {
node.setType(type.checkType().toDB()); node.setSchemtype(type.checkType());
player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic wird zeitnah überprüft"); player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic wird zeitnah überprüft");
player.closeInventory(); player.closeInventory();
}); });
@ -566,7 +566,7 @@ public class SchematicCommand extends SWCommand {
@Override @Override
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) { public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
return mapNode(SteamwarUser.get(0), previousArguments, s); return SchematicNode.getNodeFromPath(SteamwarUser.get(0), s);
} }
}; };
} }
@ -665,7 +665,7 @@ public class SchematicCommand extends SWCommand {
@Override @Override
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) { public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
return mapNode(getUser((Player) commandSender), previousArguments, s); return SchematicNode.getNodeFromPath(getUser((Player) commandSender), s);
} }
}; };
} }

Datei anzeigen

@ -40,45 +40,6 @@ public class SchematicCommandUtils {
private SchematicCommandUtils() { private SchematicCommandUtils() {
} }
public 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);
}
}
}
public static List<String> getNodeTabcomplete(SteamwarUser user, String[] strings, String s) { public static List<String> getNodeTabcomplete(SteamwarUser user, String[] strings, String s) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
boolean sws = s.startsWith("/"); boolean sws = s.startsWith("/");
@ -87,7 +48,7 @@ public class SchematicCommandUtils {
} }
if (s.contains("/")) { if (s.contains("/")) {
String preTab = s.substring(0, s.lastIndexOf("/") + 1); String preTab = s.substring(0, s.lastIndexOf("/") + 1);
SchematicNode pa = mapNode(user, strings, preTab); SchematicNode pa = SchematicNode.getNodeFromPath(user, preTab);
if (pa == null) return Collections.emptyList(); if (pa == null) return Collections.emptyList();
List<SchematicNode> nodes = SchematicNode.getSchematicNodeInNode(pa); List<SchematicNode> nodes = SchematicNode.getSchematicNodeInNode(pa);
nodes.forEach(node -> list.add((sws ? "/" : "") + node.generateBreadcrumbs(user))); nodes.forEach(node -> list.add((sws ? "/" : "") + node.generateBreadcrumbs(user)));
@ -281,14 +242,14 @@ public class SchematicCommandUtils {
rename.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " umbenennen"))); rename.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " umbenennen")));
rename.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem rename " + node.generateBreadcrumbs(user) + " [Neuer Name]")); rename.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem rename " + node.generateBreadcrumbs(user) + " [Neuer Name]"));
base.addExtra(rename); base.addExtra(rename);
TextComponent delete = new TextComponent("[Löschen] ");
delete.setColor(ChatColor.DARK_RED);
delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " Löschen")));
delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + node.generateBreadcrumbs(user)));
base.addExtra(delete);
} }
TextComponent delete = new TextComponent("[" + (node.getOwner()==user.getId()?"Löschen":"Entfernen") + "] ");
delete.setColor(ChatColor.DARK_RED);
delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " Löschen")));
delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + node.generateBreadcrumbs(user)));
base.addExtra(delete);
if (!base.getExtra().isEmpty()) { if (!base.getExtra().isEmpty()) {
player.spigot().sendMessage(base); player.spigot().sendMessage(base);
} }