Skip to content

Commit d99df75

Browse files
committed
0 -> Command.SINGLE_SUCCESS
1 parent 2a18957 commit d99df75

34 files changed

+82
-50
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ You may see old code that doesn't adhere to these guidelines, but all new code m
5454
### Command registry
5555
#### General
5656
* Execute a command's code mostly in a dedicated method, rather than in the `register` method
57-
* If the command was successful and there isn't something sensible to return, it should `return 0`. If the command was not successful, an exception should be thrown
57+
* If the command was successful and there isn't something sensible to return, it should `return Command.SINGLE_SUCCESS`. If the command was not successful, an exception should be thrown
5858
#### Exceptions
5959
* Exception variables are [immutable constants](#immutable-constants)
6060
### Miscellaneous

src/main/java/net/earthcomputer/clientcommands/command/AliasCommand.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.gson.Gson;
44
import com.google.gson.reflect.TypeToken;
55
import com.google.gson.stream.JsonReader;
6+
import com.mojang.brigadier.Command;
67
import com.mojang.brigadier.CommandDispatcher;
78
import com.mojang.brigadier.exceptions.CommandSyntaxException;
89
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
@@ -101,7 +102,7 @@ private static int executeAliasCommand(FabricClientCommandSource source, String
101102
source.getPlayer().sendChatMessage(cmd);
102103
}
103104

104-
return 0;
105+
return Command.SINGLE_SUCCESS;
105106
}
106107

107108
@SuppressWarnings("unchecked")
@@ -127,7 +128,7 @@ private static int addAlias(FabricClientCommandSource source, String key, String
127128

128129
saveAliases();
129130
source.sendFeedback(Text.translatable("commands.calias.addAlias.success", key));
130-
return 0;
131+
return Command.SINGLE_SUCCESS;
131132
}
132133

133134
private static int listAliases(FabricClientCommandSource source) {
@@ -139,7 +140,7 @@ private static int listAliases(FabricClientCommandSource source) {
139140
source.sendFeedback(Text.of(Formatting.BOLD + key + Formatting.RESET + ": " + aliasMap.get(key).replace("%","%%")));
140141
}
141142
}
142-
return 0;
143+
return Command.SINGLE_SUCCESS;
143144
}
144145

145146
private static int removeAlias(FabricClientCommandSource source, String key) throws CommandSyntaxException {
@@ -153,7 +154,7 @@ private static int removeAlias(FabricClientCommandSource source, String key) thr
153154

154155
saveAliases();
155156
source.sendFeedback(Text.translatable("commands.calias.removeAlias.success", key));
156-
return 0;
157+
return Command.SINGLE_SUCCESS;
157158
}
158159

159160
private static HashMap<String, String> loadAliases() {

src/main/java/net/earthcomputer/clientcommands/command/BookCommand.java

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

3+
import com.mojang.brigadier.Command;
34
import com.mojang.brigadier.CommandDispatcher;
45
import com.mojang.brigadier.exceptions.CommandSyntaxException;
56
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
@@ -101,6 +102,6 @@ private static int fillBook(FabricClientCommandSource source, IntStream characte
101102

102103
source.sendFeedback(Text.translatable("commands.cbook.success"));
103104

104-
return 0;
105+
return Command.SINGLE_SUCCESS;
105106
}
106107
}

src/main/java/net/earthcomputer/clientcommands/command/CEnchantCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.earthcomputer.clientcommands.command;
22

3+
import com.mojang.brigadier.Command;
34
import com.mojang.brigadier.CommandDispatcher;
45
import net.earthcomputer.clientcommands.TempRules;
56
import net.earthcomputer.clientcommands.command.arguments.ItemAndEnchantmentsPredicateArgumentType.ItemAndEnchantmentsPredicate;
@@ -42,7 +43,7 @@ private static int cenchant(FabricClientCommandSource source, ItemAndEnchantment
4243
.append(" ")
4344
.append(getCommandTextComponent("commands.client.crack", "/ccrackrng"));
4445
source.sendFeedback(text);
45-
return 0;
46+
return Command.SINGLE_SUCCESS;
4647
}
4748

4849
boolean simulate = getFlag(source, FLAG_SIMULATE);
@@ -71,7 +72,7 @@ private static int cenchant(FabricClientCommandSource source, ItemAndEnchantment
7172
source.sendFeedback(Text.translatable("commands.cenchant.success"));
7273
}
7374
}
74-
return 0;
75+
return Command.SINGLE_SUCCESS;
7576
}
7677

7778
}

src/main/java/net/earthcomputer/clientcommands/command/CGiveCommand.java

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

3+
import com.mojang.brigadier.Command;
34
import com.mojang.brigadier.CommandDispatcher;
45
import com.mojang.brigadier.exceptions.CommandSyntaxException;
56
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
@@ -35,6 +36,6 @@ private static int give(FabricClientCommandSource source, ItemStackArgument item
3536
source.getPlayer().playerScreenHandler.sendContentUpdates();
3637

3738
source.sendFeedback(Text.translatable("commands.cgive.success", count, stack.toHoverableText()));
38-
return 0;
39+
return Command.SINGLE_SUCCESS;
3940
}
4041
}

src/main/java/net/earthcomputer/clientcommands/command/CParticleCommand.java

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

3+
import com.mojang.brigadier.Command;
34
import com.mojang.brigadier.CommandDispatcher;
45
import com.mojang.brigadier.exceptions.CommandSyntaxException;
56
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
@@ -60,7 +61,7 @@ private static int spawnParticle(FabricClientCommandSource source, ParticleEffec
6061
}
6162
source.sendFeedback(Text.translatable("commands.cparticle.success",
6263
Registry.PARTICLE_TYPE.getId(parameters.getType()).toString()));
63-
return 0;
64+
return Command.SINGLE_SUCCESS;
6465
}
6566
}
6667
}

src/main/java/net/earthcomputer/clientcommands/command/CPlaySoundCommand.java

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

3+
import com.mojang.brigadier.Command;
34
import com.mojang.brigadier.CommandDispatcher;
45
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
56
import dev.xpple.clientarguments.arguments.CSuggestionProviders;
@@ -47,7 +48,7 @@ private static int playSound(FabricClientCommandSource source, Identifier sound,
4748

4849
source.sendFeedback(Text.translatable("commands.cplaysound.success", sound));
4950

50-
return 0;
51+
return Command.SINGLE_SUCCESS;
5152
}
5253

5354
}

src/main/java/net/earthcomputer/clientcommands/command/CStopSoundCommand.java

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

3+
import com.mojang.brigadier.Command;
34
import com.mojang.brigadier.CommandDispatcher;
45
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
56
import dev.xpple.clientarguments.arguments.CSuggestionProviders;
@@ -44,7 +45,7 @@ private static int stopSound(FabricClientCommandSource source, SoundCategory cat
4445
} else {
4546
source.sendFeedback(Text.translatable("commands.cstopsound.success.source.sound", sound, category.getName()));
4647
}
47-
return 0;
48+
return Command.SINGLE_SUCCESS;
4849
}
4950

5051
}

src/main/java/net/earthcomputer/clientcommands/command/CTeleportCommand.java

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

3+
import com.mojang.brigadier.Command;
34
import com.mojang.brigadier.CommandDispatcher;
45
import com.mojang.brigadier.exceptions.CommandSyntaxException;
56
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
@@ -28,6 +29,6 @@ private static int teleport(FabricClientCommandSource source, UUID uuid) throws
2829
}
2930
source.getClient().getNetworkHandler().sendPacket(new SpectatorTeleportC2SPacket(uuid));
3031
source.sendFeedback(Text.translatable("commands.ctp.success", uuid.toString()));
31-
return 0;
32+
return Command.SINGLE_SUCCESS;
3233
}
3334
}

src/main/java/net/earthcomputer/clientcommands/command/CTellRawCommand.java

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

3+
import com.mojang.brigadier.Command;
34
import com.mojang.brigadier.CommandDispatcher;
45
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
56
import net.minecraft.text.MutableText;
@@ -16,7 +17,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
1617
.executes(ctx -> {
1718
MutableText text = Texts.parse(new FakeCommandSource(ctx.getSource().getPlayer()), getCTextArgument(ctx, "message"), ctx.getSource().getPlayer(), 0);
1819
ctx.getSource().getClient().inGameHud.getChatHud().addMessage(text);
19-
return 0;
20+
return Command.SINGLE_SUCCESS;
2021
})
2122
)
2223
);

0 commit comments

Comments
 (0)