46 lines
2 KiB
Java
46 lines
2 KiB
Java
package net.saltymc.eaa.handler.commands;
|
|
|
|
|
|
import com.mojang.brigadier.Command;
|
|
import com.mojang.brigadier.arguments.DoubleArgumentType;
|
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
|
import com.mojang.brigadier.context.CommandContext;
|
|
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 net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument;
|
|
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal;
|
|
|
|
public class EchoCommand {
|
|
public static int run(CommandContext<FabricClientCommandSource> context) { // throws CommandSyntaxException
|
|
FabricClientCommandSource source = context.getSource();
|
|
|
|
SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.TUTORIAL_HINT, Text.of("ECHO"), Text.of(context.getInput()));
|
|
|
|
//String nachricht = getString(context,"nachricht");
|
|
double nachricht = DoubleArgumentType.getDouble(context, "nachricht");
|
|
System.out.println("nachricht is " + nachricht);
|
|
|
|
source.sendFeedback(
|
|
new LiteralText("You said input: ")
|
|
.formatted(Formatting.RED)
|
|
.append(new LiteralText(nachricht + ""))
|
|
);
|
|
return 1;
|
|
}
|
|
|
|
public LiteralArgumentBuilder<FabricClientCommandSource> register() {
|
|
return this.getCommandSpecification().executes(context -> this.run(context));
|
|
}
|
|
|
|
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification() {
|
|
//return literal("echo").then(argument("nachricht", DoubleArgumentType.doubleArg()));
|
|
return literal("test_client_command_with_arg").then(
|
|
ClientCommandManager.argument("nachricht", DoubleArgumentType.doubleArg()));
|
|
}
|
|
}
|