Skip to content

Commit 0b07fd6

Browse files
added the ForbiddenResult and UnauthorizedResult
1 parent 805f15d commit 0b07fd6

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

commands/src/main/java/com/wizardlybump17/wlib/command/result/CommandResult.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ public interface CommandResult<T> {
9494
return new UnprocessableContentResult<>(lastInputIndex, lastNode);
9595
}
9696

97+
static <T> @NotNull UnauthorizedResult<T> unauthorized(int lastInputIndex, @NotNull CommandNode<?> lastNode) {
98+
return new UnauthorizedResult<>(lastInputIndex, lastNode);
99+
}
100+
101+
static <T> @NotNull ForbiddenResult<T> forbidden(int lastInputIndex, @NotNull CommandNode<?> lastNode) {
102+
return new ForbiddenResult<>(lastInputIndex, lastNode);
103+
}
104+
97105
//with context
98106

99107
static <T> @NotNull SuccessResult<T> successful(@NotNull CommandContext context, @Nullable T data) {
@@ -139,4 +147,12 @@ public interface CommandResult<T> {
139147
static <T> @NotNull UnprocessableContentResult<T> unprocessableContent(@NotNull CommandContext context) {
140148
return unprocessableContent(context.lastInputIndex(), context.lastNode());
141149
}
150+
151+
static <T> @NotNull UnauthorizedResult<T> unauthorized(@NotNull CommandContext context) {
152+
return unauthorized(context.lastInputIndex(), context.lastNode());
153+
}
154+
155+
static <T> @NotNull ForbiddenResult<T> forbidden(@NotNull CommandContext context) {
156+
return forbidden(context.lastInputIndex(), context.lastNode());
157+
}
142158
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.wizardlybump17.wlib.command.result.error;
2+
3+
import com.wizardlybump17.wlib.command.node.CommandNode;
4+
import org.jetbrains.annotations.NotNull;
5+
6+
public record ForbiddenResult<T>(int lastInputIndex, @NotNull CommandNode<?> lastNode) implements UnsuccessResult<T> {
7+
8+
public static final @NotNull String ID = "WLib:Error/Forbidden";
9+
10+
@Override
11+
public @NotNull String id() {
12+
return ID;
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.wizardlybump17.wlib.command.result.error;
2+
3+
import com.wizardlybump17.wlib.command.node.CommandNode;
4+
import org.jetbrains.annotations.NotNull;
5+
6+
public record UnauthorizedResult<T>(int lastInputIndex, @NotNull CommandNode<?> lastNode) implements UnsuccessResult<T> {
7+
8+
public static final @NotNull String ID = "WLib:Error/Unauthorized";
9+
10+
@Override
11+
public @NotNull String id() {
12+
return ID;
13+
}
14+
}

0 commit comments

Comments
 (0)