51 lines
2 KiB
Java
51 lines
2 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 com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
|
import net.minecraft.client.toast.SystemToast;
|
|
import net.minecraft.command.argument.EntityArgumentType;
|
|
import net.minecraft.text.Text;
|
|
|
|
import net.saltymc.eaa.util.mojangApi.PlayerInfo;
|
|
|
|
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument;
|
|
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal;
|
|
|
|
public class TagCommand extends EaaModCommand{
|
|
@Override
|
|
public int run(CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
|
FabricClientCommandSource source = context.getSource();
|
|
|
|
String player = StringArgumentType.getString(context,"player");
|
|
String tag = StringArgumentType.getString(context,"tag");
|
|
|
|
SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.TUTORIAL_HINT, Text.of(tag), Text.of(player));
|
|
|
|
Text text = null;
|
|
try {
|
|
String playerUUID = PlayerInfo.playerNameToUUID(player);
|
|
String playerName = PlayerInfo.playerUUIDToName(playerUUID);
|
|
|
|
text = Text.of("You tagged player " + playerName + " : " + playerUUID);
|
|
} catch (Exception e) {
|
|
text = Text.of(e.toString());
|
|
}
|
|
source.sendFeedback(text);
|
|
|
|
return 1;
|
|
}
|
|
|
|
@Override
|
|
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification() {
|
|
return literal("/tag").then(
|
|
argument("player", StringArgumentType.word())
|
|
.suggests((ctx, builder) -> EntityArgumentType.player().listSuggestions(ctx, builder))
|
|
.then(argument("tag", StringArgumentType.word())
|
|
.executes(this)
|
|
));
|
|
}
|
|
}
|