SteamWar/SpigotCore
Archiviert
13
0

Some Fixes for SchematicSelector
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Chaoscaot 2021-12-04 14:02:57 +01:00
Ursprung 9b5629704c
Commit e544abf328

Datei anzeigen

@ -53,6 +53,7 @@ public class SchematicSelector {
@Getter @Getter
private boolean singleDirOpen; private boolean singleDirOpen;
private boolean sdoTrigger = false; private boolean sdoTrigger = false;
private boolean noDirOpen = true;
public SchematicSelector(Player player, SelectorTarget target, Consumer<SchematicNode> callback) { public SchematicSelector(Player player, SelectorTarget target, Consumer<SchematicNode> callback) {
this.player = player; this.player = player;
@ -80,12 +81,13 @@ public class SchematicSelector {
if(sdoTrigger) { if(sdoTrigger) {
sdoTrigger = false; sdoTrigger = false;
openList(nodes.get(0));
return; return;
} }
List<SWListInv.SWListEntry<SchematicNode>> list = new ArrayList<>(); List<SWListInv.SWListEntry<SchematicNode>> list = new ArrayList<>();
if(parent != null) { if(parent != null && !noDirOpen) {
list.add(new SWListInv.SWListEntry<>(new SWItem(Material.ARROW, Core.MESSAGE.parse("SCHEM_SELECTOR_BACK", player), clickType -> {}), null)); list.add(new SWListInv.SWListEntry<>(new SWItem(Material.ARROW, Core.MESSAGE.parse("SCHEM_SELECTOR_BACK", player), clickType -> {}), null));
} }
@ -125,7 +127,25 @@ public class SchematicSelector {
private void handleClick(SchematicNode node, SchematicNode parent) { private void handleClick(SchematicNode node, SchematicNode parent) {
if(node == null) { if(node == null) {
openList(getParent(parent)); if(!singleDirOpen) {
if(parent.getParent() == null) {
noDirOpen = true;
}
openList(getParent(parent));
} else {
SchematicNode currentParent = parent;
do {
sdoTrigger = false;
currentParent = getParent(currentParent);
if(currentParent == null)
break;
getSchematicList(currentParent);
} while (sdoTrigger);
if(currentParent == null) {
noDirOpen = true;
}
openList(currentParent);
}
return; return;
} }
if(node.isDir()) { if(node.isDir()) {
@ -135,6 +155,7 @@ public class SchematicSelector {
return; return;
} }
filter.reset(); filter.reset();
noDirOpen = false;
openList(node); openList(node);
return; return;
} }
@ -308,7 +329,12 @@ public class SchematicSelector {
case SCHEMATIC_TYPE: case SCHEMATIC_TYPE:
nodes.addAll(SchematicNode.getAccessibleSchematicsOfTypeInParent(user.getId(), target.type.toDB(), parent==null?0:parent.getId())); nodes.addAll(SchematicNode.getAccessibleSchematicsOfTypeInParent(user.getId(), target.type.toDB(), parent==null?0:parent.getId()));
if(target.rank >= 0) { if(target.rank >= 0) {
nodes.removeIf(node -> node.getRank() > target.rank); nodes.removeIf(node -> {
if(node.isDir()) {
return false;
}
return node.getRank() > target.rank;
});
} }
break; break;
default: default:
@ -316,7 +342,6 @@ public class SchematicSelector {
} }
if(singleDirOpen && nodes.size() == 1 && nodes.get(0).isDir()) { if(singleDirOpen && nodes.size() == 1 && nodes.get(0).isDir()) {
openList(nodes.get(0));
sdoTrigger = true; sdoTrigger = true;
} }
return nodes; return nodes;