SteamWar/SpigotCore
Archiviert
13
0

Add Reopen to SchematicSelector
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Chaos 2022-02-04 23:09:59 +01:00
Ursprung 76c7962e17
Commit 148653ea4c
2 geänderte Dateien mit 16 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -58,6 +58,8 @@ public class SchematicSelector {
private int depth = 0; private int depth = 0;
private Sorting sorting = Sorting.NAME; private Sorting sorting = Sorting.NAME;
private boolean invertSorting = false; private boolean invertSorting = false;
@Getter
private SchematicNode lastParent;
public SchematicSelector(Player player, SelectorTarget target, Consumer<SchematicNode> callback) { public SchematicSelector(Player player, SelectorTarget target, Consumer<SchematicNode> callback) {
this.player = player; this.player = player;
@ -77,10 +79,17 @@ public class SchematicSelector {
if(publicMode == PublicMode.PUBLIC_ONLY) { if(publicMode == PublicMode.PUBLIC_ONLY) {
this.user = SteamwarUser.get(0); this.user = SteamwarUser.get(0);
} }
injectable.onSelectorOpen(this, SchematicSelectorInjectable.OpenFrom.FRESH);
openList(null); openList(null);
} }
public void reOpen() {
injectable.onSelectorOpen(this, SchematicSelectorInjectable.OpenFrom.REOPEN);
openList(lastParent);
}
private void openList(SchematicNode parent) { private void openList(SchematicNode parent) {
lastParent = parent;
List<SchematicNode> nodes = applySorting(filter.isFilter()?getFilteredSchematics():getSchematicList(parent)); List<SchematicNode> nodes = applySorting(filter.isFilter()?getFilteredSchematics():getSchematicList(parent));
if(sdoTrigger) { if(sdoTrigger) {

Datei anzeigen

@ -42,4 +42,11 @@ public interface SchematicSelectorInjectable {
default boolean onFolderCreate(SchematicSelector selector, String name) {return true;} default boolean onFolderCreate(SchematicSelector selector, String name) {return true;}
default void onNodeFilter(SchematicSelector selector, SchematicNode node) {} default void onNodeFilter(SchematicSelector selector, SchematicNode node) {}
default void onSelectorOpen(SchematicSelector selector, OpenFrom from) {}
enum OpenFrom {
FRESH,
REOPEN
}
} }