net.minecraft.util.ChatStyle#net.minecraft.event.ClickEvent源码实例Demo

下面列出了net.minecraft.util.ChatStyle#net.minecraft.event.ClickEvent 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Hyperium   文件: NetworkHandler.java
@Override
public void handleChat(String s) {
    if (s.toLowerCase().contains("reconnecting hyperium connection")) return;
    Hyperium.LOGGER.debug("Chat: {}", s);
    s = s.replace("&", C.COLOR_CODE_SYMBOL);
    IChatComponent chatComponent = new ChatComponentText("");

    Arrays.stream(s.split(" ")).forEach(s1 -> {
        ChatComponentText iChatComponents = new ChatComponentText(s1 + " ");
        if (s1.contains(".") && !s1.startsWith(".") && !s1.endsWith(".")) {
            ChatStyle chatStyle = new ChatStyle();
            chatStyle.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, s1.startsWith("http") ? s1 : "http://" + s1));
            iChatComponents.setChatStyle(chatStyle);
        }
        chatComponent.appendSibling(iChatComponents);
    });

    GeneralChatHandler.instance().sendMessage(chatComponent);
}
 
源代码2 项目: LiquidBounce   文件: MixinGuiEditSign.java
@Inject(method = "actionPerformed", at = @At("HEAD"))
private void actionPerformed(GuiButton button, CallbackInfo callbackInfo) {
    switch(button.id) {
        case 0:
            if(!signCommand1.getText().isEmpty())
                tileSign.signText[0].setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, signCommand1.getText())));

            if(!signCommand2.getText().isEmpty())
                tileSign.signText[1].setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, signCommand2.getText())));

            if(!signCommand3.getText().isEmpty())
                tileSign.signText[2].setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, signCommand3.getText())));

            if(!signCommand4.getText().isEmpty())
                tileSign.signText[3].setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, signCommand4.getText())));
            break;
        case 1:
            enabled = !enabled;
            toggleButton.displayString = enabled ? "Disable Formatting codes" : "Enable Formatting codes";
            break;
    }
}
 
源代码3 项目: LiquidBounce   文件: MixinGuiEditSign.java
@Inject(method = "actionPerformed", at = @At("HEAD"))
private void actionPerformed(GuiButton button, CallbackInfo callbackInfo) {
    switch(button.id) {
        case 0:
            if(!signCommand1.getText().isEmpty())
                tileSign.signText[0].setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, signCommand1.getText())));

            if(!signCommand2.getText().isEmpty())
                tileSign.signText[1].setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, signCommand2.getText())));

            if(!signCommand3.getText().isEmpty())
                tileSign.signText[2].setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, signCommand3.getText())));

            if(!signCommand4.getText().isEmpty())
                tileSign.signText[3].setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, signCommand4.getText())));
            break;
        case 1:
            enabled = !enabled;
            toggleButton.displayString = enabled ? "Disable Formatting codes" : "Enable Formatting codes";
            break;
    }
}
 
源代码4 项目: Hyperium   文件: HyperiumEntityPlayer.java
public IChatComponent getDisplayName() {
    if (cachedName == null || System.currentTimeMillis() - lastChangeTime > 50L) {
        IChatComponent ichatcomponent = new ChatComponentText(ScorePlayerTeam
            .formatPlayerName(parent.getTeam(), displayName));
        ichatcomponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + parent.getName() + " "));
        //Unneeded for client
        if (Minecraft.getMinecraft().isIntegratedServerRunning()) {
            ichatcomponent.getChatStyle()
                .setChatHoverEvent(((IMixinEntity) parent).callGetHoverEvent());
        }
        ichatcomponent.getChatStyle().setInsertion(parent.getName());
        cachedName = ichatcomponent;
    }

    return cachedName;
}
 
源代码5 项目: LiquidBounce   文件: MixinGuiScreen.java
@Inject(method = "handleComponentHover", at = @At("HEAD"))
private void handleHoverOverComponent(IChatComponent component, int x, int y, final CallbackInfo callbackInfo) {
    if (component == null || component.getChatStyle().getChatClickEvent() == null || !LiquidBounce.moduleManager.getModule(ComponentOnHover.class).getState())
        return;

    final ChatStyle chatStyle = component.getChatStyle();

    final ClickEvent clickEvent = chatStyle.getChatClickEvent();
    final HoverEvent hoverEvent = chatStyle.getChatHoverEvent();

    drawHoveringText(Collections.singletonList("§c§l" + clickEvent.getAction().getCanonicalName().toUpperCase() + ": §a" + clickEvent.getValue()), x, y - (hoverEvent != null ? 17 : 0));
}
 
源代码6 项目: LiquidBounce   文件: MixinGuiScreen.java
@Inject(method = "handleComponentHover", at = @At("HEAD"))
private void handleHoverOverComponent(IChatComponent component, int x, int y, final CallbackInfo callbackInfo) {
    if (component == null || component.getChatStyle().getChatClickEvent() == null || !LiquidBounce.moduleManager.getModule(ComponentOnHover.class).getState())
        return;

    final ChatStyle chatStyle = component.getChatStyle();

    final ClickEvent clickEvent = chatStyle.getChatClickEvent();
    final HoverEvent hoverEvent = chatStyle.getChatHoverEvent();

    drawHoveringText(Collections.singletonList("§c§l" + clickEvent.getAction().getCanonicalName().toUpperCase() + ": §a" + clickEvent.getValue()), x, y - (hoverEvent != null ? 17 : 0));
}
 
源代码7 项目: Hyperium   文件: UpdateChecker.java
@InvokeEvent
public void serverJoinEvent(ServerJoinEvent event) {
    if (asked) return; //If they were already asked, don't even make the new thread.
    UpdateUtils updateUtils = new UpdateUtils();
    Multithreading.runAsync(() -> {
        boolean latest = updateUtils.isAbsoluteLatest();
        boolean beta = updateUtils.isBeta();
        int version = Metadata.getVersionID();
        Hyperium.LOGGER.info("version is: " + version);
        if (beta) return; // dont alert beta users
        if (latest) return; //If they're on the latest version, I don't want to mess with them.

        Hyperium.INSTANCE.getNotification().display("You have an update pending.",
            "Click here to be sent to the installer.",
            10f,
            null, () -> {
                try {
                    Desktop.getDesktop().browse(new URI("https://hyperium.cc/downloads"));
                } catch (IOException | URISyntaxException e) {
                    IChatComponent urlComponent = new
                        ChatComponentText(ChatColor.RED + "[Hyperium] " +
                        ChatColor.GRAY + "Click to be sent to update Hyperium");
                    urlComponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://hyperium.cc/downloads"));
                    Hyperium.INSTANCE.getHandlers().getGeneralChatHandler().sendMessage(urlComponent);
                }
            }, new Color(200, 150, 50));
        asked = true;
    });
}
 
源代码8 项目: Hyperium   文件: CommandNickHider.java
public void sendMessage(String message, String hover, String click) {
    ChatComponentText chatComponent = new ChatComponentText(ChatColor.YELLOW + message);
    if (hover != null && !hover.isEmpty()) {
        chatComponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
            new ChatComponentText(ChatColor.AQUA + hover + (!click.isEmpty() ? "\n" + click : ""))));
    }

    if (click != null && !click.isEmpty()) {
        chatComponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, click));
    }

    Minecraft.getMinecraft().thePlayer.addChatComponentMessage(chatComponent);
}
 
源代码9 项目: MediaMod   文件: MediaModCommand.java
@Override
public void processCommand(ICommandSender sender, String[] args) {
    if(args.length <= 0) {
        TickScheduler.INSTANCE.schedule(1, () -> FMLClientHandler.instance().getClient().displayGuiScreen(new GuiMediaModSettings()));
    } else {
        String subcommand = args[0];
        if(subcommand.equalsIgnoreCase("party")) {
            if(args.length >= 2) {
                String function = args[1];
                if(function.equalsIgnoreCase("start")) {
                    if(!MediaMod.INSTANCE.partyManager.canStartParty()) {
                        PlayerMessager.sendMessage(ChatColor.RED + "You are already in a party!", true);
                        return;
                    }

                    PlayerMessager.sendMessage(ChatColor.GRAY + "Creating MediaMod Party... " + "(note: this only works with spotify at the moment)", true);

                    String code = MediaMod.INSTANCE.partyManager.startParty();
                    if(code.equals("")) {
                        PlayerMessager.sendMessage(ChatColor.RED + "An error occurred whilst creating your MediaMod party!", true);
                    } else {
                        IChatComponent urlComponent = new ChatComponentText(ChatColor.WHITE + "" + ChatColor.BOLD + code);
                        urlComponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, code));
                        urlComponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("Copy Code")));
                        PlayerMessager.sendMessage(new ChatComponentText(ChatColor.GRAY + "Share this code with your friends to invite them to your party: ").appendSibling(urlComponent), true);
                    }
                } else if (function.equalsIgnoreCase("leave")) {
                    if(!MediaMod.INSTANCE.partyManager.canStartParty()) {
                        boolean success = MediaMod.INSTANCE.partyManager.leaveParty();
                        if(success) {
                            PlayerMessager.sendMessage((ChatColor.GRAY + "You have left the party"), true);
                        } else {
                            PlayerMessager.sendMessage(ChatColor.RED + "An error occurred whilst trying to leave the party!", true);
                        }
                    } else {
                        PlayerMessager.sendMessage(ChatColor.RED + "You are not in a party!");
                    }
                }
            } else {
                PlayerMessager.sendMessage(ChatColor.RED + "Incorrect syntax! Usage: /mm party <start/invite/info/join/leave>");
            }
        }
    }
}
 
源代码10 项目: Hyperium   文件: MixinChatStyle.java
/**
 * @author Sk1er
 */
@Inject(method = "setChatClickEvent", at = @At("HEAD"))
private void setChatClickEvent(ClickEvent boldIn, CallbackInfoReturnable<ChatStyle> callbackInfoReturnable) {
    hyperiumChatStyle.resetCache();
}