use of net.minecraft.text.HoverEvent in project fabric-name-history-lookup by Woolyenough.
the class ClientCommands method names.
private static int names(CommandContext<FabricClientCommandSource> context) {
CompletableFuture.runAsync(() -> {
String name = context.getInput().split(" ")[1];
String[] playerNameAndUUID = get_player_name_and_uuid(name);
String username = playerNameAndUUID[0];
String uuid = playerNameAndUUID[1];
if (Objects.equals(username, "None")) {
context.getSource().sendError(new LiteralText("No account exists by that name .-."));
} else {
context.getSource().sendFeedback(new LiteralText("§7[Hover] §eView name history of " + username).styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://namemc.com/profile/" + username)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, get_player_name_history(username, uuid).append(new LiteralText("\n\n§7§oClick to open in NameMC!"))))));
}
});
return 0;
}
use of net.minecraft.text.HoverEvent in project BleachHack by BleachDrinker420.
the class CmdBetterChat method onCommand.
@Override
public void onCommand(String alias, String[] args) throws Exception {
if (args.length < 2) {
throw new CmdSyntaxException();
}
BetterChat chat = ModuleManager.getModule(BetterChat.class);
if (args[0].equalsIgnoreCase("filter")) {
if (args[1].equalsIgnoreCase("list")) {
MutableText text = new LiteralText("Filter Entries:");
int i = 1;
for (Pattern pat : chat.filterPatterns) {
text = text.append(new LiteralText("\n\u00a76" + i + " > \u00a7f" + pat.pattern()).styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Click to remove this filter."))).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, getPrefix() + "betterchat filter remove " + pat.pattern()))));
i++;
}
BleachLogger.info(text);
} else if (args[1].equalsIgnoreCase("add")) {
String arg = String.join(" ", ArrayUtils.subarray(args, 2, args.length)).trim();
chat.filterPatterns.add(Pattern.compile(arg));
JsonArray jsonFilter = new JsonArray();
chat.filterPatterns.forEach(p -> jsonFilter.add(p.toString()));
BleachFileHelper.saveMiscSetting("betterChatFilter", jsonFilter);
BleachLogger.info("Added \"" + arg + "\" to the filter patterns.");
} else if (args[1].equalsIgnoreCase("remove")) {
String arg = String.join(" ", ArrayUtils.subarray(args, 2, args.length)).trim();
if (chat.filterPatterns.removeIf(p -> p.toString().equals(arg))) {
JsonArray jsonFilter = new JsonArray();
chat.filterPatterns.forEach(p -> jsonFilter.add(p.toString()));
BleachFileHelper.saveMiscSetting("betterChatFilter", jsonFilter);
BleachLogger.info("Removed \"" + arg + "\" from the filter patterns.");
} else {
BleachLogger.info("Could not find \"" + arg + "\" in the pattern list.");
}
} else {
throw new CmdSyntaxException();
}
} else if (args[0].equalsIgnoreCase("prefix")) {
if (args[1].equalsIgnoreCase("current")) {
BleachLogger.info("Current prefix: \"" + chat.prefix + "\"");
} else if (args[1].equalsIgnoreCase("reset")) {
chat.prefix = "";
BleachFileHelper.saveMiscSetting("betterChatPrefix", new JsonPrimitive(chat.prefix));
BleachLogger.info("Reset the customchat prefix!");
} else if (args[1].equalsIgnoreCase("set") && args.length >= 3) {
chat.prefix = String.join(" ", ArrayUtils.subarray(args, 2, args.length)).trim() + " ";
BleachFileHelper.saveMiscSetting("betterChatPrefix", new JsonPrimitive(chat.prefix));
BleachLogger.info("Set prefix to: \"" + chat.prefix + "\"");
} else {
throw new CmdSyntaxException();
}
} else if (args[0].equalsIgnoreCase("suffix")) {
if (args[1].equalsIgnoreCase("current")) {
BleachLogger.info("Current suffix: \"" + chat.suffix + "\"");
} else if (args[1].equalsIgnoreCase("reset")) {
chat.suffix = " \u25ba \u0432\u029f\u0454\u03b1c\u043d\u043d\u03b1c\u043a";
BleachFileHelper.saveMiscSetting("betterChatSuffix", new JsonPrimitive(chat.suffix));
BleachLogger.info("Reset the customchat suffix!");
} else if (args[1].equalsIgnoreCase("set") && args.length >= 3) {
chat.suffix = String.join(" ", ArrayUtils.subarray(args, 2, args.length)).trim() + " ";
BleachFileHelper.saveMiscSetting("betterChatSuffix", new JsonPrimitive(chat.suffix));
BleachLogger.info("Set suffix to: \"" + chat.suffix + "\"");
} else {
throw new CmdSyntaxException();
}
} else {
throw new CmdSyntaxException();
}
}
use of net.minecraft.text.HoverEvent in project BleachHack by BleachDrinker420.
the class BetterChat method onPacketRead.
@BleachSubscribe
public void onPacketRead(EventPacket.Read event) {
if (event.getPacket() instanceof GameMessageS2CPacket) {
GameMessageS2CPacket packet = (GameMessageS2CPacket) event.getPacket();
if (packet.getLocation() == MessageType.GAME_INFO)
return;
Text message = packet.getMessage().shallowCopy();
if (getSetting(6).asToggle().getState()) {
message = Texts.forEachWord(message, (string, style) -> {
String stripped = Formatting.strip(string);
if (stripped.matches("['\u00a1-\u00f5]+\u00ff[0-~]+")) {
String decrypted = decrypt(stripped);
if (decrypted != null) {
return new LiteralText("<").styled(s -> s.withColor(BleachHack.watermark.getColor1())).append(new LiteralText(decrypted).styled(s -> s.withColor(0xffffff).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(string).setStyle(style))))).append(new LiteralText(">").styled(s -> s.withColor(BleachHack.watermark.getColor2())));
}
}
return null;
});
}
if (!filterPatterns.isEmpty() && getSetting(4).asToggle().getState()) {
int mode = getSetting(4).asToggle().getChild(0).asMode().getMode();
if (mode == 0) {
for (Pattern pattern : filterPatterns) {
message = Texts.replaceAll(message, pattern, (string, style) -> new LiteralText(StringUtils.repeat('|', string.length() * 2)).styled(s -> s.withColor(Formatting.GRAY).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(string).setStyle(style)))));
}
} else {
for (Pattern pat : filterPatterns) {
if (pat.matcher(message.getString()).find()) {
if (mode == 1) {
Text messageCopy = message.shallowCopy();
message = new LiteralText("\u00a77Blocked Message").styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, messageCopy)));
break;
} else {
event.setCancelled(true);
return;
}
}
}
}
}
if (getSetting(3).asToggle().getState()) {
DateTimeFormatter formatter = getSetting(3).asToggle().getChild(0).asToggle().getState() ? DateTimeFormatter.ofPattern("HH:mm:ss") : DateTimeFormatter.ofPattern("HH:mm");
message = new LiteralText("\u00a78[\u00a77" + LocalDateTime.now().format(formatter) + "\u00a78] ").append(message);
}
if (!message.equals(packet.getMessage())) {
packet.message = message;
}
}
}
use of net.minecraft.text.HoverEvent in project BleachHack by BleachDrinker420.
the class CmdHelp method onCommand.
@Override
public void onCommand(String alias, String[] args) throws Exception {
String cmd = args.length == 0 ? "" : args[0];
if (cmd.isEmpty()) {
BleachLogger.info("Commands:");
} else {
BleachLogger.info("Syntax for " + getPrefix() + cmd.toLowerCase(Locale.ENGLISH) + ":");
}
for (Command c : CommandManager.getCommands()) {
if (!cmd.isEmpty() && Stream.of(c.getAliases()).noneMatch(cmd::equalsIgnoreCase))
continue;
MutableText text = new LiteralText(getPrefix() + c.getAliases()[0] + ": \u00a7f" + c.getDescription()).styled(s -> s.withColor(BleachLogger.INFO_COLOR));
BleachLogger.noPrefix(text.styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, c.getHelpTooltip()))));
}
}
use of net.minecraft.text.HoverEvent in project BleachHack by BleachDrinker420.
the class BleachCreditsScreen method getBoosterText.
private Text getBoosterText(ImmutablePair<Boolean, String> pair) {
int color = pair.getLeft() ? 0x1abc9c : 0xf579ff;
String[] split = pair.getRight().split("#");
return new LiteralText(split[0]).styled(s -> s.withColor(color).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(pair.getRight()).styled(s1 -> s1.withColor(color)))));
}
Aggregations