use of net.minecraft.text.HoverEvent in project meteor-client by MeteorDevelopment.
the class ModulesCommand method getModuleText.
private BaseText getModuleText(Module module) {
// Hover tooltip
BaseText tooltip = new LiteralText("");
tooltip.append(new LiteralText(module.title).formatted(Formatting.BLUE, Formatting.BOLD)).append("\n");
tooltip.append(new LiteralText(module.name).formatted(Formatting.GRAY)).append("\n\n");
tooltip.append(new LiteralText(module.description).formatted(Formatting.WHITE));
BaseText finalModule = new LiteralText(module.title);
if (!module.equals(Modules.get().getGroup(module.category).get(Modules.get().getGroup(module.category).size() - 1)))
finalModule.append(new LiteralText(", ").formatted(Formatting.GRAY));
finalModule.setStyle(finalModule.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, tooltip)));
return finalModule;
}
use of net.minecraft.text.HoverEvent in project Client by MatHax.
the class ChatEncryption method onMessageReceive.
@EventHandler
private void onMessageReceive(ReceiveMessageEvent event) {
((ChatHudAccessor) mc.inGameHud.getChatHud()).getVisibleMessages().removeIf((message) -> message.getId() == event.id && event.id != 0);
((ChatHudAccessor) mc.inGameHud.getChatHud()).getMessages().removeIf((message) -> message.getId() == event.id && event.id != 0);
Text message = event.getMessage();
if (message.getString().endsWith(suffix.get()) && !suffix.get().isEmpty()) {
String[] msg = message.getString().split(encryptedPrefix);
try {
String chat = decrypt(msg[1], customKey.get() ? groupKey.get() : password);
BaseText prefixOpenBorder = new LiteralText("[");
prefixOpenBorder.setStyle(prefixOpenBorder.getStyle().withFormatting(Formatting.GRAY));
BaseText prefix = new LiteralText("Encrypted Chat");
prefix.setStyle(prefix.getStyle().withColor(MatHax.INSTANCE.MATHAX_COLOR.getPacked()));
BaseText prefixCloseBorder = new LiteralText("] ");
prefixCloseBorder.setStyle(prefixCloseBorder.getStyle().withFormatting(Formatting.GRAY));
BaseText chatText = new LiteralText(msg[0] + chat);
chatText.setStyle(chatText.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(msg[1]))));
BaseText chatMessage = new LiteralText("");
if (Modules.get().get(BetterChat.class).displayPlayerHeads())
chatMessage.append(" ");
chatMessage.append(prefixOpenBorder);
chatMessage.append(prefix);
chatMessage.append(prefixCloseBorder);
chatMessage.append(chatText);
message = chatMessage;
} catch (Exception exception) {
message = event.getMessage();
}
}
event.setMessage(message);
}
use of net.minecraft.text.HoverEvent in project Client by MatHax.
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 + command.getName());
if (command.getAliases().size() > 0) {
aliases.append(", ");
for (String alias : command.getAliases()) {
if (alias.isEmpty())
continue;
aliases.append(Config.get().prefix + 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 + command.getName())));
return text;
}
use of net.minecraft.text.HoverEvent in project KahzerxMod by otakucraft.
the class ExchangeCommand method register.
public void register(CommandDispatcher<ServerCommandSource> dispatcher, ShopExtension extension) {
dispatcher.register(literal("exchange").requires(server -> extension.extensionSettings().isEnabled()).then(literal("confirm").then(argument("count", IntegerArgumentType.integer(0)).then(argument("item", StringArgumentType.string()).executes(context -> {
ServerPlayerEntity player = context.getSource().getPlayer();
Item item = player.getMainHandStack().getItem();
String sentItem = StringArgumentType.getString(context, "item");
int count = player.getMainHandStack().getCount();
int sentCount = IntegerArgumentType.getInteger(context, "count");
if (!basicVerify(context, player)) {
return 1;
}
if (count != sentCount || !item.getTranslationKey().equals(sentItem)) {
context.getSource().sendFeedback(MarkEnum.CROSS.appendMessage("El stack de tu mano ha cambiado!"), false);
return 1;
}
extension.updateFounds(player, Exchange.getValue(item) * count);
extension.logExchange(player, item, count);
player.setStackInHand(Hand.MAIN_HAND, new ItemStack(Items.AIR));
context.getSource().sendFeedback(MarkEnum.TICK.appendMessage("Añadidos ").append(MarkEnum.OTAKU_COIN.appendMessage(String.valueOf(Exchange.getValue(item) * count))), false);
return 1;
})))).then(literal("abort").then(argument("count", IntegerArgumentType.integer(0)).then(argument("item", StringArgumentType.string()).executes(context -> {
ServerPlayerEntity player = context.getSource().getPlayer();
Item item = player.getMainHandStack().getItem();
String sentItem = StringArgumentType.getString(context, "item");
int count = player.getMainHandStack().getCount();
int sentCount = IntegerArgumentType.getInteger(context, "count");
if (count == sentCount || item.getTranslationKey().equals(sentItem)) {
context.getSource().sendFeedback(MarkEnum.TICK.appendMessage("Exchange cancelado!"), false);
}
return 1;
})))).executes(context -> {
ServerPlayerEntity player = context.getSource().getPlayer();
Item item = player.getMainHandStack().getItem();
int count = player.getMainHandStack().getCount();
if (!basicVerify(context, player)) {
return 1;
}
context.getSource().sendFeedback(MarkEnum.INFO.appendMessage(String.format("Vas a cambiar %d %s por ", count, item.getName().getString())).append(MarkEnum.OTAKU_COIN.appendMessage(String.format("%d", Exchange.getValue(item) * count))), false);
context.getSource().sendFeedback(MarkEnum.QUESTION.appendMessage("Confirmar exchange? ").append(new LiteralText("[Sí]").styled(style -> style.withColor(Formatting.GREEN).withBold(true).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/exchange confirm %d %s", count, item.getTranslationKey()))).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("confirmar exchange"))))).append(new LiteralText(" ").styled(style -> style.withColor(Formatting.WHITE))).append(new LiteralText("[No]").styled(style -> style.withColor(Formatting.DARK_RED).withBold(true).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/exchange abort %d %s", count, item.getTranslationKey()))).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("cancelar exchange"))))), false);
return 1;
}).then(literal("info").executes(context -> {
context.getSource().sendFeedback(MarkEnum.OTAKU_COIN.appendMessage("a"), false);
return 1;
})));
}
use of net.minecraft.text.HoverEvent in project meteor-client by MeteorDevelopment.
the class NbtCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("add").then(argument("nbt_data", CompoundNbtTagArgumentType.nbtTag()).executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (validBasic(stack)) {
NbtCompound tag = CompoundNbtTagArgumentType.getTag(s, "nbt_data");
NbtCompound source = stack.getOrCreateNbt();
if (tag != null) {
source.copyFrom(tag);
setStack(stack);
} else {
error("Some of the NBT data could not be found, try using: " + Config.get().prefix.get() + "nbt set {nbt}");
}
}
return SINGLE_SUCCESS;
})));
builder.then(literal("set").then(argument("nbt_data", CompoundNbtTagArgumentType.nbtTag()).executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (validBasic(stack)) {
NbtCompound tag = s.getArgument("nbt_data", NbtCompound.class);
stack.setNbt(tag);
setStack(stack);
}
return SINGLE_SUCCESS;
})));
builder.then(literal("remove").then(argument("nbt_path", NbtPathArgumentType.nbtPath()).executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (validBasic(stack)) {
NbtPathArgumentType.NbtPath path = s.getArgument("nbt_path", NbtPathArgumentType.NbtPath.class);
path.remove(stack.getNbt());
}
return SINGLE_SUCCESS;
})));
builder.then(literal("get").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack == null) {
error("You must hold an item in your main hand.");
} else {
NbtCompound tag = stack.getNbt();
String nbt = tag == null ? "{}" : tag.asString();
BaseText copyButton = new LiteralText("NBT");
copyButton.setStyle(copyButton.getStyle().withFormatting(Formatting.UNDERLINE).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, this.toString("copy"))).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Copy the NBT data to your clipboard."))));
BaseText text = new LiteralText("");
text.append(copyButton);
text.append(new LiteralText(": " + nbt));
info(text);
}
return SINGLE_SUCCESS;
}));
builder.then(literal("copy").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack == null) {
error("You must hold an item in your main hand.");
} else {
NbtCompound tag = stack.getOrCreateNbt();
mc.keyboard.setClipboard(tag.toString());
BaseText nbt = new LiteralText("NBT");
nbt.setStyle(nbt.getStyle().withFormatting(Formatting.UNDERLINE).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(tag.toString()))));
BaseText text = new LiteralText("");
text.append(nbt);
text.append(new LiteralText(" data copied!"));
info(text);
}
return SINGLE_SUCCESS;
}));
builder.then(literal("count").then(argument("count", IntegerArgumentType.integer(-127, 127)).executes(context -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (validBasic(stack)) {
int count = IntegerArgumentType.getInteger(context, "count");
stack.setCount(count);
setStack(stack);
info("Set mainhand stack count to %s.", count);
}
return SINGLE_SUCCESS;
})));
}
Aggregations