SteamWar/SpigotCore
Archiviert
13
0

Fixes, Fixes, damn Fixes
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Chaoscaot 2021-12-08 18:54:13 +01:00
Ursprung 79050e3b09
Commit d1ca48436c
2 geänderte Dateien mit 20 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.inventory; package de.steamwar.inventory;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.sql.NodeMember;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType; import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
@ -53,7 +54,9 @@ public class SchematicSelector {
@Getter @Getter
private boolean singleDirOpen; private boolean singleDirOpen;
private boolean sdoTrigger = false; private boolean sdoTrigger = false;
private boolean noDirOpen = true; @Getter
@Setter
private int openedDirs = 0;
public SchematicSelector(Player player, SelectorTarget target, Consumer<SchematicNode> callback) { public SchematicSelector(Player player, SelectorTarget target, Consumer<SchematicNode> callback) {
this.player = player; this.player = player;
@ -87,7 +90,7 @@ public class SchematicSelector {
List<SWListInv.SWListEntry<SchematicNode>> list = new ArrayList<>(); List<SWListInv.SWListEntry<SchematicNode>> list = new ArrayList<>();
if(parent != null && !noDirOpen) { if(parent != null && openedDirs != 0) {
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));
} }
@ -127,25 +130,32 @@ public class SchematicSelector {
private void handleClick(SchematicNode node, SchematicNode parent) { private void handleClick(SchematicNode node, SchematicNode parent) {
if(node == null) { if(node == null) {
openedDirs--;
if(!singleDirOpen) { if(!singleDirOpen) {
if(parent.getParent() == null) { if(NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
noDirOpen = true; openList(null);
} } else {
openList(getParent(parent)); openList(getParent(parent));
}
} else { } else {
SchematicNode currentParent = parent; SchematicNode currentParent = parent;
boolean isMember = false;
do { do {
sdoTrigger = false; sdoTrigger = false;
if(NodeMember.getNodeMember(currentParent.getId(), user.getId()) != null) {
isMember = true;
}
currentParent = getParent(currentParent); currentParent = getParent(currentParent);
if(currentParent == null) if(currentParent == null)
break; break;
getSchematicList(currentParent); getSchematicList(currentParent);
} while (sdoTrigger); } while (sdoTrigger);
if(currentParent == null) { if(isMember || NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
noDirOpen = true; openList(null);
} } else {
openList(currentParent); openList(currentParent);
} }
}
return; return;
} }
if(node.isDir()) { if(node.isDir()) {
@ -155,7 +165,7 @@ public class SchematicSelector {
return; return;
} }
filter.reset(); filter.reset();
noDirOpen = false; openedDirs++;
openList(node); openList(node);
return; return;
} }

Datei anzeigen

@ -488,13 +488,10 @@ public class SchematicNode {
StringBuilder builder = new StringBuilder(getName()); StringBuilder builder = new StringBuilder(getName());
SchematicNode currentNode = this; SchematicNode currentNode = this;
if (currentNode.isDir()) builder.append("/"); if (currentNode.isDir()) builder.append("/");
while (currentNode.getParentNode() != null) { while (currentNode.getParentNode() != null && !currentNode.getMembers().stream().anyMatch(member -> member.getMember() == user.getId())) {
currentNode = currentNode.getParentNode(); currentNode = currentNode.getParentNode();
builder.insert(0, split) builder.insert(0, split)
.insert(0, currentNode.getName()); .insert(0, currentNode.getName());
if (currentNode.getMembers().stream().anyMatch(member -> member.getMember() == user.getId())) {
break;
}
} }
return builder.toString(); return builder.toString();
} }