Skip to content

Commit 2f1017c

Browse files
added the NotFoundResult
1 parent 867fc5d commit 2f1017c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public interface CommandResult<T> {
7878
return new NoContentResult<>(lastInputIndex, lastNode);
7979
}
8080

81+
static <T> @NotNull NotFoundResult<T> notFound(int lastInputIndex, @NotNull CommandNode<?> lastNode) {
82+
return new NotFoundResult<>(lastInputIndex, lastNode);
83+
}
84+
8185
//with context
8286

8387
static <T> @NotNull SuccessResult<T> successful(@NotNull CommandContext context, @Nullable T data) {
@@ -107,4 +111,8 @@ public interface CommandResult<T> {
107111
static <T> @NotNull NoContentResult<T> noContent(@NotNull CommandContext context) {
108112
return noContent(context.lastInputIndex(), context.lastNode());
109113
}
114+
115+
static <T> @NotNull NotFoundResult<T> notFound(@NotNull CommandContext context) {
116+
return notFound(context.lastInputIndex(), context.lastNode());
117+
}
110118
}
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 NotFoundResult<T>(int lastInputIndex, @NotNull CommandNode<?> lastNode) implements UnsuccessResult<T> {
7+
8+
public static final @NotNull String ID = "WLib:Error/NotFound";
9+
10+
@Override
11+
public @NotNull String id() {
12+
return ID;
13+
}
14+
}

0 commit comments

Comments
 (0)