forked from SteamWar/SteamWar
Format code
This commit is contained in:
@@ -28,22 +28,22 @@ import org.bukkit.entity.Player;
|
||||
public class SafeSchematicNode {
|
||||
|
||||
public static Result setParent(@NonNull SteamwarUser user, @NonNull SchematicNode node, SchematicNode newParent) {
|
||||
if(user.getId() != node.getOwner()) {
|
||||
if (user.getId() != node.getOwner()) {
|
||||
return Result.NOT_OWNER;
|
||||
}
|
||||
if(newParent == null) {
|
||||
if(SchematicNode.list(user, null)
|
||||
if (newParent == null) {
|
||||
if (SchematicNode.list(user, null)
|
||||
.stream().map(SchematicNode::getName).anyMatch(s -> s.equalsIgnoreCase(node.getName()))) {
|
||||
return Result.ALREADY_IN_DIRECTORY;
|
||||
}
|
||||
|
||||
node.setParent(null);
|
||||
} else {
|
||||
if(!newParent.isDir()) {
|
||||
if (!newParent.isDir()) {
|
||||
return Result.NOT_A_DIR;
|
||||
}
|
||||
|
||||
if(SchematicNode.list(user, newParent.getId())
|
||||
if (SchematicNode.list(user, newParent.getId())
|
||||
.stream().map(SchematicNode::getName).anyMatch(s -> s.equalsIgnoreCase(node.getName()))) {
|
||||
return Result.ALREADY_IN_DIRECTORY;
|
||||
}
|
||||
@@ -54,15 +54,15 @@ public class SafeSchematicNode {
|
||||
}
|
||||
|
||||
public static Result setName(@NonNull SteamwarUser user, @NonNull SchematicNode node, @NonNull String name) {
|
||||
if(user.getId() != node.getOwner()) {
|
||||
if (user.getId() != node.getOwner()) {
|
||||
return Result.NOT_OWNER;
|
||||
}
|
||||
|
||||
if(SchematicNode.invalidSchemName(new String[]{name})) {
|
||||
if (SchematicNode.invalidSchemName(new String[]{name})) {
|
||||
return Result.INVALID_NAME;
|
||||
}
|
||||
|
||||
if(SchematicNode.list(user, node.getParent()).stream().map(SchematicNode::getName).anyMatch(s -> s.equalsIgnoreCase(name))) {
|
||||
if (SchematicNode.list(user, node.getParent()).stream().map(SchematicNode::getName).anyMatch(s -> s.equalsIgnoreCase(name))) {
|
||||
return Result.ALREADY_IN_DIRECTORY;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user