tutorial:commands
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:commands [2020/11/25 08:20] – [Catch or throw a CommandSyntaxException] i509vcb | tutorial:commands [2021/03/09 02:05] – [Exceptions] what is "translateable"? solidblock | ||
---|---|---|---|
Line 245: | Line 245: | ||
===== Can I register client side commands? ===== | ===== Can I register client side commands? ===== | ||
- | Fabric | + | Fabric |
- | There is an open pull request to fabric api which adds this. That will be documented on this page in the future. | + | |
===== Dark Arts ===== | ===== Dark Arts ===== | ||
Line 280: | Line 279: | ||
.requires(source -> source.hasPermissionLevel(4)) | .requires(source -> source.hasPermissionLevel(4)) | ||
.executes(ctx -> { | .executes(ctx -> { | ||
- | ctx.getSource().sendFeedback(new LiteralText(" | + | ctx.getSource().sendFeedback(new LiteralText(" |
return 1; | return 1; | ||
}); | }); | ||
Line 302: | Line 301: | ||
if(random.nextBoolean()) { // If heads succeed. | if(random.nextBoolean()) { // If heads succeed. | ||
- | ctx.getSource().sendMessage(new | + | ctx.getSource().sendMessage(new |
return Command.SINGLE_SUCCESS; | return Command.SINGLE_SUCCESS; | ||
} | } | ||
- | throw new SimpleCommandExceptionType(new | + | throw new SimpleCommandExceptionType(new |
})); | })); | ||
</ | </ | ||
Line 425: | Line 424: | ||
public static int broadcast(ServerCommandSource source, Formatting formatting, String message) { | public static int broadcast(ServerCommandSource source, Formatting formatting, String message) { | ||
- | final Text text = new LiteralText(message).formatting(formatting); | + | final Text text = new LiteralText(message).formatted(formatting); |
- | source.getMinecraftServer().getPlayerManager().broadcastChatMessage(text, | + | source.getMinecraftServer().getPlayerManager().broadcastChatMessage(text, |
return Command.SINGLE_SUCCESS; | return Command.SINGLE_SUCCESS; | ||
} | } |
tutorial/commands.txt · Last modified: 2024/02/23 14:22 by allen1210