当前位置: 首页>>代码示例>>Java>>正文


Java ClickEvent类代码示例

本文整理汇总了Java中net.minecraft.util.text.event.ClickEvent的典型用法代码示例。如果您正苦于以下问题:Java ClickEvent类的具体用法?Java ClickEvent怎么用?Java ClickEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ClickEvent类属于net.minecraft.util.text.event包,在下文中一共展示了ClickEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPlayerLogin

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event){
    if(DifficultyManager.enabled && ProgressiveDifficulty.oldConfigExists){
        TextComponentString linkComponent = new TextComponentString("[Progressive Difficulty Wiki]");
        ITextComponent[] chats = new ITextComponent[]{
                new TextComponentString("[ProgressiveDifficulty] It looks like you have a version 1.0 " +
                        "config file. Please check out the Progressive Difficulty Wiki for instructions on how" +
                        " to migrate to a version 2.0 config file."),
                linkComponent
        };
        ClickEvent goLinkEvent = new ClickEvent(ClickEvent.Action.OPEN_URL,"https://github.com/talandar/ProgressiveDifficulty/wiki/2.0-Transition");
        linkComponent.getStyle().setClickEvent(goLinkEvent);
        linkComponent.getStyle().setColor(TextFormatting.BLUE);
        linkComponent.getStyle().setUnderlined(true);
        ChatUtil.sendChat(event.player,chats);
    }
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:18,代码来源:EventHandler.java

示例2: mouseClicked

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
@Override
public boolean mouseClicked(int mouseX, int mouseY, int y, int virtualWidth) {
	ITextComponent hoveredComponent = getHoveredComponent(virtualWidth, y, mouseX, mouseY);
	if (hoveredComponent != null) {
		ClickEvent clickEvent = hoveredComponent.getStyle().getClickEvent();
		if (clickEvent != null && clickEvent.getAction() == ClickEvent.Action.CHANGE_PAGE) {
			String value = clickEvent.getValue();
			String name = null;
			if (value.contains("=")) {
				int equalsIndex = value.indexOf('=');
				name = value.substring(0, equalsIndex);
				value = value.substring(equalsIndex + 1);
			}
			CommandHelpManager.getInstance().displayHelpScreen(name, value);
			return true;
		} else {
			return GeneralUtils.handleClickEvent(clickEvent);
		}
	} else
		return false;
}
 
开发者ID:Earthcomputer,项目名称:Easy-Editors,代码行数:22,代码来源:CommandHelpManager.java

示例3: notifyUser

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
private void notifyUser(VersionData data, UpdateResponse response) {
    ITextBuilder builder = new TextBuilder()
            .translation("update.available")
            .text(data.getName())
            .format(TextFormatting.GOLD)
            .end()
            .text(" ");
    if (data.getUrl() != null)
        builder.translation("update.clickhere").end()
                .format(TextFormatting.LIGHT_PURPLE)
                .click(new ClickEvent(ClickEvent.Action.OPEN_URL, data.getUrl()))
                .text(". ");
    ITextComponent msg = builder
            .text(response.minecraft.version)
            .text(" - ")
            .text(response.minecraft.changes)
            .build();
    LogManager.getLogger("Updates").info(msg.getUnformattedText());
    this.chatProxy.addToChat("Updates", msg);
}
 
开发者ID:killjoy1221,项目名称:MnM-Utils,代码行数:21,代码来源:UpdateChecker.java

示例4: makeChat

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
private static ITextComponent makeChat(boolean tag) {

        ITextComponent chat = new TextComponentString(tag ? "[test] " : "");
        chat.getStyle().setBold(true);
        {
            ITextComponent colored = new TextComponentString("This should be green. ");
            colored.getStyle().setColor(TextFormatting.GREEN);
            chat.appendSibling(colored);
        }
        chat.appendText(" ");
        {
            ITextComponent link = new TextComponentString("This is a link.");
            link.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://google.com/"));
            chat.appendSibling(link);
        }
        return chat;
    }
 
开发者ID:killjoy1221,项目名称:TabbyChat-2,代码行数:18,代码来源:ChatTextUtilsTest.java

示例5: append

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Appends a string with the specified color(s) and an event
 * triggered on text click and on text hover. Only one actual
 * color should be specified, any other {@code TextFormatting}
 * type should be styling. (Bold, Italic, Underline, Strikethrough,
 * and Obfuscated)
 *
 * @param text The string being appended
 * @param clickEvent Click event to be used
 * @param hoverEvent Hover event to be used
 * @param colors Color formatting
 * @return This builder
 */
public final ChatBuilder append(String text, @Nullable ClickEvent clickEvent, @Nullable HoverEvent hoverEvent, TextFormatting... colors) {
    TextComponentString component = new TextComponentString(text);
    Style style = component.getStyle();
    Arrays.stream(colors).forEach(color -> {
        switch (color) {
            case BOLD: {
                style.setBold(true);
                break;
            }
            case ITALIC: {
                style.setItalic(true);
                break;
            }
            case UNDERLINE: {
                style.setUnderlined(true);
                break;
            }
            case STRIKETHROUGH: {
                style.setStrikethrough(true);
                break;
            }
            case OBFUSCATED: {
                style.setObfuscated(true);
                break;
            }
            default: {
                style.setColor(color);
                break;
            }
        }
    });
    // noinspection ConstantConditions
    style.setClickEvent(clickEvent).setHoverEvent(hoverEvent);
    this.component.appendSibling(component);
    return this;
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:50,代码来源:ChatBuilder.java

示例6: mouseClicked

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
    super.mouseClicked(mouseX, mouseY, mouseButton);

    int info2Start = (this.height / 2) - 50;

    if (orderPressed && !isSure && mouseY >= info2Start && mouseY <= info2Start + fontRendererObj.FONT_HEIGHT)
    {
        ITextComponent comp = getComponent(mouseX, mouseY);

        ClickEvent clickevent = comp.getStyle().getClickEvent();
        if (clickevent != null && clickevent.getAction() == ClickEvent.Action.OPEN_URL)
        {
            try
            {
                URI uri = new URI(clickevent.getValue());
                Class<?> oclass = Class.forName("java.awt.Desktop");
                Object object = oclass.getMethod("getDesktop").invoke(null);
                oclass.getMethod("browse", URI.class).invoke(object, uri);
            }
            catch (Throwable t)
            {
                CreeperHost.logger.error("Can\'t open url for " + clickevent, t);
            }
            return;
        }
    }

    for (TextFieldDetails field : this.fields)
    {
        field.myMouseClicked(mouseX, mouseY, mouseButton);
    }
}
 
开发者ID:CreeperHost,项目名称:CreeperHostGui,代码行数:35,代码来源:GuiPersonalDetails.java

示例7: addURLClick

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
public static ITextComponent addURLClick(ITextComponent component, String url)
{
	Style s = component.getStyle();
	s.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url));
	component.setStyle(s);
	return component;
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:8,代码来源:TextFormatter.java

示例8: getDisplayName

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Get the formatted ChatComponent that will be used for the sender's username in chat
 */
public ITextComponent getDisplayName()
{
    ITextComponent itextcomponent = new TextComponentString(ScorePlayerTeam.formatPlayerName(this.getTeam(), this.getName()));
    itextcomponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.getName() + " "));
    itextcomponent.getStyle().setHoverEvent(this.getHoverEvent());
    itextcomponent.getStyle().setInsertion(this.getName());
    return itextcomponent;
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:12,代码来源:EntityPlayer.java

示例9: getClickEvent

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
@Nullable

    /**
     * The effective chat click event.
     */
    public ClickEvent getClickEvent()
    {
        return this.clickEvent == null ? this.getParent().getClickEvent() : this.clickEvent;
    }
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:10,代码来源:Style.java

示例10: getDisplayName

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Get the formatted ChatComponent that will be used for the sender's username in chat
 */
public ITextComponent getDisplayName()
{
    ITextComponent itextcomponent = new TextComponentString("");
    if (!prefixes.isEmpty()) for (ITextComponent prefix : prefixes) itextcomponent.appendSibling(prefix);
    itextcomponent.appendSibling(new TextComponentString(ScorePlayerTeam.formatPlayerName(this.getTeam(), this.getDisplayNameString())));
    if (!suffixes.isEmpty()) for (ITextComponent suffix : suffixes) itextcomponent.appendSibling(suffix);
    itextcomponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.getName() + " "));
    itextcomponent.getStyle().setHoverEvent(this.getHoverEvent());
    itextcomponent.getStyle().setInsertion(this.getName());
    return itextcomponent;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:EntityPlayer.java

示例11: sendRecordMessage

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Send record message to the player
 */
private void sendRecordMessage()
{
    EntityPlayer player = this.mc.thePlayer;

    if (this.filename.getText().isEmpty())
    {
        L10n.error(player, "recording.fill_filename");

        return;
    }

    String command = "/action record " + this.filename.getText() + " " + this.pos.getX() + " " + this.pos.getY() + " " + this.pos.getZ();

    ITextComponent component = new TextComponentString(stringClickhere);
    component.getStyle().setClickEvent(new ClickEvent(Action.RUN_COMMAND, command));
    component.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(command)));
    component.getStyle().setColor(TextFormatting.GRAY).setUnderlined(true);

    L10n.info(player, "recording.message", this.filename.getText(), component);

    /* Add the command to the history */
    List<String> messages = this.mc.ingameGUI.getChatGUI().getSentMessages();

    boolean empty = messages.isEmpty();
    boolean lastMessageIsntCommand = !empty && !messages.get(messages.size() - 1).equals(command);

    if (lastMessageIsntCommand || empty)
    {
        messages.add(command);
    }
}
 
开发者ID:mchorse,项目名称:blockbuster,代码行数:35,代码来源:GuiReplay.java

示例12: climsg

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
protected void climsg(EntityPlayer p) {
	final TextComponentTranslation tt = new TextComponentTranslation("mcflux.update.newversion", version);
	tt.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, R.MF_URL));
	p.sendMessage(tt);
}
 
开发者ID:Szewek,项目名称:Minecraft-Flux,代码行数:8,代码来源:Msg.java

示例13: handleComponentClick

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Executes the click event specified by the given chat component
 */
protected boolean handleComponentClick(ITextComponent component) {
    ClickEvent clickevent = component.getStyle().getClickEvent();

    if (clickevent == null) {
        return false;
    } else if (clickevent.getAction() == ClickEvent.Action.CHANGE_PAGE) {
        String s = clickevent.getValue();

        try {
            int i = Integer.parseInt(s) - 1;

            if (i >= 0 && i < this.bookTotalPages && i != this.currPage) {
                this.currPage = i;
                this.updateButtons();
                return true;
            }
        } catch (Throwable var5) {
            ;
        }

        return false;
    } else {
        boolean flag = super.handleComponentClick(component);
        if (flag && clickevent.getAction() == ClickEvent.Action.RUN_COMMAND) {
            this.mc.displayGuiScreen((GuiScreen)null);
        }
        return flag;
    }
}
 
开发者ID:r1chardj0n3s,项目名称:pycode-minecraft,代码行数:33,代码来源:GuiPythonBook.java

示例14: execute

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
@Override
public String execute(CommandSender sender, String[] params) throws CommandException {
	DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
	
	ITextComponent textModid = new TextComponentString("MODID:             ").setStyle(new Style().setColor(TextFormatting.DARK_AQUA));
	ITextComponent modid = new TextComponentString(Reference.MODID).setStyle(new Style().setColor(TextFormatting.GREEN));
	
	ITextComponent textVersion = new TextComponentString("VERSION:          ").setStyle(new Style().setColor(TextFormatting.DARK_AQUA));
	ITextComponent version = new TextComponentString(Reference.VERSION).setStyle(new Style().setColor(TextFormatting.GREEN));

	ITextComponent textName = new TextComponentString("NAME:              ").setStyle(new Style().setColor(TextFormatting.DARK_AQUA));
	ITextComponent name = new TextComponentString(Reference.NAME).setStyle(new Style().setColor(TextFormatting.GREEN));

	ITextComponent textModDir = new TextComponentString("MOD_DIR:          ").setStyle(new Style().setColor(TextFormatting.DARK_AQUA));
	ITextComponent modDir = new TextComponentString(Reference.getModDir().getPath()).setStyle(new Style().setColor(TextFormatting.GREEN));

	ITextComponent textBuildDate = new TextComponentString("BUILD_DATE:     ").setStyle(new Style().setColor(TextFormatting.DARK_AQUA));
	ITextComponent builDate = new TextComponentString(df.format(Reference.BUILD)).setStyle(new Style().setColor(TextFormatting.GREEN));

	ITextComponent textWebsite = new TextComponentString("WEBSITE         ").setStyle(new Style().setColor(TextFormatting.DARK_AQUA));
	ITextComponent website = new TextComponentString(Reference.WEBSITE).setStyle(new Style().setColor(TextFormatting.GREEN).setUnderlined(true).setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, Reference.WEBSITE)));
	
	sender.sendChatComponent(textModid.appendSibling(modid));
	sender.sendChatComponent(textVersion.appendSibling(version));
	sender.sendChatComponent(textName.appendSibling(name));
	sender.sendChatComponent(textModDir.appendSibling(modDir));
	sender.sendChatComponent(textBuildDate.appendSibling(builDate));
	sender.sendChatComponent(textWebsite.appendSibling(website));
	
	return null;
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:32,代码来源:CommandMorecommands.java

示例15: findMoreCommandsUpdates

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Starts a thread looking for MoreCommands updates
 */
private void findMoreCommandsUpdates() {
	this.mod.getLogger().info("Searching for MoreCommands updates");
	
	new Thread(new MoreCommandsUpdater(Loader.MC_VERSION, new MoreCommandsUpdater.UpdateCallback() {
		@Override
		public void udpate(String version, String website, String download) {
			TextComponentString text = new TextComponentString(Reference.VERSION.equals(version) ? 
					"MoreCommands update for this version found " : "new MoreCommands version found: "); 
			text.getStyle().setColor(TextFormatting.BLUE);
			TextComponentString downloadVersion = new TextComponentString(version); downloadVersion.getStyle().setColor(TextFormatting.YELLOW);
			TextComponentString homepage = new TextComponentString("Minecraft Forum"); homepage.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, website)).setColor(TextFormatting.GREEN).setItalic(true).setUnderlined(true);
			TextComponentString downloadPage = new TextComponentString("Download"); downloadPage.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, download)).setColor(TextFormatting.GREEN).setItalic(true).setUnderlined(true);
			TextComponentString comma = new TextComponentString(", "); comma.getStyle().setColor(TextFormatting.DARK_GRAY);
			TextComponentString sep = new TextComponentString(" - "); sep.getStyle().setColor(TextFormatting.DARK_GRAY);
			
			String rawText = text.getUnformattedText() + (Reference.VERSION.equals(version) ? "" : downloadVersion.getUnformattedText()) + " - " + website + ", " + download;
			if (!Reference.VERSION.equals(version)) text.appendSibling(downloadVersion);
			text.appendSibling(sep).appendSibling(homepage).appendSibling(comma).appendSibling(downloadPage);
			
			CommonProxy.this.mod.getLogger().info(rawText);
			CommonProxy.this.updateText = text;
			
			if (MoreCommands.isClientSide() && net.minecraft.client.Minecraft.getMinecraft().player != null) {
				CommonProxy.this.playerNotified = true;
				net.minecraft.client.Minecraft.getMinecraft().player.sendMessage(text);
			}
		}
	}), "MoreCommands Update Thread").start();
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:33,代码来源:CommonProxy.java


注:本文中的net.minecraft.util.text.event.ClickEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。