From f36a2261208142951f8229f9e689d0b87bf87b54 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 17 Jan 2023 22:23:22 +0100 Subject: [PATCH] Fix: Use Cached BreadCrumbs --- .../schematicsystem/commands/GUI.java | 10 ++++----- .../commands/SchematicCommand.java | 22 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java index aced87a..19a9fde 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java @@ -92,7 +92,7 @@ public class GUI { private static void info(Player player, SchematicNode node, SchematicSelector back) { SteamwarUser user = getUser(player); - SWInventory inv = new SWInventory(player, 9 * 2, node.generateBreadcrumbs(user)); + SWInventory inv = new SWInventory(player, 9 * 2, node.generateBreadcrumbs()); if(!node.isDir()) { inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), SchematicSystem.MESSAGE.parse("GUI_INFO_LOAD", player), click -> { player.closeInventory(); @@ -237,9 +237,9 @@ public class GUI { private static void deleteOwn(Player p, SchematicNode schem, SchematicSelector back){ SteamwarUser user = getUser(p); - SWInventory inv = new SWInventory(p, 9, SchematicSystem.MESSAGE.parse("GUI_DELETE_OWN_TITLE", p, schem.generateBreadcrumbs(user))); + SWInventory inv = new SWInventory(p, 9, SchematicSystem.MESSAGE.parse("GUI_DELETE_OWN_TITLE", p, schem.generateBreadcrumbs())); inv.setItem(0, SWItem.getDye(1), (byte) 1, SchematicSystem.MESSAGE.parse("CONFIRM", p), click -> { - p.performCommand("schematic delete " + schem.generateBreadcrumbs(user)); + p.performCommand("schematic delete " + schem.generateBreadcrumbs()); if(back != null) { if(schem.isDir()) { @@ -256,12 +256,12 @@ public class GUI { private static void deleteMembership(Player p, SchematicNode schem, SchematicSelector back){ SteamwarUser user = getUser(p); - SWInventory inv = new SWInventory(p, 9, SchematicSystem.MESSAGE.parse("GUI_DELETE_MEMBER_TITLE", p, schem.generateBreadcrumbs(user))); + SWInventory inv = new SWInventory(p, 9, SchematicSystem.MESSAGE.parse("GUI_DELETE_MEMBER_TITLE", p, schem.generateBreadcrumbs())); inv.setItem(0, SWItem.getDye(1), (byte) 1, SchematicSystem.MESSAGE.parse("CONFIRM", p), click -> { NodeMember member = NodeMember.getNodeMember(schem.getId(), user.getId()); if(member != null) member.delete(); - SchematicSystem.MESSAGE.send("GUI_DELETE_MEMBER_DONE", p, schem.generateBreadcrumbs(user)); + SchematicSystem.MESSAGE.send("GUI_DELETE_MEMBER_DONE", p, schem.generateBreadcrumbs()); if(back != null) { if(schem.isDir()) { back.reOpenDirUp(); diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index 264c6bb..29f942d 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -116,7 +116,7 @@ public class SchematicCommand extends SWCommand { @Register("list") public void schemList(Player player, @Validator("isDirValidator") @Mapper("dirMapper") SchematicNode node, @OptionalValue("1") int page) { SteamwarUser user = getUser(player); - createCachedSchemList(player, SchematicNode.list(user, node.getId()), Math.max(page - 1, 0), node, SchematicListBehavior.builder().setPublics(node.getOwner() == 0).setPageCommandGen(value -> "/schem list " + (node.getOwner()==0?"public ":"") + node.generateBreadcrumbs(user) + " " + value).build()); + createCachedSchemList(player, SchematicNode.list(user, node.getId()), Math.max(page - 1, 0), node, SchematicListBehavior.builder().setPublics(node.getOwner() == 0).setPageCommandGen(value -> "/schem list " + (node.getOwner()==0?"public ":"") + node.generateBreadcrumbs() + " " + value).build()); } @Register({"info", "public"}) @@ -211,7 +211,7 @@ public class SchematicCommand extends SWCommand { return; } - SchematicSystem.MESSAGE.send(newSchem?"COMMAND_SAVE_DONE":"COMMAND_SAVE_OVERWRITE", player, node.generateBreadcrumbs(user)); + SchematicSystem.MESSAGE.send(newSchem?"COMMAND_SAVE_DONE":"COMMAND_SAVE_OVERWRITE", player, node.generateBreadcrumbs()); } @Register("addmember") @@ -248,7 +248,7 @@ public class SchematicCommand extends SWCommand { Player t = Bukkit.getPlayer(target.getUUID()); if (t != null) { - SchematicSystem.MESSAGE.send("COMMAND_ADD_ADDED", t, node.generateBreadcrumbs(target), player.getName()); + SchematicSystem.MESSAGE.send("COMMAND_ADD_ADDED", t, node.generateBreadcrumbs(), player.getName()); } } @@ -268,7 +268,7 @@ public class SchematicCommand extends SWCommand { List nodes = SchematicNode.deepGet(node.getId(), node1 -> node1.getOwner() != user.getId()); if (!nodes.isEmpty()) { for (SchematicNode schematicNode : nodes) { - SchematicNode newNode = mkdirs(schematicNode.generateBreadcrumbs(user).split("/"), target, 1); + SchematicNode newNode = mkdirs(schematicNode.generateBreadcrumbs().split("/"), target, 1); if(SchematicNode.getSchematicNode(schematicNode.getName(), newNode == null ? 0 : newNode.getId()) != null) { schematicNode.setName(schematicNode.getName() + "-" + Instant.now().getEpochSecond() % 1000); } @@ -277,7 +277,7 @@ public class SchematicCommand extends SWCommand { } member.delete(); - SchematicSystem.MESSAGE.send("COMMAND_DELMEM_DONE", player, target.getUserName(), node.generateBreadcrumbs(user)); + SchematicSystem.MESSAGE.send("COMMAND_DELMEM_DONE", player, target.getUserName(), node.generateBreadcrumbs()); Player t = Bukkit.getPlayer(target.getUUID()); if (t != null) { @@ -384,7 +384,7 @@ public class SchematicCommand extends SWCommand { String[] layers = name.split("/"); if (invalidSchemName(player, layers)) return; SchematicNode node = mkdirs(layers, user, 0); - SchematicSystem.MESSAGE.send("COMMAND_DIR_DONE", player, node.generateBreadcrumbs(user)); + SchematicSystem.MESSAGE.send("COMMAND_DIR_DONE", player, node.generateBreadcrumbs()); } @Register("changetype") @@ -399,7 +399,7 @@ public class SchematicCommand extends SWCommand { Clipboard finalClipboard = clipboard; - String breadcrumb = node.generateBreadcrumbs(user); + String breadcrumb = node.generateBreadcrumbs(); SchematicType.values().parallelStream() .filter(SchematicType::isAssignable) @@ -470,7 +470,7 @@ public class SchematicCommand extends SWCommand { return; } } - SchematicSystem.MESSAGE.send("COMMAND_MOVE_DONE", player, node.generateBreadcrumbs(user)); + SchematicSystem.MESSAGE.send("COMMAND_MOVE_DONE", player, node.generateBreadcrumbs()); } @Register("rename") @@ -484,7 +484,7 @@ public class SchematicCommand extends SWCommand { result.sendError(player); return; } - SchematicSystem.MESSAGE.send("COMMAND_RENAME_DONE", player, node.generateBreadcrumbs(user)); + SchematicSystem.MESSAGE.send("COMMAND_RENAME_DONE", player, node.generateBreadcrumbs()); } @Register("addteam") @@ -577,13 +577,13 @@ public class SchematicCommand extends SWCommand { if (node.isDir()) { if (SchematicNode.getSchematicNodeInNode(node).isEmpty()) { - SchematicSystem.MESSAGE.send("COMMAND_DELETE_DIR", player, node.generateBreadcrumbs(user)); + SchematicSystem.MESSAGE.send("COMMAND_DELETE_DIR", player, node.generateBreadcrumbs()); node.delete(); } else { SchematicSystem.MESSAGE.send("COMMAND_DELETE_DIR_FULL", player); } } else { - SchematicSystem.MESSAGE.send("COMMAND_DELETE_SCHEM", player, node.generateBreadcrumbs(user)); + SchematicSystem.MESSAGE.send("COMMAND_DELETE_SCHEM", player, node.generateBreadcrumbs()); node.delete(); } }