use of net.minecraft.text.HoverEvent in project meteor-client by MeteorDevelopment.
the class BindsCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
// Modules
List<Module> modules = Modules.get().getAll().stream().filter(module -> module.keybind.isSet()).collect(Collectors.toList());
ChatUtils.info("--- Bound Modules ((highlight)%d(default)) ---", modules.size());
for (Module module : modules) {
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, getTooltip(module));
MutableText text = new LiteralText(module.title).formatted(Formatting.WHITE);
text.setStyle(text.getStyle().withHoverEvent(hoverEvent));
MutableText sep = new LiteralText(" - ");
sep.setStyle(sep.getStyle().withHoverEvent(hoverEvent));
text.append(sep.formatted(Formatting.GRAY));
MutableText key = new LiteralText(module.keybind.toString());
key.setStyle(key.getStyle().withHoverEvent(hoverEvent));
text.append(key.formatted(Formatting.GRAY));
ChatUtils.sendMsg(text);
}
return SINGLE_SUCCESS;
});
}
use of net.minecraft.text.HoverEvent in project meteor-client by MeteorDevelopment.
the class CommandsCommand method getCommandText.
private BaseText getCommandText(Command command) {
// Hover tooltip
BaseText tooltip = new LiteralText("");
tooltip.append(new LiteralText(Utils.nameToTitle(command.getName())).formatted(Formatting.BLUE, Formatting.BOLD)).append("\n");
BaseText aliases = new LiteralText(Config.get().prefix.get() + command.getName());
if (command.getAliases().size() > 0) {
aliases.append(", ");
for (String alias : command.getAliases()) {
if (alias.isEmpty())
continue;
aliases.append(Config.get().prefix.get() + alias);
if (!alias.equals(command.getAliases().get(command.getAliases().size() - 1)))
aliases.append(", ");
}
}
tooltip.append(aliases.formatted(Formatting.GRAY)).append("\n\n");
tooltip.append(new LiteralText(command.getDescription()).formatted(Formatting.WHITE));
// Text
BaseText text = new LiteralText(Utils.nameToTitle(command.getName()));
if (command != Commands.get().getAll().get(Commands.get().getAll().size() - 1))
text.append(new LiteralText(", ").formatted(Formatting.GRAY));
text.setStyle(text.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, tooltip)).withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, Config.get().prefix.get() + command.getName())));
return text;
}
use of net.minecraft.text.HoverEvent in project carpet-discarpet by replaceitem.
the class DiscarpetCommand method register.
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(literal("discarpet").requires(serverCommandSource -> serverCommandSource.hasPermissionLevel(2)).executes(commandContext -> {
String version = FabricLoader.getInstance().getModContainer("discarpet").get().getMetadata().getVersion().getFriendlyString();
MutableText text = new LiteralText("Discarpet version " + version).formatted(Formatting.BLUE);
text.append("\nFor help, see the ");
text.append(new LiteralText("documentation").setStyle(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/replaceitem/carpet-discarpet/blob/master/docs/Full.md")).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Click to get to the Discarpet documentation"))).withFormatting(Formatting.UNDERLINE).withColor(Formatting.DARK_BLUE)));
commandContext.getSource().sendFeedback(text, true);
return 1;
}).then(literal("list").executes(commandContext -> {
Set<String> botIDs = Discarpet.discordBots.keySet();
final LiteralText t;
if (botIDs.size() == 0) {
t = (LiteralText) new LiteralText("There are no bots active:\n").formatted(Formatting.RED);
} else {
t = (LiteralText) new LiteralText("There are " + botIDs.size() + " bots active\n").formatted(Formatting.GREEN);
}
botIDs.forEach(id -> t.append(new LiteralText(id + "\n").formatted(Formatting.BLUE)));
commandContext.getSource().sendFeedback(t, true);
return botIDs.size();
})).then(literal("getInvite").then(CommandManager.argument("id", StringArgumentType.string()).suggests(BOTS).executes(commandContext -> {
String id = StringArgumentType.getString(commandContext, "id");
String invite = Discarpet.discordBots.get(id).getInvite();
Text text = ((new LiteralText("Click here to get the invite link for the bot")).styled((style) -> {
return style.withColor(Formatting.BLUE).withFormatting(Formatting.UNDERLINE).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, invite)).withHoverEvent(new HoverEvent(net.minecraft.text.HoverEvent.Action.SHOW_TEXT, new LiteralText("Click to open the invite link"))).withInsertion(invite);
}));
commandContext.getSource().sendFeedback(text, false);
return 1;
}))).then(literal("reload").executes(commandContext -> {
Discarpet.loadConfig(commandContext.getSource());
return 1;
})));
}
use of net.minecraft.text.HoverEvent in project fabric-name-history-lookup by Woolyenough.
the class ClientCommands method namemc.
private static int namemc(CommandContext<FabricClientCommandSource> context) {
CompletableFuture.runAsync(() -> {
String name = context.getInput().split(" ")[1];
String[] playerNameAndUUID = get_player_name_and_uuid(name);
String username = playerNameAndUUID[0];
if (Objects.equals(username, "None")) {
context.getSource().sendFeedback(new LiteralText("§7[Click] §eSearch " + name + " on NameMC §c§o(account does not exist)").styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://namemc.com/profile/" + name)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(name + "\n\n§7§oClick to open NameMC")))));
} else {
context.getSource().sendFeedback(new LiteralText("§7[Click] §eLook at " + username + "'s NameMC page").styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://namemc.com/profile/" + username)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(username + "\n\n§7§oClick to open NameMC")))));
}
});
return 0;
}
use of net.minecraft.text.HoverEvent in project meteor-rejects by AntiCope.
the class Seeds method sendInvalidVersionWarning.
private static void sendInvalidVersionWarning(String seed, String targetVer) {
BaseText msg = new LiteralText(String.format("Couldn't resolve minecraft version \"%s\". Using %s instead. If you wish to change the version run: ", targetVer, MCVersion.latest().name));
String cmd = String.format("%sseed %s ", Config.get().prefix, seed);
BaseText cmdText = new LiteralText(cmd + "<version>");
cmdText.setStyle(cmdText.getStyle().withUnderline(true).withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("run command"))));
msg.append(cmdText);
msg.setStyle(msg.getStyle().withColor(Formatting.YELLOW));
ChatUtils.sendMsg("Seed", msg);
}
Aggregations