39 lines
1.5 KiB
Java
39 lines
1.5 KiB
Java
package net.saltymc.eaa.commands;
|
|
|
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
|
import com.mojang.brigadier.context.CommandContext;
|
|
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
|
import net.minecraft.client.toast.*;
|
|
import net.minecraft.text.LiteralText;
|
|
import net.minecraft.text.Text;
|
|
import net.minecraft.util.Formatting;
|
|
|
|
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument;
|
|
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal;
|
|
|
|
public class EchoCommand extends EaaModCommand{
|
|
|
|
public int run(CommandContext<FabricClientCommandSource> context) { // throws CommandSyntaxException
|
|
FabricClientCommandSource source = context.getSource();
|
|
|
|
String nachricht = StringArgumentType.getString(context,"nachricht");
|
|
|
|
SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.TUTORIAL_HINT, Text.of("ECHO"), Text.of(nachricht));
|
|
|
|
source.sendFeedback(
|
|
new LiteralText("You said: ")
|
|
.formatted(Formatting.RED)
|
|
.append(new LiteralText(nachricht + ""))
|
|
);
|
|
return 1;
|
|
}
|
|
|
|
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification() {
|
|
return literal("/echo").then(
|
|
argument("nachricht", StringArgumentType.greedyString())
|
|
.executes(this)
|
|
);
|
|
}
|
|
}
|