Merge pull request 'NodeMember: SpigotCore' (#221) from nodemember into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #221 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
5ed8a89d07
@ -1 +1 @@
|
||||
Subproject commit d56150a8b105f5ad63a8c3a21b6833f388a83225
|
||||
Subproject commit 8b8e6a9e574040eea1bdea955f69263e63eb8078
|
@ -20,10 +20,7 @@
|
||||
package de.steamwar.inventory;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.sql.NodeMember;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.*;
|
||||
import lombok.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -118,7 +115,7 @@ public class SchematicSelector {
|
||||
list.add(renderItem(node));
|
||||
}
|
||||
|
||||
SWListInv<SchematicNode> inv = new SWListInv<>(player, MessageFormat.format(injectable.createTitle(player), target.target.getName(player), filter.getName() == null?(parent == null?"/":parent.generateBreadcrumbs(user)):filter.getName()), false, list, (clickType, node) -> handleClick(node, parent));
|
||||
SWListInv<SchematicNode> inv = new SWListInv<>(player, MessageFormat.format(injectable.createTitle(player), target.target.getName(player), filter.getName() == null?(parent == null?"/":parent.generateBreadcrumbs()):filter.getName()), false, list, (clickType, node) -> handleClick(node, parent));
|
||||
if(publicMode == PublicMode.ALL) {
|
||||
if(user.getId() == 0) {
|
||||
inv.setItem(48, Material.BUCKET, Core.MESSAGE.parse("SCHEM_SELECTOR_OWN", player), clickType -> {
|
||||
@ -166,28 +163,21 @@ public class SchematicSelector {
|
||||
}
|
||||
if(!singleDirOpen) {
|
||||
if(NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
|
||||
return null;
|
||||
return Optional.ofNullable(SchematicNode.byIdAndUser(user, parent.getId())).flatMap(SchematicNode::getOptionalParent).map(integer -> SchematicNode.byIdAndUser(user, integer)).orElse(null);
|
||||
} else {
|
||||
return getParent(parent);
|
||||
return getParent(parent).orElse(null);
|
||||
}
|
||||
} else {
|
||||
SchematicNode currentParent = parent;
|
||||
boolean isMember = false;
|
||||
Optional<SchematicNode> currentParent = Optional.of(parent);
|
||||
do {
|
||||
sdoTrigger = false;
|
||||
if(NodeMember.getNodeMember(currentParent.getId(), user.getId()) != null) {
|
||||
isMember = true;
|
||||
}
|
||||
currentParent = getParent(currentParent);
|
||||
if(currentParent == null)
|
||||
currentParent = currentParent.flatMap(SchematicSelector::getParent);
|
||||
if(!currentParent.isPresent()) {
|
||||
break;
|
||||
getSchematicList(currentParent);
|
||||
} while (sdoTrigger);
|
||||
if(isMember || NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
|
||||
return null;
|
||||
} else {
|
||||
return currentParent;
|
||||
}
|
||||
getSchematicList(currentParent.get());
|
||||
} while (sdoTrigger);
|
||||
return currentParent.orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,7 +387,7 @@ public class SchematicSelector {
|
||||
}
|
||||
|
||||
private List<SchematicNode> getFilteredSchematics() {
|
||||
List<SchematicNode> nodes = new ArrayList<>(SchematicNode.getAllSchematicsAccessibleByUser(user.getId()));
|
||||
List<SchematicNode> nodes = new ArrayList<>(SchematicNode.getAll(user));
|
||||
nodes.removeIf(node -> {
|
||||
injectable.onNodeFilter(this, node);
|
||||
return !filter.matches(node);
|
||||
@ -415,15 +405,11 @@ public class SchematicSelector {
|
||||
List<SchematicNode> nodes = new ArrayList<>();
|
||||
switch (target.target) {
|
||||
case DIRECTORY:
|
||||
if(parent == null) {
|
||||
nodes.addAll(SchematicNode.getSchematicsAccessibleByUser(user.getId(), null));
|
||||
nodes.addAll(SchematicNode.list(user, Optional.ofNullable(parent).map(SchematicNode::getId).orElse(null)));
|
||||
nodes.removeIf(node -> !node.isDir());
|
||||
} else {
|
||||
nodes.addAll(SchematicNode.getSchematicDirectoryInNode(parent.getId()));
|
||||
}
|
||||
break;
|
||||
case SCHEMATIC_TYPE:
|
||||
nodes.addAll(SchematicNode.getAccessibleSchematicsOfTypeInParent(user.getId(), target.type.toDB(), parent==null?0:parent.getId()));
|
||||
nodes.addAll(SchematicNode.accessibleByUserTypeMap(user, target.type).get(parent==null?null:parent.getId()));
|
||||
if(target.rank >= 0) {
|
||||
nodes.removeIf(node -> {
|
||||
if(node.isDir()) {
|
||||
@ -434,7 +420,7 @@ public class SchematicSelector {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
nodes.addAll(SchematicNode.getSchematicsAccessibleByUser(user.getId(), parent == null?0:parent.getId()));
|
||||
nodes.addAll(SchematicNode.list(user, parent == null?null:parent.getId()));
|
||||
}
|
||||
|
||||
if(singleDirOpen && nodes.size() == 1 && nodes.get(0).isDir()) {
|
||||
@ -443,11 +429,8 @@ public class SchematicSelector {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
private static SchematicNode getParent(SchematicNode node) {
|
||||
if(node.getParent() == null) {
|
||||
return null;
|
||||
}
|
||||
return node.getParentNode();
|
||||
private static Optional<SchematicNode> getParent(SchematicNode node) {
|
||||
return node.getOptionalParent().map(integer -> SchematicNode.byIdAndUser(SteamwarUser.get(node.getEffectiveOwner()), integer));
|
||||
}
|
||||
|
||||
public static SelectorTarget selectSchematic() {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren