Skip to content

Commit 867fc5d

Browse files
added the NoContentResult
1 parent 97ac25c commit 867fc5d

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.wizardlybump17.wlib.command.exception.InputParsingException;
66
import com.wizardlybump17.wlib.command.node.CommandNode;
77
import com.wizardlybump17.wlib.command.result.error.*;
8+
import com.wizardlybump17.wlib.command.result.success.NoContentResult;
89
import com.wizardlybump17.wlib.command.sender.CommandSender;
910
import org.jetbrains.annotations.NotNull;
1011
import org.jetbrains.annotations.Nullable;
@@ -73,6 +74,10 @@ public interface CommandResult<T> {
7374
return new InvalidSenderResult<>(lastInputIndex, lastNode, sender, expectedSender);
7475
}
7576

77+
static <T> @NotNull NoContentResult<T> noContent(int lastInputIndex, @NotNull CommandNode<?> lastNode) {
78+
return new NoContentResult<>(lastInputIndex, lastNode);
79+
}
80+
7681
//with context
7782

7883
static <T> @NotNull SuccessResult<T> successful(@NotNull CommandContext context, @Nullable T data) {
@@ -98,4 +103,8 @@ public interface CommandResult<T> {
98103
static <T> @NotNull InvalidSenderResult<T> invalidSender(@NotNull CommandContext context, @NotNull Class<? extends CommandSender<?>> expectedSender) {
99104
return invalidSender(context.lastInputIndex(), context.lastNode(), context.sender(), expectedSender);
100105
}
106+
107+
static <T> @NotNull NoContentResult<T> noContent(@NotNull CommandContext context) {
108+
return noContent(context.lastInputIndex(), context.lastNode());
109+
}
101110
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.wizardlybump17.wlib.command.result.success;
2+
3+
import com.wizardlybump17.wlib.command.node.CommandNode;
4+
import com.wizardlybump17.wlib.command.result.CommandResult;
5+
import org.jetbrains.annotations.NotNull;
6+
import org.jetbrains.annotations.Nullable;
7+
8+
public record NoContentResult<T>(int lastInputIndex, @NotNull CommandNode<?> lastNode) implements CommandResult<T> {
9+
10+
private static final @NotNull String ID = "WLib:Success/NoContent";
11+
12+
@Override
13+
public @NotNull String id() {
14+
return ID;
15+
}
16+
17+
@Override
18+
public boolean success() {
19+
return true;
20+
}
21+
22+
@Override
23+
public @Nullable T data() {
24+
return null;
25+
}
26+
}

0 commit comments

Comments
 (0)