Schemnodes Schematic System #93
@ -39,7 +39,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -51,23 +50,24 @@ public class SchematicCommand extends SWCommand {
|
||||
super("schematic", "/schematic", "schem", "/schem");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player player, String... args) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Befehle§8:");
|
||||
player.sendMessage("§8/§eschem gui §8- §7Öffnet die Schematic-GUI");
|
||||
player.sendMessage("§8/§eschem list §8- §7Zeigt dir deine Schematics an");
|
||||
player.sendMessage("§8/§eschem list public §8- §7Zeigt alle Public-Schematics");
|
||||
player.sendMessage("§8/§eschem search §8[§7Stichwort§8] - §7Sucht nach passenden Schematics");
|
||||
player.sendMessage("§8/§eschem load §8[§7Schematic§8] - §7Lädt eine Schematic");
|
||||
player.sendMessage("§8/§eschem save §8[§7Schematic§8] - §7Speichert dein Clipboard als Schematic");
|
||||
player.sendMessage("§8/§eschem changetype §8[§7Schematic§8] - §7Ändert die Art deiner Schematic");
|
||||
player.sendMessage("§8/§eschem delete §8[§7Schematic§8] - §7Löscht eine Schematic");
|
||||
player.sendMessage("§8/§eschem info §8[§7Schematic§8] - §7Zeigt dir Informationen zur Schematic");
|
||||
player.sendMessage("§8/§eschem download §8[§7Schematic§8] - §7Gibt dir einen Downloadlink (1 min gültig)");
|
||||
player.sendMessage("§8/§eschem addmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Fügt einen Spieler zu einer Schematic hinzu");
|
||||
player.sendMessage("§8/§eschem delmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic");
|
||||
player.sendMessage("§8/§eschem mkdirs §8[§7Ordner§8] - §7Erstelle einen Leeren Ordner");
|
||||
player.sendMessage("§8/§eschem move §8[§7Schematic§8] [§7Neuer Pfad§8] - §7Verschiebe eine Schematic");
|
||||
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")
|
||||
@ -87,24 +87,66 @@ public class SchematicCommand extends SWCommand {
|
||||
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(SteamwarUser.get(player.getUniqueId()).getId(), 0), page, "", false);
|
||||
}
|
||||
|
||||
@Register("list")
|
||||
public void schemList(Player player, @Mapper("dirMapper") SchematicNode node) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if(!node.isDir()) {
|
||||
player.sendMessage("haethate");
|
||||
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 {
|
||||
renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), 0, node.generateBreadcrumbs(user), node.getOwner()==0);
|
||||
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("list")
|
||||
public void schemList(Player player, @Mapper("dirMapper") SchematicNode node, int page) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if(!node.isDir()) {
|
||||
player.sendMessage("haethate");
|
||||
} else {
|
||||
renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), page, node.generateBreadcrumbs(user), node.getOwner()==0);
|
||||
}
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player player, String... args) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Befehle§8:");
|
||||
player.sendMessage("§8/§eschem gui §8- §7Öffnet die Schematic-GUI");
|
||||
player.sendMessage("§8/§eschem list §8- §7Zeigt dir deine Schematics an");
|
||||
player.sendMessage("§8/§eschem list public §8- §7Zeigt alle Public-Schematics");
|
||||
player.sendMessage("§8/§eschem search §8[§7Stichwort§8] - §7Sucht nach passenden Schematics");
|
||||
player.sendMessage("§8/§eschem load §8[§7Schematic§8] - §7Lädt eine Schematic");
|
||||
player.sendMessage("§8/§eschem save §8[§7Schematic§8] - §7Speichert dein Clipboard als Schematic");
|
||||
player.sendMessage("§8/§eschem changetype §8[§7Schematic§8] - §7Ändert die Art deiner Schematic");
|
||||
player.sendMessage("§8/§eschem delete §8[§7Schematic§8] - §7Löscht eine Schematic");
|
||||
player.sendMessage("§8/§eschem info §8[§7Schematic§8] - §7Zeigt dir Informationen zur Schematic");
|
||||
player.sendMessage("§8/§eschem download §8[§7Schematic§8] - §7Gibt dir einen Downloadlink (1 min gültig)");
|
||||
player.sendMessage("§8/§eschem addmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Fügt einen Spieler zu einer Schematic hinzu");
|
||||
player.sendMessage("§8/§eschem delmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic");
|
||||
player.sendMessage("§8/§eschem clearmember §8[§7Schematic§8] - §7Entfernt alle Spieler von der Schematic");
|
||||
player.sendMessage("§8/§eschem mkdir §8[§7Ordner§8] - §7Erstelle einen Leeren Ordner");
|
||||
player.sendMessage("§8/§eschem move §8[§7Schematic§8] [§7Neuer Pfad§8] - §7Verschiebe eine Schematic");
|
||||
player.sendMessage("§8/§eschem rename §8[§7Schematic§8] [§7Neuer Name§8] - §7Gib der Schematic einen neuen Namen");
|
||||
player.sendMessage("§8/§eschem addteam §8[§7Schematic§8] - §7Füge jeden aus deinem Team auf die Schematic hinzu");
|
||||
player.sendMessage("§8/§eschem remteam §8[§7Schematic§8] - §7Entferne jeden aus deinem Team von der Schematic");
|
||||
}
|
||||
|
||||
@Register({"list", "public"})
|
||||
@ -135,6 +177,40 @@ public class SchematicCommand extends SWCommand {
|
||||
schemInfo(player, node);
|
||||
}
|
||||
|
||||
@Register("list")
|
||||
public void schemList(Player player, @Mapper("dirMapper") SchematicNode node) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (!node.isDir()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Das ist eine Schematic und kein Ordner");
|
||||
} else {
|
||||
renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), 0, node.generateBreadcrumbs(user), node.getOwner() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Register({"info", "/"})
|
||||
public void schemInfoSecret(Player player) {
|
||||
player.sendMessage("§7--==( §eSteam§8War §eSchematic-System §7)==--");
|
||||
player.sendMessage("§7Anzahl an Schematics: §e" + SchematicNode.countNodes());
|
||||
player.sendMessage("§7Von dir einsehbar: §e" + SchematicNode.getAllSchematicsAccessibleByUser(SteamwarUser.get(player.getUniqueId()).getId()).size());
|
||||
player.sendMessage("§7Autoren: §e" + Arrays.toString(SchematicSystem.INSTANCE.getDescription().getAuthors().toArray()));
|
||||
}
|
||||
|
||||
@Register("list")
|
||||
public void schemList(Player player, @Mapper("dirMapper") SchematicNode node, int page) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (!node.isDir()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Das ist eine Schematic und kein Ordner");
|
||||
} else {
|
||||
renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), page, node.generateBreadcrumbs(user), node.getOwner() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Register({"l", "public"})
|
||||
@Register({"load", "public"})
|
||||
public void loadSchemPublic(Player player, @Mapper("publicMapper") SchematicNode node) {
|
||||
loadSchem(player, node);
|
||||
}
|
||||
|
||||
@Register("info")
|
||||
public void schemInfo(Player player, SchematicNode node) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
@ -161,7 +237,7 @@ public class SchematicCommand extends SWCommand {
|
||||
List<String> schematicMembers = new ArrayList<>();
|
||||
NodeMember.getNodeMembers(node.getId()).forEach(nodeMember -> schematicMembers.add(SteamwarUser.get(nodeMember.getMember()).getUserName()));
|
||||
if (!schematicMembers.isEmpty()) {
|
||||
player.sendMessage("§7Mitglieder: §e" + schematicMembers.toString());
|
||||
player.sendMessage("§7Mitglieder: §e" + schematicMembers);
|
||||
}
|
||||
|
||||
TextComponent base = new TextComponent();
|
||||
@ -179,6 +255,12 @@ public class SchematicCommand extends SWCommand {
|
||||
download.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eSchematic downloaden")));
|
||||
download.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem download " + node.generateBreadcrumbs(user)));
|
||||
base.addExtra(download);
|
||||
|
||||
TextComponent changeTyp = new TextComponent("[Typ ändern] ");
|
||||
changeTyp.setColor(ChatColor.BLUE);
|
||||
changeTyp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eSchematic Typ ändern")));
|
||||
changeTyp.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + node.generateBreadcrumbs(user)));
|
||||
base.addExtra(changeTyp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,26 +277,28 @@ public class SchematicCommand extends SWCommand {
|
||||
delMember.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem delmember " + node.generateBreadcrumbs(user) + " "));
|
||||
base.addExtra(delMember);
|
||||
|
||||
TextComponent delete = new TextComponent("[Delete] ");
|
||||
TextComponent move = new TextComponent("[Verschieben] ");
|
||||
move.setColor(ChatColor.DARK_PURPLE);
|
||||
move.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " verschieben")));
|
||||
move.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem move " + node.generateBreadcrumbs(user) + " " + node.generateBreadcrumbs(user).replace("/" + node.getName(), "")));
|
||||
base.addExtra(move);
|
||||
|
||||
TextComponent rename = new TextComponent("[Umbenennen] ");
|
||||
rename.setColor(ChatColor.LIGHT_PURPLE);
|
||||
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]"));
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
player.spigot().sendMessage(base);
|
||||
}
|
||||
|
||||
@Register({"info", "/"})
|
||||
public void schemInfoSecret(Player player) {
|
||||
player.sendMessage("§7--==( §eSteam§8War §eSchematic-System §7)==--");
|
||||
player.sendMessage("§7Anzahl an Schematics: §e" + SchematicNode.countNodes());
|
||||
player.sendMessage("§7Von dir einsehbar: §e" + SchematicNode.getAllSchematicsAccessibleByUser(SteamwarUser.get(player.getUniqueId()).getId()).size());
|
||||
player.sendMessage("§7Autoren: §e" + Arrays.toString(SchematicSystem.INSTANCE.getDescription().getAuthors().toArray()));
|
||||
}
|
||||
|
||||
@Register("l")
|
||||
@Register("load")
|
||||
public void loadSchem(Player player, SchematicNode node) {
|
||||
@ -235,12 +319,6 @@ public class SchematicCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Register({"l", "public"})
|
||||
@Register({"load", "public"})
|
||||
public void loadSchemPublic(Player player, @Mapper("publicMapper") SchematicNode node) {
|
||||
loadSchem(player, node);
|
||||
}
|
||||
|
||||
@Register("save")
|
||||
@Register("s")
|
||||
public void saveSchem(Player player, @Mapper("dirStringMapper") String name) {
|
||||
@ -277,11 +355,12 @@ public class SchematicCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newSchem)
|
||||
if (newSchem) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + node.getName() + " §7gespeichert");
|
||||
else
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + node.getName() + " §7überschrieben");
|
||||
}
|
||||
}
|
||||
|
||||
@Register("addmember")
|
||||
public void addMember(Player player, SchematicNode node, SteamwarUser target) {
|
||||
@ -296,18 +375,18 @@ public class SchematicCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
NodeMember member = NodeMember.getNodeMember(node.getId(), target.getId());
|
||||
if(member != null) {
|
||||
if (NodeMember.getNodeMember(node.getId(), target.getId()) != null) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist bereits auf diese Schematic geaddet");
|
||||
return;
|
||||
}
|
||||
member = NodeMember.createNodeMember(node.getId(), target.getId());
|
||||
NodeMember.createNodeMember(node.getId(), target.getId());
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §e" + target.getUserName() + " §7hat nun Zugriff auf die Schematic §e" + node.generateBreadcrumbs(user));
|
||||
|
||||
Player t = Bukkit.getPlayer(target.getUUID());
|
||||
if(t != null)
|
||||
if (t != null) {
|
||||
t.sendMessage(SchematicSystem.PREFIX + "Du hast nun Zugriff auf die Schematic §e" + node.getName() + " §7von §e" + player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Register("delmember")
|
||||
@Register("remmember")
|
||||
@ -331,6 +410,21 @@ public class SchematicCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Register("search")
|
||||
public void schemSearch(Player player, String quarry) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
List<SchematicNode> nodes = SchematicNode.filterSchems(user.getId(), node -> node.getName().contains(quarry));
|
||||
player.sendMessage("§7--==( §eSchematics §8(§e" + nodes.size() + "§8) §7)==--");
|
||||
nodes.forEach(node -> {
|
||||
String br = node.generateBreadcrumbs(user);
|
||||
TextComponent schematics = new TextComponent("§7" + br.replace(quarry, "§e§l" + quarry + "§7"));
|
||||
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eSchematic verwalten").create()));
|
||||
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem info " + br));
|
||||
|
||||
player.spigot().sendMessage(schematics);
|
||||
});
|
||||
}
|
||||
|
||||
@Register("download")
|
||||
public void download(Player player, SchematicNode node) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
@ -356,21 +450,6 @@ public class SchematicCommand extends SWCommand {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§7Ordner §e" + node.generateBreadcrumbs(user) + " §7erstellt");
|
||||
}
|
||||
|
||||
@Register("search")
|
||||
public void schemSearch(Player player, String quarry) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
List<SchematicNode> nodes = SchematicNode.filterSchems(user.getId(), node -> node.getName().contains(quarry));
|
||||
player.sendMessage("§7--==( §eSchematics §8(§e" + nodes.size() + "§8) §7)==--");
|
||||
nodes.forEach(node -> {
|
||||
String br = node.generateBreadcrumbs(user);
|
||||
TextComponent schematics = new TextComponent("§7" + br.replace(quarry, "§e§l" + quarry + "§7"));
|
||||
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eSchematic verwalten").create()));
|
||||
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem info " + br));
|
||||
|
||||
player.spigot().sendMessage(schematics);
|
||||
});
|
||||
}
|
||||
|
||||
@Register("changetype")
|
||||
public void changeType(Player player, SchematicNode node) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
@ -392,6 +471,11 @@ public class SchematicCommand extends SWCommand {
|
||||
|
||||
@Register("changetype")
|
||||
public void changeType(Player player, SchematicNode node, SchematicType type) {
|
||||
changeType(player, node, type, null);
|
||||
}
|
||||
|
||||
@Register("changetype")
|
||||
public void changeType(Player player, SchematicNode node, SchematicType type, Extend extend) {
|
||||
if (node.isDir()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cOrdner haben keinen Typen.");
|
||||
return;
|
||||
@ -424,6 +508,7 @@ public class SchematicCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (extend == null) {
|
||||
SWInventory inv = new SWInventory(player, 9, "Schematic ausfahren");
|
||||
inv.setItem(0, SWItem.getDye(10), (byte) 10, "§eSchematic ausfahren", click -> {
|
||||
new PrepareSchemPacket(SteamwarUser.get(player.getUniqueId()), node, type).send(player);
|
||||
@ -437,29 +522,119 @@ public class SchematicCommand extends SWCommand {
|
||||
});
|
||||
inv.setCallback(-999, click -> player.closeInventory());
|
||||
inv.open();
|
||||
} else if (extend == Extend.AUSFAHREN) {
|
||||
new PrepareSchemPacket(SteamwarUser.get(player.getUniqueId()), node, type).send(player);
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§aDer Vorbereitungsserver wird gestartet");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Register("move")
|
||||
public void renameMove(Player player, SchematicNode node, @Mapper("dirStringMapper") String name) {
|
||||
public void move(Player player, SchematicNode node, @Mapper("dirStringMapper") String name) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (node.getOwner() != user.getId()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen");
|
||||
return;
|
||||
}
|
||||
if (name.equals("/")) {
|
||||
node.setParent(0);
|
||||
} else {
|
||||
if (name.startsWith("/")) name = name.substring(1);
|
||||
if (name.endsWith("/")) name = name.substring(0, name.length() - 1);
|
||||
String[] layers = name.split("/");
|
||||
if (invalidSchemName(player, layers)) return;
|
||||
if(name.contains("/")) {
|
||||
SchematicNode newNode = mkdirs(layers, user, 1);
|
||||
SchematicNode newNode = mkdirs(layers, user, 0);
|
||||
node.setParent(newNode.getId());
|
||||
} else {
|
||||
node.setParent(0);
|
||||
}
|
||||
String schemName = layers[layers.length-1];
|
||||
node.setName(schemName);
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§7Die Schematic heist nun §7" + node.generateBreadcrumbs(user));
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§7Die Schematic ist nun unter §e" + node.generateBreadcrumbs(user) + " §7zu finden");
|
||||
}
|
||||
|
||||
@Register("rename")
|
||||
public void rename(Player player, SchematicNode node, String name) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (node.getOwner() != user.getId()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen");
|
||||
return;
|
||||
}
|
||||
if (invalidSchemName(player, new String[]{name})) {
|
||||
return;
|
||||
}
|
||||
node.setName(name);
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§7Die Schematic heist nun §e" + node.generateBreadcrumbs(user));
|
||||
}
|
||||
|
||||
@Register("addteam")
|
||||
public void addTeam(Player player, SchematicNode node) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (node.getOwner() != user.getId()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen");
|
||||
return;
|
||||
}
|
||||
Team team = Team.get(user.getTeam());
|
||||
if (team == null) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu bist in keinem Team");
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> added = new ArrayList<>();
|
||||
for (Integer member : team.getMembers()) {
|
||||
if (user.getId() == member) continue;
|
||||
if (NodeMember.getNodeMember(node.getId(), member) == null) {
|
||||
NodeMember.createNodeMember(node.getId(), member);
|
||||
added.add(SteamwarUser.get(member).getUserName());
|
||||
}
|
||||
}
|
||||
|
||||
Optional<String> reduced = added.stream().reduce((s, s2) -> s + ", " + s2);
|
||||
if (reduced.isPresent()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§7Die Spieler §e" + reduced.get() + " §7wurden auf die Schematic hinzugefügt");
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§7Es wurde kein Spieler hinzugefügt");
|
||||
}
|
||||
}
|
||||
|
||||
@Register("remteam")
|
||||
public void remTeam(Player player, SchematicNode node) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (node.getOwner() != user.getId()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen");
|
||||
return;
|
||||
}
|
||||
Team team = Team.get(user.getTeam());
|
||||
if (team == null) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu bist in keinem Team");
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> removed = new ArrayList<>();
|
||||
for (Integer member : team.getMembers()) {
|
||||
if (user.getId() == member) continue;
|
||||
NodeMember nodeMember = NodeMember.getNodeMember(node.getId(), member);
|
||||
if (nodeMember != null) {
|
||||
nodeMember.delete();
|
||||
removed.add(SteamwarUser.get(member).getUserName());
|
||||
}
|
||||
}
|
||||
|
||||
Optional<String> reduced = removed.stream().reduce((s, s2) -> s + ", " + s2);
|
||||
if (reduced.isPresent()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§7Die Spieler §e" + reduced.get() + " §7wurden von der Schematic entfernt");
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§7Es wurde kein Spieler entfernt");
|
||||
}
|
||||
}
|
||||
|
||||
@Register("remallmember")
|
||||
@Register("clearmember")
|
||||
public void clearMember(Player player, SchematicNode node) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (node.getOwner() != user.getId()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen");
|
||||
return;
|
||||
}
|
||||
|
||||
node.getMembers().forEach(NodeMember::delete);
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§7Alle Spieler wurden von der Schematic entfernt");
|
||||
}
|
||||
|
||||
private boolean invalidSchemName(Player player, String[] layers) {
|
||||
@ -502,6 +677,9 @@ public class SchematicCommand extends SWCommand {
|
||||
return currentNode;
|
||||
}
|
||||
|
||||
private final TypeMapper<SchematicNode> schematicCommandTypeMapper = nodeTypeMapper();
|
||||
private final TypeMapper<SchematicNode> publicCommandTypeMapper = publicNodeTypeMapper();
|
||||
|
||||
private void renderSchemlist(Player player, List<SchematicNode> nodes, int chunk, String breadcrumbs, boolean isPublic) {
|
||||
nodes.sort(Comparator.comparing(SchematicNode::getName));
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
@ -562,23 +740,37 @@ public class SchematicCommand extends SWCommand {
|
||||
beforePage.setColor(ChatColor.YELLOW);
|
||||
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eVorherige Seite").create()));
|
||||
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (isPublic ? "public" : "") + " " + breadcrumbs + " " + (chunk - 1)));
|
||||
}else
|
||||
} else {
|
||||
beforePage.setColor(ChatColor.RED);
|
||||
}
|
||||
|
||||
TextComponent nextPage = new TextComponent(" Seite (" + (chunk + 1) + "/" + Math.max(pageCount, 1) + ") »»");
|
||||
if (chunk < pageCount - 1) {
|
||||
nextPage.setColor(ChatColor.YELLOW);
|
||||
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eNächste Seite").create()));
|
||||
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (isPublic ? "public" : "") + " " + breadcrumbs + " " + (chunk + 1)));
|
||||
}else
|
||||
} else {
|
||||
nextPage.setColor(ChatColor.RED);
|
||||
}
|
||||
|
||||
beforePage.addExtra(nextPage);
|
||||
player.spigot().sendMessage(beforePage);
|
||||
}
|
||||
|
||||
private final TypeMapper<SchematicNode> schematicCommandTypeMapper = nodeTypeMapper();
|
||||
private final TypeMapper<SchematicNode> publicCommandTypeMapper = publicNodeTypeMapper();
|
||||
@Mapper("publicMapper")
|
||||
public TypeMapper<SchematicNode> publicNodeTypeMapper() {
|
||||
return new TypeMapper<SchematicNode>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return getNodeTabcomplete(SteamwarUser.get(0), strings, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return mapNode(SteamwarUser.get(0), previousArguments, s);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Mapper("memberMapper")
|
||||
public TypeMapper<NodeMember> nodeMemberTypeMapper() {
|
||||
@ -603,21 +795,6 @@ public class SchematicCommand extends SWCommand {
|
||||
};
|
||||
}
|
||||
|
||||
@Mapper("publicMapper")
|
||||
public TypeMapper<SchematicNode> publicNodeTypeMapper() {
|
||||
return new TypeMapper<SchematicNode>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return getNodeTabcomplete(SteamwarUser.get(0), strings, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return mapNode(SteamwarUser.get(0), previousArguments, s);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Mapper("dirMapper")
|
||||
public TypeMapper<SchematicNode> dirNodeTypeMapper() {
|
||||
return new TypeMapper<SchematicNode>() {
|
||||
@ -662,63 +839,21 @@ public class SchematicCommand extends SWCommand {
|
||||
};
|
||||
}
|
||||
|
||||
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");
|
||||
@Mapper("dirStringMapper")
|
||||
public TypeMapper<String> stringTabMapper() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
List<String> list = getNodeTabcomplete(SteamwarUser.get(((Player) commandSender).getUniqueId()), strings, s);
|
||||
list.removeIf(s1 -> !s1.endsWith("/"));
|
||||
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);
|
||||
}
|
||||
@Override
|
||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return s;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ClassMapper(SchematicNode.class)
|
||||
@ -751,19 +886,9 @@ public class SchematicCommand extends SWCommand {
|
||||
};
|
||||
}
|
||||
|
||||
@Mapper("dirStringMapper")
|
||||
public TypeMapper<String> stringTabMapper() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return getNodeTabcomplete(SteamwarUser.get(((Player) commandSender).getUniqueId()), strings, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return s;
|
||||
}
|
||||
};
|
||||
enum Extend {
|
||||
AUSFAHREN,
|
||||
NORMAL
|
||||
}
|
||||
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren