File tree Expand file tree Collapse file tree
commands/src/main/java/com/wizardlybump17/wlib/command/result Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments