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

+1-1
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

+5-4
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

+2-1
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

+3-2
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

+2-1
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

+2-1
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

+2-1
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

+2-1
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

+2-1
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

+2-1
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
);

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

+2-1
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

56
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
@@ -44,7 +45,7 @@ private static int getStackSize(FabricClientCommandSource source, ItemStack stac
4445
}
4546
}
4647

47-
return 1;
48+
return Command.SINGLE_SUCCESS;
4849
}
4950

5051
private static int getStackSize(FabricClientCommandSource source, int count) {

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

+2-1
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.cortex.clientAddon.cracker.SeedCracker;
56
import net.earthcomputer.clientcommands.ServerBrandManager;
@@ -24,7 +25,7 @@ private static int crackPlayerRNG(FabricClientCommandSource source) {
2425
PlayerRandCracker.setSeed(seed);
2526
TempRules.playerCrackState = PlayerRandCracker.CrackState.CRACKED;
2627
});
27-
return 0;
28+
return Command.SINGLE_SUCCESS;
2829
}
2930

3031
}

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

+2-1
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.client.world.ClientWorld;
@@ -63,7 +64,7 @@ public static int findBlock(FabricClientCommandSource source, ClientBlockPredica
6364
.append(" ")
6465
.append(getGlowCoordsTextComponent(Text.translatable("commands.cfindblock.success.glow"), closestBlock))
6566
.append(Text.translatable("commands.cfindblock.success.right", foundRadius)));
66-
return 1;
67+
return Command.SINGLE_SUCCESS;
6768
}
6869
}
6970

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

+2-1
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

@@ -43,7 +44,7 @@ private static int listEntities(FabricClientCommandSource source, CEntitySelecto
4344
.append(" ")
4445
.append(getCommandTextComponent("commands.client.cancel", "/ctask stop " + taskName)));
4546

46-
return 0;
47+
return Command.SINGLE_SUCCESS;
4748
} else {
4849
List<? extends Entity> entities = selector.getEntities(source);
4950

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

+2-1
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.context.CommandContext;
56
import net.earthcomputer.clientcommands.GuiBlocker;
@@ -82,7 +83,7 @@ private static int findItem(CommandContext<FabricClientCommandSource> ctx, boole
8283
ctx.getSource().sendFeedback(Text.translatable("commands.cfinditem.starting", item.getLeft()));
8384
}
8485

85-
return 0;
86+
return Command.SINGLE_SUCCESS;
8687
}
8788

8889
private static class FindItemsTask extends SimpleTask {

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

+2-1
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

56
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
@@ -26,7 +27,7 @@ private static int setFov(FabricClientCommandSource source, int fov) {
2627
Text feedback = Text.translatable("commands.cfov.success", fov);
2728
source.sendFeedback(feedback);
2829

29-
return 0;
30+
return Command.SINGLE_SUCCESS;
3031
}
3132

3233
}

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

+2-1
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

56
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
@@ -22,7 +23,7 @@ private static int setGamma(FabricClientCommandSource source, double gamma) {
2223
Text feedback = Text.translatable("commands.cgamma.success", gamma);
2324
source.sendFeedback(feedback);
2425

25-
return 0;
26+
return Command.SINGLE_SUCCESS;
2627
}
2728

2829
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.earthcomputer.clientcommands.command;
22

33
import com.google.common.collect.ImmutableList;
4+
import com.mojang.brigadier.Command;
45
import com.mojang.brigadier.CommandDispatcher;
56
import com.mojang.brigadier.builder.ArgumentBuilder;
67
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@@ -78,7 +79,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
7879

7980
private static int getData(FabricClientCommandSource source, DataCommandObject dataObj) throws CommandSyntaxException {
8081
source.sendFeedback(dataObj.feedbackQuery(dataObj.getNbt()));
81-
return 1;
82+
return Command.SINGLE_SUCCESS;
8283
}
8384

8485
private static int getData(FabricClientCommandSource source, DataCommandObject dataObj, NbtPath path) throws CommandSyntaxException {

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

+2-1
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;
@@ -42,7 +43,7 @@ private static int setGhostBlock(FabricClientCommandSource source, BlockPos pos,
4243
boolean result = world.setBlockState(pos, state, 18);
4344
if (result) {
4445
source.sendFeedback(Text.translatable("commands.cghostblock.set.success"));
45-
return 1;
46+
return Command.SINGLE_SUCCESS;
4647
} else {
4748
throw SET_FAILED_EXCEPTION.create();
4849
}

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

+2-1
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;
@@ -102,7 +103,7 @@ protected void onTick() {
102103
.append(" ")
103104
.append(getCommandTextComponent("commands.client.cancel", "/ctask stop " + taskName)));
104105

105-
return 0;
106+
return Command.SINGLE_SUCCESS;
106107
} else {
107108
List<? extends Entity> entities = entitySelector.getEntities(source);
108109
if (entities.isEmpty()) {

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

+3-2
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;
@@ -45,7 +46,7 @@ private static int save(FabricClientCommandSource source, int index) {
4546
Text hotbarKey = client.options.hotbarKeys[index - 1].getBoundKeyLocalizedText();
4647

4748
source.sendFeedback(Text.translatable("inventory.hotbarSaved", loadKey, hotbarKey));
48-
return 0;
49+
return Command.SINGLE_SUCCESS;
4950
}
5051

5152
private static int restore(FabricClientCommandSource source, int index) throws CommandSyntaxException {
@@ -69,6 +70,6 @@ private static int restore(FabricClientCommandSource source, int index) throws C
6970
player.playerScreenHandler.sendContentUpdates();
7071

7172
source.sendFeedback(Text.translatable("commands.chotbar.restoredHotbar", index));
72-
return 0;
73+
return Command.SINGLE_SUCCESS;
7374
}
7475
}

0 commit comments

Comments
 (0)