From 4f8e527201bb8a3929f0858bb4ad67bf225664da Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 14 Nov 2021 11:23:52 +0100 Subject: [PATCH] Soem New Things Signed-off-by: Chaoscaot --- .../schematicsystem/commands/GUI.java | 126 ++++++++++-------- .../commands/SchematicCommand.java | 10 +- .../commands/SchematicCommandUtils.java | 2 +- 3 files changed, 83 insertions(+), 55 deletions(-) diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java index 38c3cd7..0ab051d 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java @@ -33,6 +33,7 @@ import org.bukkit.event.inventory.ClickType; import java.util.*; import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.getUser; +import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.invalidSchemName; public class GUI { @@ -46,7 +47,7 @@ public class GUI { for(SchematicNode schem : schems) { Material m; if (schem.getItem().isEmpty()) - m = SWItem.getMaterial("CAULDRON_ITEM"); + m = schem.isDir()?SWItem.getMaterial("CHEST"):SWItem.getMaterial("CAULDRON_ITEM"); else m = SWItem.getMaterial(schem.getItem()); @@ -59,46 +60,57 @@ public class GUI { schemList.add(new SWListInv.SWListEntry<>(item, schem)); } - SWListInv inv = new SWListInv<>(player, "§eSchematicliste §8- §r" + path, false, schemList, (clickType, schem) -> info(player, schem)); - if(publics) + SWListInv inv = new SWListInv<>(player, "§eSchematicliste §8- §r" + path, false, schemList, (clickType, schem) -> { + if(schem.isDir()) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + list(player, SchematicNode.getSchematicNodeInNode(schem), schem.getOwner() == 0, schem.generateBreadcrumbs(user)); + } else { + info(player, schem); + } + }); + if(publics) { inv.setItem(48, Material.BUCKET, "§7Eigene Schematics", clickType -> open(player)); - else + } else { inv.setItem(48, Material.GLASS, "§7Public Schematics", clickType -> list(player, SchematicNode.getSchematicsAccessibleByUser(0, null), true, "/")); + } + if(!publics && !path.equals("/")) { + inv.setItem(49, Material.ANVIL, "§7Ordner-Info", clickType -> info(player, SchematicSystem.SCHEMATIC_COMMAND.nodeTypeMapper().map(player, new String[0], path))); + } inv.setItem(50, Material.NAME_TAG, "§7Suche", clickType -> search(player, publics)); inv.open(); } private static void info(Player player, SchematicNode node) { SteamwarUser user = getUser(player); - if(node.isDir()) { - list(player, SchematicNode.getSchematicNodeInNode(node), node.getOwner() == 0, node.generateBreadcrumbs(user)); - } else { - SWInventory inv = new SWInventory(player, 9, node.generateBreadcrumbs(user)); + SWInventory inv = new SWInventory(player, 9, node.generateBreadcrumbs(user)); + if(!node.isDir()) { inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), "§eLaden", click -> { player.closeInventory(); SchematicSystem.SCHEMATIC_COMMAND.loadSchem(player, node); }); + } - if(node.getOwner() == user.getId()){ - if(node.getSchemtype().writeable()){ - List checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId()); - ListIterator i = checkedSchematics.listIterator(checkedSchematics.size()); - while(i.hasPrevious()) { - CheckedSchematic checkedSchematic = i.previous(); - if(checkedSchematic.getNode() == node.getId()) { - inv.setItem(1, SWItem.getDye(10), (byte) 10, "§eStatus " + node.getSchemtype().name(), Collections.singletonList("§7" + checkedSchematic.getDeclineReason()), false, click -> {}); - break; - } + if(node.getOwner() == user.getId()){ + if(!node.isDir() && node.getSchemtype().writeable()){ + List checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId()); + ListIterator i = checkedSchematics.listIterator(checkedSchematics.size()); + while(i.hasPrevious()) { + CheckedSchematic checkedSchematic = i.previous(); + if(checkedSchematic.getNode() == node.getId()) { + inv.setItem(1, SWItem.getDye(10), (byte) 10, "§eStatus " + node.getSchemtype().name(), Collections.singletonList("§7" + checkedSchematic.getDeclineReason()), false, click -> {}); + break; } } - Material mat = SWItem.getMaterial("CAULDRON_ITEM"); - if(node.getItem() != null && !node.getItem().equals("")) - mat = SWItem.getMaterial(node.getItem()); + } + Material mat = node.isDir()?SWItem.getMaterial("CHEST"):SWItem.getMaterial("CAULDRON_ITEM"); + if(node.getItem() != null && !node.getItem().equals("")) + mat = SWItem.getMaterial(node.getItem()); - inv.setItem(2, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> { - player.closeInventory(); - changeItem(player, node); - }); + inv.setItem(2, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> { + player.closeInventory(); + changeItem(player, node); + }); + if(!node.isDir()) { inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> { player.closeInventory(); changeType(player, node); @@ -107,34 +119,48 @@ public class GUI { player.closeInventory(); SchematicSystem.SCHEMATIC_COMMAND.download(player, node); }); - SWItem skull = SWItem.getPlayerSkull("MHF_STEVE"); - skull.setCallback(click -> { - player.closeInventory(); - delmembers(player, node); + } + SWItem skull = SWItem.getPlayerSkull("MHF_STEVE"); + skull.setCallback(click -> { + player.closeInventory(); + delmembers(player, node); + }); + skull.setName("§eMitglieder"); + inv.setItem(6, skull); + Material finalMat = mat; + inv.setItem(7, Material.NAME_TAG, "§eUmbenennen", clickType -> { + SWAnvilInv anvilInv = new SWAnvilInv(player, node.getName() + " umbenennen"); + anvilInv.setItem(finalMat); + anvilInv.setCallback(s -> { + if (!invalidSchemName(player, new String[]{s})) { + node.setName(s); + } + info(player, node); }); - skull.setName("§eMitglieder"); - inv.setItem(6, skull); - inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cLöschen", click -> { - player.closeInventory(); - delete(player, node); - }); - }else{ + anvilInv.open(); + }); + inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cLöschen", click -> { + player.closeInventory(); + delete(player, node); + }); + }else{ + if(!node.isDir()) { inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), click -> {}); - - SteamwarUser owneruser = SteamwarUser.get(node.getOwner()); - SWItem skull = SWItem.getPlayerSkull(owneruser.getUserName()); - skull.setName("§7von §e" + owneruser.getUserName()); - inv.setItem(6, skull); - - inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cZugriff entfernen", click -> { - player.closeInventory(); - delete(player, node); - }); } - inv.setCallback(-999, click -> player.closeInventory()); - inv.open(); + SteamwarUser owneruser = SteamwarUser.get(node.getOwner()); + SWItem skull = SWItem.getPlayerSkull(owneruser.getUserName()); + skull.setName("§7von §e" + owneruser.getUserName()); + inv.setItem(6, skull); + + inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cZugriff entfernen", click -> { + player.closeInventory(); + delete(player, node); + }); } + + inv.setCallback(-999, click -> player.closeInventory()); + inv.open(); } static void changeType(Player p, SchematicNode schem){ @@ -164,10 +190,6 @@ public class GUI { inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> { schem.delete(); - List checkedSchematics = CheckedSchematic.getLastDeclined(schem); - for(CheckedSchematic checkedSchematic : checkedSchematics) { - checkedSchematic.remove(); - } p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.generateBreadcrumbs(user) + " §7gelöscht"); p.closeInventory(); }); diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index fb88de4..2f73a49 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -174,7 +174,7 @@ public class SchematicCommand extends SWCommand { if (invalidSchemName(player, layers)) return; SchematicNode currentNode = mkdirs(layers, user, 1); - SchematicNode node = SchematicNode.getSchematicInParent(layers[layers.length - 1], currentNode == null ? 0 : currentNode.getId()); + SchematicNode node = SchematicNode.getSchematicNode(layers[layers.length - 1], currentNode == null ? 0 : currentNode.getId()); if (node != null && !node.getSchemtype().writeable()) { player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst diese Schematic nicht überschreiben"); return; @@ -285,7 +285,7 @@ public class SchematicCommand extends SWCommand { } player.sendMessage(SchematicSystem.PREFIX + "Dein Download Link:"); - player.sendMessage(DownloadSchematic.getLink(node)); + player.sendMessage(NodeDownload.getLink(node)); } @Register("dir") @@ -397,6 +397,12 @@ public class SchematicCommand extends SWCommand { player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen"); return; } + + if(SchematicNode.getAllParentsOfNode(node).contains(node)) { + player.sendMessage(SchematicSystem.PREFIX + "§cDas kann nur Fehler machen, vertrau mir!"); + return; + } + if (name.equals("/")) { node.setParent(0); } else { diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java index c4eb43c..930a85c 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java @@ -90,7 +90,7 @@ public class SchematicCommandUtils { 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))); + nodes.forEach(node -> list.add((sws ? "/" : "") + node.generateBreadcrumbs(user))); } else { List nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0); nodes.forEach(node -> list.add((sws ? "/" : "") + node.getName() + (node.isDir() ? "/" : "")));