Skip to content

Commit 3945942

Browse files
committed
Added PermissionNode#empty
1 parent 59ff26f commit 3945942

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

src/main/java/org/mangorage/mangobotcore/api/command/v1/AbstractCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.mangorage.mangobotcore.api.command.v1.info.CommandData;
99
import org.mangorage.mangobotcore.api.command.v1.info.CommandPart;
1010
import org.mangorage.mangobotcore.api.command.v1.info.ParameterPart;
11-
1211
import java.util.ArrayList;
1312
import java.util.LinkedHashMap;
1413
import java.util.List;
@@ -40,7 +39,9 @@ public String getDescription() {
4039
public abstract R getFailedResult();
4140
public abstract R getNoPermission();
4241

43-
public abstract PermissionNode<C> getPermissionNode();
42+
public PermissionNode<C> getPermissionNode() {
43+
return PermissionNode.empty();
44+
}
4445

4546
public List<String> aliases() {
4647
return List.of();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package org.mangorage.mangobotcore.api.command.v1;
22

3+
import org.mangorage.mangobotcore.internal.permission.EmptyPermissionNode;
4+
35
public interface PermissionNode<C> {
6+
static <C> PermissionNode<C> empty() {
7+
return EmptyPermissionNode.of();
8+
}
9+
410
String getId();
511
boolean hasPermission(CommandContext<C> commandContext);
612
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.mangorage.mangobotcore.internal.permission;
2+
3+
import org.mangorage.mangobotcore.api.command.v1.CommandContext;
4+
import org.mangorage.mangobotcore.api.command.v1.PermissionNode;
5+
6+
public final class EmptyPermissionNode<C> implements PermissionNode<C> {
7+
8+
private static final EmptyPermissionNode<?> INSTANCE = new EmptyPermissionNode<>();
9+
10+
public static <C> EmptyPermissionNode<C> of() {
11+
return (EmptyPermissionNode<C>) INSTANCE;
12+
}
13+
14+
EmptyPermissionNode() {}
15+
16+
@Override
17+
public String getId() {
18+
return "empty";
19+
}
20+
21+
@Override
22+
public boolean hasPermission(CommandContext<C> commandContext) {
23+
return true;
24+
}
25+
}

0 commit comments

Comments
 (0)