Skip to content

Commit 760825d

Browse files
committed
Refactor command return values to use Command.SINGLE_SUCCESS for consistency
1 parent 2c722ca commit 760825d

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

src/main/java/dev/amble/lib/client/command/ClientScriptCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.amble.lib.client.command;
22

3+
import com.mojang.brigadier.Command;
34
import com.mojang.brigadier.CommandDispatcher;
45
import com.mojang.brigadier.arguments.StringArgumentType;
56
import com.mojang.brigadier.context.CommandContext;
@@ -248,6 +249,6 @@ private static int listAvailable(CommandContext<FabricClientCommandSource> conte
248249
statusIcon.copy().append(Text.literal(id.getNamespace() + ":" + displayId).formatted(Formatting.WHITE))
249250
);
250251
}
251-
return 1;
252+
return Command.SINGLE_SUCCESS;
252253
}
253254
}

src/main/java/dev/amble/lib/command/PlayAnimationCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.amble.lib.command;
22

3+
import com.mojang.brigadier.Command;
34
import com.mojang.brigadier.CommandDispatcher;
45
import com.mojang.brigadier.arguments.BoolArgumentType;
56
import com.mojang.brigadier.arguments.StringArgumentType;
@@ -45,6 +46,6 @@ private static int execute(CommandContext<ServerCommandSource> context) {
4546

4647
String name = target.getEntityName();
4748
context.getSource().sendFeedback(() -> Text.literal("Playing animation "+ animationId +" on "+ name), true);
48-
return 1;
49+
return Command.SINGLE_SUCCESS;
4950
}
5051
}

src/main/java/dev/amble/lib/command/ServerScriptCommand.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ public class ServerScriptCommand {
3333
private static final String SCRIPT_PREFIX = "script/";
3434
private static final String SCRIPT_SUFFIX = ".lua";
3535

36-
private static String translationKey(String key) {
37-
return "command." + AmbleKit.MOD_ID + ".script." + key;
38-
}
39-
4036
/**
4137
* Converts a full script identifier to a display-friendly format.
4238
* Removes the "script/" prefix and ".lua" suffix.
@@ -116,9 +112,8 @@ private static int execute(CommandContext<ServerCommandSource> context, String a
116112
try {
117113
LuaScript script = ServerScriptManager.getInstance().getCache().get(fullScriptId);
118114

119-
if (script == null) {
120-
context.getSource().sendError(Text.translatable(translationKey("error.not_found"), scriptId));
121-
return 0;
115+
if (script == null) context.getSource().sendError(Text.translatable("command.amblekit.script.error.not_found", scriptId));
116+
context.getSource().sendError(Text.literal("Server script '" + scriptId + "' not found"));
122117
}
123118

124119
if (script.onExecute() == null || script.onExecute().isnil()) {
@@ -252,6 +247,6 @@ private static int listAvailable(CommandContext<ServerCommandSource> context) {
252247
context.getSource().sendFeedback(() ->
253248
statusIcon.copy().append(Text.literal(id.getNamespace() + ":" + displayId).formatted(Formatting.WHITE)), false);
254249
}
255-
return 1;
250+
return Command.SINGLE_SUCCESS;
256251
}
257252
}

src/main/java/dev/amble/lib/command/SetSkinCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,6 @@ private static int executeWithSlim(CommandContext<ServerCommandSource> context)
164164
String username = entity.getEntityName();
165165
context.getSource().sendFeedback(() -> Text.translatable(translationKey("set"), username, value), true);
166166

167-
return 1;
167+
return Command.SINGLE_SUCCESS;
168168
}
169169
}

0 commit comments

Comments
 (0)