From 148653ea4c8420d8b0555ad1860e8291141abfea Mon Sep 17 00:00:00 2001 From: Chaos Date: Fri, 4 Feb 2022 23:09:59 +0100 Subject: [PATCH] Add Reopen to SchematicSelector --- .../src/de/steamwar/inventory/SchematicSelector.java | 9 +++++++++ .../steamwar/inventory/SchematicSelectorInjectable.java | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelector.java b/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelector.java index a007562..d795783 100644 --- a/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelector.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelector.java @@ -58,6 +58,8 @@ public class SchematicSelector { private int depth = 0; private Sorting sorting = Sorting.NAME; private boolean invertSorting = false; + @Getter + private SchematicNode lastParent; public SchematicSelector(Player player, SelectorTarget target, Consumer callback) { this.player = player; @@ -77,10 +79,17 @@ public class SchematicSelector { if(publicMode == PublicMode.PUBLIC_ONLY) { this.user = SteamwarUser.get(0); } + injectable.onSelectorOpen(this, SchematicSelectorInjectable.OpenFrom.FRESH); openList(null); } + public void reOpen() { + injectable.onSelectorOpen(this, SchematicSelectorInjectable.OpenFrom.REOPEN); + openList(lastParent); + } + private void openList(SchematicNode parent) { + lastParent = parent; List nodes = applySorting(filter.isFilter()?getFilteredSchematics():getSchematicList(parent)); if(sdoTrigger) { diff --git a/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelectorInjectable.java b/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelectorInjectable.java index 7c4d718..29bd658 100644 --- a/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelectorInjectable.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelectorInjectable.java @@ -42,4 +42,11 @@ public interface SchematicSelectorInjectable { default boolean onFolderCreate(SchematicSelector selector, String name) {return true;} default void onNodeFilter(SchematicSelector selector, SchematicNode node) {} + + default void onSelectorOpen(SchematicSelector selector, OpenFrom from) {} + + enum OpenFrom { + FRESH, + REOPEN + } }