40 lines
1.7 KiB
Java
40 lines
1.7 KiB
Java
package net.saltymc.eaa.handler.commands;
|
|
|
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
|
import com.mojang.brigadier.context.CommandContext;
|
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
|
|
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
|
import net.minecraft.client.toast.SystemToast;
|
|
import net.minecraft.text.LiteralText;
|
|
import net.minecraft.text.Text;
|
|
import net.minecraft.util.Formatting;
|
|
|
|
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
|
|
|
|
|
|
public class EchoCommand extends EaaModCommand {
|
|
@Override
|
|
public int run(CommandContext context) throws CommandSyntaxException {
|
|
FabricClientCommandSource source = (FabricClientCommandSource) (context.getSource());
|
|
|
|
SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.TUTORIAL_HINT, Text.of("ECHO"), Text.of(context.getInput()));
|
|
|
|
source.sendFeedback(
|
|
new LiteralText("You said input: ")
|
|
.formatted(Formatting.RED)
|
|
.append(new LiteralText(getString(context, "message"))
|
|
.formatted(Formatting.WHITE, Formatting.ITALIC)
|
|
)
|
|
);
|
|
return SINGLE_SUCCESS;
|
|
}
|
|
|
|
@Override
|
|
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification() {
|
|
return ClientCommandManager.literal("echo")
|
|
.then(ClientCommandManager.argument("message", StringArgumentType.greedyString()));
|
|
}
|
|
}
|