Java 类net.minecraft.util.ChatStyle 实例源码

项目:4Space-5    文件:SpaceRaceManager.java   
public static void onPlayerRemoval(String player, SpaceRace race)
{
    for (String member : race.getPlayerNames())
    {
        EntityPlayerMP memberObj = PlayerUtil.getPlayerForUsernameVanilla(MinecraftServer.getServer(), member);

        if (memberObj != null)
        {
            memberObj.addChatMessage(new ChatComponentText(EnumColor.DARK_AQUA + GCCoreUtil.translateWithFormat("gui.spaceRace.chat.removeSuccess", EnumColor.RED + player + EnumColor.DARK_AQUA)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA)));
        }
    }

    List<String> playerList = new ArrayList<String>();
    playerList.add(player);
    SpaceRace newRace = SpaceRaceManager.addSpaceRace(new SpaceRace(playerList, SpaceRace.DEFAULT_NAME, new FlagData(48, 32), new Vector3(1, 1, 1)));
    EntityPlayerMP playerToRemove = PlayerUtil.getPlayerBaseServerFromPlayerUsername(player, true);

    if (playerToRemove != null)
    {
        SpaceRaceManager.sendSpaceRaceData(playerToRemove, newRace);
        SpaceRaceManager.sendSpaceRaceData(playerToRemove, race);
    }
}
项目:SignPicture    文件:CommandHelpers.java   
public static void printHelp(final @Nonnull ICommandSender sender, final @Nonnull IModCommand command) {
    final ChatStyle header = new ChatStyle();
    header.setColor(EnumChatFormatting.BLUE);
    ChatBuilder.create("signpic.command."+command.getFullCommandString().replace(" ", ".")+".format").useTranslation().setStyle(header).setParams(command.getFullCommandString()).sendPlayer(sender);
    final ChatStyle body = new ChatStyle();
    body.setColor(EnumChatFormatting.GRAY);
    final List<String> aliases = command.getCommandAliases();
    if (aliases!=null)
        ChatBuilder.create("signpic.command.aliases").useTranslation().setStyle(body).setParams(aliases.toString().replace("[", "").replace("]", "")).sendPlayer(sender);
    ChatBuilder.create("signpic.command.permlevel").useTranslation().setStyle(body).setParams(Integer.valueOf(command.getRequiredPermissionLevel())).sendPlayer(sender);
    ChatBuilder.create("signpic.command."+command.getFullCommandString().replace(" ", ".")+".help").useTranslation().setStyle(body).sendPlayer(sender);
    if (!command.getChildren().isEmpty()) {
        ChatBuilder.create("signpic.command.list").useTranslation().sendPlayer(sender);
        final Iterator<SubCommand> arg3 = command.getChildren().iterator();
        while (arg3.hasNext()) {
            final SubCommand child = arg3.next();
            ChatBuilder.create("signpic.command."+child.getFullCommandString().replace(" ", ".")+".desc").useTranslation().setParams(child.getCommandName()).sendPlayer(sender);
        }
    }

}
项目:EEWReciever    文件:CommandAuth.java   
@Override
public void processSubCommand(final ICommandSender sender, final String[] args) {
    if (CommandAuth.this.auther==null)
        printAuthStart(sender);
    else if (CommandAuth.this.auther.getState()!=TweetQuakeAuther.AuthState.START)
        new ChatBuilder().setText("このコマンドは現在有効ではありません。").setStyle(new ChatStyle().setColor(EnumChatFormatting.RED)).sendPlayer(sender);
    else {
        try {
            final ChatStyle style1 = new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, CommandAuth.this.auther.getAuthURL()));
            new ChatBuilder().setText("クリックして認証URLを開く").setStyle(style1).sendPlayer(sender);
            final ChatStyle style2 = new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/eewreciever auth pin <これを消して数字にしてください>"));
            new ChatBuilder().setText("認証IDを手に入れたらクリックしてIDを入力").setStyle(style2).sendPlayer(sender);
        } catch (final TwitterException e) {
            Reference.logger.error(e.getMessage(), e);
            CommandAuth.printRetry(sender, this);
        }
    }
}
项目:EEWReciever    文件:CommandTest.java   
@Override
public void processSubCommand(final ICommandSender sender, final String[] args) {
    if (args.length>2) {
        try {
            final String arg = RootCommand.func_82360_a(sender, args, 0);
            String text = null;
            if (NumberUtils.isNumber(arg))
                text = TweetQuakeManager.intance().getAuthedTwitter().showStatus(NumberUtils.toLong(arg)).getText();
            else if (arg.startsWith("https://twitter.com/eewbot/status/"))
                TweetQuakeManager.intance().getAuthedTwitter().showStatus(NumberUtils.toLong(StringUtils.remove(arg, "https://twitter.com/eewbot/status/"))).getText();
            else
                text = arg;
            TweetQuake.instance().getQuakeUpdate().add(new TweetQuakeNode().parseString(text));
        } catch (final Exception e) {
            ChatBuilder.create(e.getClass().getName()).setStyle(new ChatStyle().setColor(EnumChatFormatting.RED)).sendPlayer(sender);
            Reference.logger.error(e.getMessage(), e);
        }
    }
}
项目:PopularMMOS-EpicProportions-Mod    文件:ClientProxy.java   
@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
public void onEvent(PlayerTickEvent event)
{

    if (!ClientProxy.haveWarnedVersionOutOfDate && event.player.worldObj.isRemote 
          && !ClientProxy.versionChecker.isLatestVersion())
    {
        ClickEvent versionCheckChatClickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, 
              "http://www.planetminecraft.com/mod/popularmmos-epicproportions-mod-season-9/");
        ChatStyle clickableChatStyle = new ChatStyle().setChatClickEvent(versionCheckChatClickEvent);
        ChatComponentText versionWarningChatComponent = 
              new ChatComponentText("Your EpicProportions Mod is not latest version!  Click here to update.");
        versionWarningChatComponent.setChatStyle(clickableChatStyle);
        event.player.addChatMessage(versionWarningChatComponent);
        ClientProxy.haveWarnedVersionOutOfDate = true;
    }

}
项目:PopularMMOS-EpicProportions-Mod    文件:VersionChecker.java   
@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
public void onEvent(PlayerTickEvent event)
{

    if (!ClientProxy.haveWarnedVersionOutOfDate && event.player.worldObj.isRemote 
          && !ClientProxy.versionChecker.isLatestVersion())
    {
        ClickEvent versionCheckChatClickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, 
              "http://www.planetminecraft.com/mod/popularmmos-epicproportions-mod-season-9/");
        ChatStyle clickableChatStyle = new ChatStyle().setChatClickEvent(versionCheckChatClickEvent);
        ChatComponentText versionWarningChatComponent = 
              new ChatComponentText("�4�l" + "Your EpicProportions Mod is not latest version!  Click here to update.");
        versionWarningChatComponent.setChatStyle(clickableChatStyle);
        event.player.addChatMessage(versionWarningChatComponent);
        ClientProxy.haveWarnedVersionOutOfDate = true;
    }

}
项目:IngressCraft    文件:IngressNotifier.java   
public static void BroadcastJoining(ItemStack scanner) {

        NBTTagCompound nbt = scanner.getTagCompound();

        ChatComponentText message = new ChatComponentText("");
        message.appendSibling(
                new ChatComponentText(nbt.getString("codename"))
                        .setChatStyle(
                                new ChatStyle()
                                        .setColor(nbt.getInteger("faction") == Constants.Faction.RESISTANCE ? EnumChatFormatting.BLUE : EnumChatFormatting.GREEN)
                        )
        );
        message.appendSibling(new ChatComponentText(" has joined the "));
        message.appendSibling(
                new ChatComponentText(nbt.getInteger("faction") == Constants.Faction.RESISTANCE ? "Resistance" : "Enlightened")
                        .setChatStyle(
                                new ChatStyle()
                                        .setColor(nbt.getInteger("faction") == Constants.Faction.RESISTANCE ? EnumChatFormatting.BLUE : EnumChatFormatting.GREEN)
                        )
        );
        message.appendSibling(new ChatComponentText("."));
        MinecraftServer.getServer().getConfigurationManager().sendChatMsg(message);

    }
项目:IngressCraft    文件:IngressNotifier.java   
public static void BroadcastDeploying(ItemStack scanner) {

        NBTTagCompound nbt = scanner.getTagCompound();

        ChatComponentText message = new ChatComponentText("");
        message.appendSibling(
                new ChatComponentText(nbt.getString("codename"))
                        .setChatStyle(
                                new ChatStyle()
                                        .setColor(nbt.getInteger("faction") == Constants.Faction.RESISTANCE ? EnumChatFormatting.BLUE : EnumChatFormatting.GREEN)
                        )
        );
        message.appendSibling(new ChatComponentText(" has deployed a Resonator."));
        MinecraftServer.getServer().getConfigurationManager().sendChatMsg(message);

    }
项目:IngressCraft    文件:IngressNotifier.java   
public static void BroadcastCapturing(ItemStack scanner) {

        NBTTagCompound nbt = scanner.getTagCompound();

        ChatComponentText message = new ChatComponentText("");
        message.appendSibling(
                new ChatComponentText(nbt.getString("codename"))
                        .setChatStyle(
                                new ChatStyle()
                                        .setColor(nbt.getInteger("faction") == Constants.Faction.RESISTANCE ? EnumChatFormatting.BLUE : EnumChatFormatting.GREEN)
                        )
        );
        message.appendSibling(new ChatComponentText(" has captured a Portal."));
        MinecraftServer.getServer().getConfigurationManager().sendChatMsg(message);

    }
项目:IngressCraft    文件:IngressNotifier.java   
public static void BroadcastDestroying(ItemStack scanner) {

        NBTTagCompound nbt = scanner.getTagCompound();

        ChatComponentText message = new ChatComponentText("");
        message.appendSibling(
                new ChatComponentText(nbt.getString("codename"))
                        .setChatStyle(
                                new ChatStyle()
                                        .setColor(nbt.getInteger("faction") == Constants.Faction.RESISTANCE ? EnumChatFormatting.BLUE : EnumChatFormatting.GREEN)
                        )
        );
        message.appendSibling(new ChatComponentText(" has destroyed a Resonator."));
        MinecraftServer.getServer().getConfigurationManager().sendChatMsg(message);

    }
项目:IngressCraft    文件:IngressNotifier.java   
public static void BroadcastNeutralizing(ItemStack scanner) {

        NBTTagCompound nbt = scanner.getTagCompound();

        ChatComponentText message = new ChatComponentText("");
        message.appendSibling(
                new ChatComponentText(nbt.getString("codename"))
                        .setChatStyle(
                                new ChatStyle()
                                        .setColor(nbt.getInteger("faction") == Constants.Faction.RESISTANCE ? EnumChatFormatting.BLUE : EnumChatFormatting.GREEN)
                        )
        );
        message.appendSibling(new ChatComponentText(" has neutralized a Portal."));
        MinecraftServer.getServer().getConfigurationManager().sendChatMsg(message);

    }
项目:Achievement-Get    文件:StatAchievement.java   
@Override
public IChatComponent getStatName() {
    IChatComponent text = this.name.createCopy();
    ChatStyle style = text.getChatStyle();
    style.setColor(color);

    // So the achievement doesn't have to be registered on the client.
    IChatComponent desc = new ChatComponentText("");
    desc.appendSibling(text.createCopy()).appendText("\n");
    IChatComponent type = new ChatComponentText("Achievement");
    type.getChatStyle().setItalic(true);
    desc.appendSibling(type).appendText("\n");
    desc.appendSibling(new ChatComponentText(this.getDescription()));
    HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, desc);
    style.setChatHoverEvent(hover);

    return text;
}
项目:Magicians-Artifice    文件:BlockWandMaker.java   
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float hitX, float hitY, float hitZ) {
    if (!player.isSneaking()) {
        if (/*world.getBlock(x,y,z) == BlockRegistry.wandMakerLit || */world.getBlockLightValue(x,y,z) >= 10 || player.isPotionActive(Potion.nightVision)) {
            if (!world.isRemote) {
                player.openGui(MagiciansArtifice.instance, GuiHandler.IDS.WandMaker, world, x, y, z);
            }
        } else {
            if (!world.isRemote) {
                player.addChatComponentMessage(new ChatComponentTranslation("maker.read.nope").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(true)));
            }
        }
    } else {
        if (world.getBlock(x,y,z) == BlockRegistry.wandMaker) {
            updateMakerState(false,world,x,y,z);
        } else if (world.getBlock(x,y,z) == BlockRegistry.wandMakerLit){
            updateMakerState(true,world,x,y,z);
        }
    }
    return true;
}
项目:Magicians-Artifice    文件:ItemLetterMerlin.java   
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    Calendar calendar = Calendar.getInstance();
    if (!world.isRemote) {
        player.addChatComponentMessage(new ChatComponentTranslation("merlin.letter.header").setChatStyle(new ChatStyle().setItalic(true).setBold(true)));
        if (calendar.get(2) + 1 == 4 && calendar.get(5) == 1) {
            player.addChatComponentMessage(new ChatComponentTranslation("merlin.letter.body.april"));
        } else {
            player.addChatComponentMessage(new ChatComponentTranslation("merlin.letter.body"));
        }
        player.addChatComponentMessage(new ChatComponentText(""));
        player.addChatComponentMessage(new ChatComponentTranslation("merlin.letter.ending").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_BLUE)));

        for (int i = 0; i < player.inventory.getSizeInventory();i++) {
            if (player.inventory.getStackInSlot(i) != null) {
                if (player.inventory.getStackInSlot(i).getItem() == ItemRegistry.merlinLetter) {
                    player.inventory.setInventorySlotContents(i, null);
                }
            }
        }

        return stack;
    }
    return stack;
}
项目:PixelUtilities    文件:PUTickHandler.java   
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
    System.out.println("world join ");
    if (!Basemod.vlcLoaded)//Display message in chat with link to vlc for arch
    {
        ChatStyle style = new ChatStyle().setUnderlined(true).setColor(EnumChatFormatting.GOLD);
        IChatComponent text = new ChatComponentText("You need to download VLC here to hear the radio ").setChatStyle(style);
        event.player.addChatComponentMessage(text);

        if (Basemod.is64bit) {//TODO detect platform (mac/linux/windogs)
            text = new ChatComponentText("http://download.videolan.org/pub/videolan/vlc/last/win64/vlc-2.1.3-win64.exe").setChatStyle(style);
        } else {
            text = new ChatComponentText("http://download.videolan.org/pub/videolan/vlc/last/win32/vlc-2.1.3-win32.exe").setChatStyle(style);
        }
        event.player.addChatComponentMessage(text);
    }
}
项目:bUpload    文件:MessageHandler.java   
public static void sendChatMessage(String key) {

        if (mc == null || mc.thePlayer == null || mc.ingameGUI == null || mc.ingameGUI.getChatGUI() == null) {
            System.err.println(TranslationManager.getTranslation(key));
            return;
        }

        IChatComponent chat = new ChatComponentText("");
        IChatComponent prefix = new ChatComponentText("[bUpload] ");
        prefix.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD));
        IChatComponent main = new ChatComponentTranslation(key);
        main.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE));
        chat.appendSibling(prefix);
        chat.appendSibling(main);

        mc.ingameGUI.getChatGUI().printChatMessage(chat);
    }
项目:bUpload    文件:MessageHandler.java   
public static void sendChatMessage(String key, Object... elements) {

        if (mc == null || mc.thePlayer == null || mc.ingameGUI == null || mc.ingameGUI.getChatGUI() == null) {
            System.err.println(TranslationManager.getTranslation(key, elements));
            return;
        }

        IChatComponent chat = new ChatComponentText("");
        IChatComponent prefix = new ChatComponentText("[bUpload] ");
        prefix.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD));
        IChatComponent main = new ChatComponentTranslation(key, elements);
        main.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE));
        chat.appendSibling(prefix);
        chat.appendSibling(main);

        mc.ingameGUI.getChatGUI().printChatMessage(chat);
    }
项目:Corruption    文件:WaterAllergyCorruption.java   
@Override
public void onUpdate(EntityPlayer player, Side side) {
    if (side == Side.SERVER) {
        if (player.worldObj.getTotalWorldTime() % 10 == 0) {
            if (player.isInWater() || (player.worldObj.isRaining() && player.worldObj.canBlockSeeTheSky((int) player.posX, (int) player.posY, (int) player.posZ))) {
                player.attackEntityFrom(DamageSource.drown, 1);
                this.playerCount.add(player.getCommandSenderName(), 10);
            }
            if (player.getCurrentEquippedItem() != null && (player.getCurrentEquippedItem().getItem() instanceof ItemPotion || player.getCurrentEquippedItem().getItem() == Items.water_bucket)) {
                player.dropOneItem(true);
                player.attackEntityFrom(DamageSource.drown, 1);
                this.playerCount.add(player.getCommandSenderName(), 10);
                player.addChatComponentMessage(new ChatComponentText("The condensation from the bottle burns your hands, causing you to drop it.").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA)));
            }
        }
        this.playerCount.add(player.getCommandSenderName());
    }
}
项目:Corruption    文件:FMLEventHandler.java   
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent e) {
    if (Corruption.corrSpeed == 20) e.player.addChatComponentMessage(new ChatComponentText("[Corruption] Please note that this server is running at ModJam speed (10x faster then normal!) so you can see the full effects of the mod. You can change this in your config"));

    //Introduction
    if (CorruptionDataHelper.needIntroduction(e.player)) {
        if (this.playerIntroduction.count(e.player.getCommandSenderName()) > 0) {
            e.player.addChatComponentMessage(new ChatComponentTranslation("chat.corruption.logout").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED).setItalic(true)));
            CorruptionDataHelper.increaseCorruptionForPlayer(e.player, 50);
        }
        else {
            this.playerIntroduction.add(e.player.getCommandSenderName());
        }
    }

    Corruption.eventChannel.sendTo(PacketEventHandler.getDiaryDataPacket(e.player), (EntityPlayerMP) e.player);
    List<String> corrEffects = CorruptionDataHelper.getCorruptionEffectsForPlayer(e.player);
    if (!corrEffects.isEmpty()) {
        for (String corr : corrEffects) {
            Corruption.eventChannel.sendTo(PacketEventHandler.getCorruptionEffectPacket(e.player.getCommandSenderName(), corr, true, false), (EntityPlayerMP) e.player);
        }
    }
}
项目:ForgeUpdater    文件:UpdateCheckThreadController.java   
public void onPlayerConnect(ICommandSender sender)
{
    if (checking) {
        this.senders.add(sender);
    } else {
        int updates = UpdateCheckThreadController.instance.getUpdates();
        if (updates > 0) {
            String msg = "There "+(updates == 1 ? "is " : "are ")+EnumChatFormatting.RED+updates+EnumChatFormatting.AQUA+" mod"+(updates == 1 ? "" : "s")+" with"+(updates == 1 ? " a" : "")+" new version"+(updates == 1 ? "" : "s")+".";
            sender.addChatMessage(new ChatComponentText(msg).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA)));

            IChatComponent chatComponentBody = new ChatComponentText("For more information, please type ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA));
            IChatComponent chatComponentLink = new ChatComponentText("/updates").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED).setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/updates")).setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("Run command").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD)))));;
            sender.addChatMessage(chatComponentBody.appendSibling(chatComponentLink));
        }
    }
}
项目:Emotes    文件:EmoteHandler.java   
public static void putEmote(EntityPlayer player, Class<? extends EmoteBase> clazz) {
    ModelBiped model = getPlayerModel();
    ModelBiped armorModel = getPlayerArmorModel();
    ModelBiped armorLegModel = getPlayerArmorLegModel();

    System.out.println(model.bipedHead.rotateAngleY);
    if(model.bipedHead.rotateAngleY < 0)
        model.bipedHead.rotateAngleY = 2 * (float) Math.PI - model.bipedHead.rotateAngleY; 

    try {
        if(playerEmotes.containsKey(player))
            player.addChatComponentMessage(new ChatComponentText("You're already doing an emote.").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
        else playerEmotes.put(player, clazz.getConstructor(EntityPlayer.class, ModelBiped.class, ModelBiped.class, ModelBiped.class).newInstance(player, model, armorModel, armorLegModel));
    } catch(Exception e) {
        e.printStackTrace();
    }
}
项目:A-Cup-of-Java    文件:BeverageACOJ.java   
@Override
public ItemStack onEaten(ItemStack itemStack, World world, EntityPlayer entityPlayer)
{
    if (!entityPlayer.capabilities.isCreativeMode)
    {
        --itemStack.stackSize;
        if (!world.isRemote)
        {
            if (rand.nextInt(10) == 1)
            {
                entityPlayer.setHealth(entityPlayer.getHealth() - 4);
                entityPlayer.addChatMessage(new ChatComponentTranslation("msg." + Reference.MOD_ID.toLowerCase() + ":burn.txt").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED)));
            }
        }
    }

    return itemStack.stackSize <= 0 ? new ItemStack(ModItems.ItemCoffeeMug) : itemStack;
}
项目:Hackery    文件:nsodCommand.java   
@Override
public void processCommand(ICommandSender plr, String[] args) {
    if (!plr.getEntityWorld().isRemote) {
        if(args.length != 2){
            plr.addChatMessage(new ChatComponentText("commands.nsod.usage"));
            return;
        }
        EntityPlayerMP vicitm = getPlayer(plr,args[0]);
        if(vicitm == null){
            plr.addChatMessage(new ChatComponentText("commands.nsod.noexist").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
            return;
        }
        Boolean value = Boolean.parseBoolean(args[1]);
        if(value == null){
            plr.addChatMessage(new ChatComponentText("commands.nsod.usage"));
        }
        HackeryMod.channel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
        HackeryMod.channel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(vicitm);
        HackeryMod.channel.get(Side.SERVER).writeAndFlush(new setBSODPacket(value));
    }
}
项目:MyEssentials-Core    文件:ChatComponentFormatted.java   
private IChatComponent createComponent(String[] parts, Iterator args) {
    ChatStyle chatStyle = getStyle(parts[0]);
    String[] textWithHover = parts[1].split(" << ");
    String actualText = textWithHover[0];

    while (actualText.contains("%s")) {
        actualText = actualText.replaceFirst("%s", Matcher.quoteReplacement(args.next().toString()));
    }
    IChatComponent message = new ChatComponentText(actualText).setChatStyle(chatStyle);

    if (textWithHover.length == 2) {
        IChatComponent hoverText = new ChatComponentFormatted("{" + textWithHover[1] + "}", args);
        chatStyle.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText));
    }

    return message;
}
项目:IceAndShadow2    文件:IaSPlayerHelper.java   
protected static void doMessagePlayer(EntityPlayer plai, String str, final boolean alert) {
    if (IaSPlayerHelper.dochat && plai.worldObj.isRemote) {
        final String localized = LanguageRegistry.instance().getStringLocalization("ias2.message."+str);
        if(!localized.isEmpty()) {
            final ChatComponentText
                txt = new ChatComponentText(localized);
            if(alert)
                txt.setChatStyle(new ChatStyle().setItalic(true).setBold(true).setColor(EnumChatFormatting.RED));
            else
                txt.setChatStyle(new ChatStyle().setItalic(true).setColor(EnumChatFormatting.GRAY));
            if(alert) {
                plai.addChatMessage(new ChatComponentText(""));
                plai.addChatMessage(txt);
                plai.addChatMessage(new ChatComponentText(""));
            } else
                plai.addChatMessage(txt);
            IaSPlayerHelper.dochat = false;
        }
    } else {
        IaSPlayerHelper.dochat = true;
    }
}
项目:nei-lotr    文件:ModVersion.java   
public IChatComponent getFormattedChatText() {
    String text = StatCollector.translateToLocal("neiLotr.versionChecker.notification.chat");
    String[] parts = text.split("7");
    String text1 = parts[0];
    String text2 = parts[1];
    String text3 = parts[2];
    String text4 = parts[3];

    ChatComponentText chat1 = (ChatComponentText) new ChatComponentText("[NEI LOTR]: ")
            .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN));
    ChatComponentText chat2 = (ChatComponentText) new ChatComponentText(text1 + " ")
            .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE));
    ChatComponentText chat3 = (ChatComponentText) new ChatComponentText(text2)
            .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.BLUE).setUnderlined(true)
                    .setChatClickEvent(
                            new ClickEvent(Action.OPEN_URL, "https://goo.gl/EkxFlC"))
                    .setChatHoverEvent(
                            new HoverEvent(net.minecraft.event.HoverEvent.Action.SHOW_TEXT,
                                    new ChatComponentText(StatCollector
                                            .translateToLocal("neiLotr.versionChecker.notification.changelog")
                                            .replace("/", "\n")))));
    ChatComponentText chat4 = (ChatComponentText) new ChatComponentText(" " + text3 + " ")
            .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE));
    ChatComponentText chat5 = (ChatComponentText) new ChatComponentText(state.toString() + " " + version)
            .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW).setUnderlined(true)
                    .setChatClickEvent(
                            new ClickEvent(Action.OPEN_URL, url))
                    .setChatHoverEvent(
                            new HoverEvent(net.minecraft.event.HoverEvent.Action.SHOW_TEXT,
                                    new ChatComponentText(StatCollector
                                            .translateToLocal("neiLotr.versionChecker.notification.newVersion")
                                            .replace("/", "\n")))));
    ChatComponentText chat6 = (ChatComponentText) new ChatComponentText(" " + text4 + " ")
            .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE));
    ChatComponentText chat7 = (ChatComponentText) new ChatComponentText(mcVersion)
            .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE));

    return chat1.appendSibling(chat2).appendSibling(chat3).appendSibling(chat4).appendSibling(chat5)
            .appendSibling(chat6).appendSibling(chat7);
}
项目:Proyecto-DASI    文件:AgentQuitFromTimeUpImplementation.java   
@Override
protected void drawCountDown(int secondsRemaining)
{
       ChatComponentText text = new ChatComponentText("" + secondsRemaining + "...");
       ChatStyle style = new ChatStyle();
       style.setBold(true);
       if (secondsRemaining <= 5)
           style.setColor(EnumChatFormatting.RED);

       text.setChatStyle(style);
       Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(text, 1);
}
项目:Proyecto-DASI    文件:AgentQuitFromTimeUpImplementation.java   
@Override
protected void drawCountDown(int secondsRemaining)
{
       ChatComponentText text = new ChatComponentText("" + secondsRemaining + "...");
       ChatStyle style = new ChatStyle();
       style.setBold(true);
       if (secondsRemaining <= 5)
           style.setColor(EnumChatFormatting.RED);

       text.setChatStyle(style);
       Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(text, 1);
}
项目:SignPicture    文件:Informations.java   
public void runUpdate() {
    final Informations.InfoState state = getState();
    final @Nullable Informations.InfoSource source = getSource();
    if (source!=null) {
        final Info.Version version = source.onlineVersion().version;
        if (version!=null&&!StringUtils.isEmpty(version.remote))
            if (state.isDownloaded()) {
                ChatBuilder.create("signpic.versioning.downloadedAlready").useTranslation().setStyle(new ChatStyle().setColor(EnumChatFormatting.RED)).chatClient();
                Log.notice(I18n.format("signpic.gui.notice.versioning.downloadedAlready"));
                try {
                    Desktop.getDesktop().open(Client.getLocation().modDir.getCanonicalFile());
                } catch (final IOException e) {
                    Log.log.error(e.getMessage(), e);
                }
            } else if (state.downloading) {
                ChatBuilder.create("signpic.versioning.downloadingAlready").useTranslation().setStyle(new ChatStyle().setColor(EnumChatFormatting.RED)).chatClient();
                Log.notice(I18n.format("signpic.gui.notice.versioning.downloadingAlready"));
            } else {
                final ModDownload downloader = new ModDownload();
                downloader.getState().getMeta().put(GuiTask.HighlightPanel, true);
                downloader.getState().getMeta().put(GuiTask.ShowPanel, 3f);
                downloader.setCallback(new ICommunicateCallback() {
                    @Override
                    public void onDone(final ICommunicateResponse res) {
                        final ModDLResult result = downloader.result;
                        if (result!=null)
                            new ChatBuilder().setChat(result.response).chatClient();
                    }
                });
                Communicator.instance.communicate(downloader);
            }
    }
}
项目:RorysMod    文件:PlayerTickEvents.java   
@SubscribeEvent
public void onPlayerJoinWorld(EntityJoinWorldEvent event) {
    if (UsefulFunctions.isPlayer(event.entity) && event.world.isRemote) {
        Version version = RorysMod.instance.versionCheker;
        if (!version.haveWarnedVersionOutOfDate && !version.isLatestVersion()) {
            ChatComponentText localChatComponentText = new ChatComponentText("");
            ChatStyle localChatStyle;
            IChatComponent modVersion = new ChatComponentText(EnumChatFormatting.AQUA + StatCollector.translateToLocal("message.rorysmod.version.current") + ": " + RorysGlobal.VERSION);

            IChatComponent modName = new ChatComponentText(EnumChatFormatting.GOLD + "[" + RorysGlobal.NAME + "]" + EnumChatFormatting.WHITE);
            localChatStyle = modName.getChatStyle();
            localChatStyle.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, modVersion));
            localChatStyle.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://rorysmod.rtfd.io"));
            localChatComponentText.appendSibling(modName);

            IChatComponent newVersion = new ChatComponentText(" " + StatCollector.translateToLocal("message.rorysmod.version.new"));
            newVersion.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.WHITE + version.getLatest().getName())));
            localChatComponentText.appendSibling(newVersion);
            UsefulFunctions.getPlayerFromEntity(event.entity).addChatMessage(localChatComponentText);
            localChatComponentText = new ChatComponentText("");

            IChatComponent download = new ChatComponentText(EnumChatFormatting.GREEN + StatCollector.translateToLocal("message.rorysmod.download"));
            download.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, version.getLatest().getHtmlUrl())).setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("message.rorysmod.version.download"))));

            IChatComponent update = new ChatComponentText("[");
            update.appendSibling(download);
            update.appendText(EnumChatFormatting.WHITE + "] " + EnumChatFormatting.GRAY + version.getLatest().getName());
            update.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, version.getLatest().getHtmlUrl()));
            localChatComponentText.appendSibling(update);
            UsefulFunctions.getPlayerFromEntity(event.entity).addChatMessage(localChatComponentText);
            version.haveWarnedVersionOutOfDate = true;
        }
    }
}
项目:EEWReciever    文件:CommandAuth.java   
@Override
public void processSubCommand(final ICommandSender sender, final String[] args) {
    if (CommandAuth.this.auther==null) {
        CommandAuth.this.auther = TweetQuakeManager.intance().getAuther();
        ChatBuilder.create("Twitter認証を開始します。").sendPlayer(sender);
        final ChatStyle style1 = new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://twitter.com/eewbot"));
        ChatBuilder.create("初めに、クリックして開くアカウントを、認証に利用するアカウントでフォローして下さい。(フォローしていないと動作しません)").setStyle(style1).sendPlayer(sender);
        final ChatStyle style2 = new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/eewreciever auth url"));
        ChatBuilder.create("完了したら、クリックして認証に進みます。").setStyle(style2).sendPlayer(sender);
    } else if (CommandAuth.this.auther.getState()!=AuthState.CONNECT)
        ChatBuilder.create("認証はすでに開始しています!").sendPlayer(sender);
    else
        ChatBuilder.create("認証は済んでいます!").sendPlayer(sender);
}
项目:EEWReciever    文件:AuthNoticeHandler.java   
@SubscribeEvent
public void onPlayerLogin(final PlayerEvent.PlayerLoggedInEvent event) {
    if (TweetQuake.instance().isAuthRequired()&&isOp(event.player.getGameProfile())) {
        final ChatStyle style = new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/eewreciever auth start"));
        ChatBuilder.create("[EEWReciever2] Twitter認証が完了していません。クリックして開始する(Twitterアカウントが必要です").setStyle(style).sendPlayer(event.player);
    }
}
项目:Coreder    文件:ChatCommandBase.java   
/**
 * Formats a chat message to inform the player that an exception was caught while processing a
 * chat command
 *
 * @param e
 *        The {@link Exception} that was caught
 * @return A formatted message to be sent to the player
 */
public static final IChatComponent formatExceptionForChat(Exception e) {
    // I _could_ have chained all of this into one line.
    // But then I'd never be willing to debug it.
    // And it /needed/ debugging.
    ChatComponentTranslation msg = new ChatComponentTranslation("coreder.chat.exception");
    ChatStyle style = new ChatStyle();
    HoverEvent onHover = new HoverEvent(Action.SHOW_TEXT, new ChatComponentText(e.toString()));
    style.setItalic(true).setColor(EnumChatFormatting.RED).setUnderlined(true);
    style.setChatHoverEvent(onHover);
    msg.setChatStyle(style);
    return msg;
}
项目:Coreder    文件:CmdGetCheats.java   
@Override
public void processCommand(ICommandSender source, String[] args) {
    if (source.getEntityWorld().isRemote) {
        return;
    }
    boolean cheats = source.getEntityWorld().getWorldInfo().areCommandsAllowed();
    IChatComponent msg = new ChatComponentText("Cheats are currently " + (cheats ? "en" : "dis") + "abled");
    msg.setChatStyle(new ChatStyle().setItalic(true).setColor(EnumChatFormatting.AQUA));
    source.addChatMessage(msg);
}
项目:TeleComponents    文件:ItemTelePos.java   
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int face, float flt1, float flt2, float flt3)
{
    NBTHelper.setInteger(itemStack, "xCoord", x);
    NBTHelper.setInteger(itemStack, "yCoord", y + 1);
    NBTHelper.setInteger(itemStack, "zCoord", z);
    NBTHelper.setInteger(itemStack, "dimNum", world.provider.dimensionId);

    player.addChatComponentMessage(new ChatComponentText("Coordinates set to: X: " + x + ", Y: " + (y + 1) + ", Z: " + z).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE)));
    this.onItemRightClick(itemStack, world, player);
    return true;
}
项目:TeleComponents    文件:ItemPortTeleport.java   
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (!world.isRemote) {
        if (stack.getItemDamage() == 0) {
            int xCoord = NBTHelper.getInt(stack, "xCoord");
            int yCoord = NBTHelper.getInt(stack, "yCoord");
            int zCoord = NBTHelper.getInt(stack, "zCoord");
            int dimNum = NBTHelper.getInt(stack, "dimNum");
            World worldTo = DimensionManager.getWorld(dimNum);
            Block block1 = worldTo.getBlock(xCoord, yCoord, zCoord);
            Block block2 = worldTo.getBlock(xCoord, yCoord + 1, zCoord);
            stack.damageItem(499, player);

            if (yCoord > 0) {
                if (!block1.isOpaqueCube() && !block2.isOpaqueCube()) {
                    if ((!(block1 instanceof BlockStaticLiquid) && !(block2 instanceof BlockStaticLiquid))) {
                        if (worldTo.equals(world)) {
                            player.worldObj = worldTo;
                            player.setPositionAndUpdate(xCoord + .5, yCoord, zCoord + .5);
                        } else {
                            if (player.timeUntilPortal > 0)
                                player.addChatComponentMessage(new ChatComponentText("Teleport failed: Please wait " + TimeHelper.ticksToSeconds(player.timeUntilPortal) + " second(s) to teleport").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
                            else
                                TeleportHelper.teleportPlayerToDim(world, dimNum, xCoord + .5, yCoord, zCoord + .5, player);
                        }
                        return stack;
                    }
                }

                player.addChatComponentMessage(new ChatComponentText("Teleport failed").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
            }
        } else {
            player.addChatComponentMessage(new ChatComponentText("Teleport failed: Cooldown in progress, please wait " + TimeHelper.ticksToSeconds(stack.getItemDamage()) + " second(s)"));
        }
    }
    return stack;
}
项目:MagicBees    文件:TickHandlerVersion.java   
private void sendNotificationToPlayer(EntityPlayer player) {
    if (versionInfo.isCriticalUpdate()) {
        player.addChatMessage(new ChatComponentTranslation("magicbees.versioning.critical", versionInfo.getLatestVersion()).setChatStyle(alert));
    }
    else {
        player.addChatMessage(new ChatComponentTranslation("magicbees.versioning.newVersion", versionInfo.getLatestVersion()).setChatStyle(newVersion));
    }
    ChatStyle thisDescription = description.createShallowCopy();
    thisDescription.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, VersionInfo.DownloadURL));
    thisDescription.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(versionInfo.getVersionDescription())));
    player.addChatMessage(new ChatComponentTranslation("magicbees.versioning.clickDownload").setChatStyle(thisDescription));
}
项目:D3Log    文件:D3LogCommand.java   
@Override
public void processCommand(ICommandSender sender, String[] args)
{
    if (args.length == 0 || args[0].equalsIgnoreCase(SUBCOMMANDS[0]))
    {
        sender.addChatMessage(new ChatComponentText("--== 3DLog Help ==--").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA)));
        sender.addChatMessage(new ChatComponentText("Possible sub commands:"));
        sender.addChatMessage(new ChatComponentText("help -> Display this text"));
        sender.addChatMessage(new ChatComponentText("wand [target] -> Gives wand item to target or you."));
        sender.addChatMessage(new ChatComponentText("lookup <target> -> Look at the event history of target"));
        sender.addChatMessage(new ChatComponentText("rollback <target> -> Roll back all logged world changes by target."));
        sender.addChatMessage(new ChatComponentText("purge <time|all> -> Remove records older than time (or all) from the database."));
    }
    else if (args[0].equalsIgnoreCase(SUBCOMMANDS[1]))
    {
        EntityPlayerMP target;
        if (args.length == 2) target = getPlayer(sender, args[1]);
        else target = getCommandSenderAsPlayer(sender);

        target.inventory.addItemStackToInventory(Constants.WAND.copy());
    }
    else if (args[0].equalsIgnoreCase(SUBCOMMANDS[2]))
    {
        lookupTask(sender, args, false);
    }
    else if (args[0].equalsIgnoreCase(SUBCOMMANDS[3]))
    {
        lookupTask(sender, args, true);
    }
}
项目:TeleComponents    文件:ItemTelePos.java   
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int face, float flt1, float flt2, float flt3)
{
    NBTHelper.setInteger(itemStack, "xCoord", x);
    NBTHelper.setInteger(itemStack, "yCoord", y + 1);
    NBTHelper.setInteger(itemStack, "zCoord", z);
    NBTHelper.setInteger(itemStack, "dimNum", world.provider.dimensionId);

    player.addChatComponentMessage(new ChatComponentText("Coordinates set to: X: " + x + ", Y: " + (y + 1) + ", Z: " + z).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE)));
    this.onItemRightClick(itemStack, world, player);
    return true;
}
项目:TeleComponents    文件:ItemPortTeleport.java   
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (!world.isRemote) {
        if (stack.getItemDamage() == 0) {
            int xCoord = NBTHelper.getInt(stack, "xCoord");
            int yCoord = NBTHelper.getInt(stack, "yCoord");
            int zCoord = NBTHelper.getInt(stack, "zCoord");
            int dimNum = NBTHelper.getInt(stack, "dimNum");
            World worldTo = DimensionManager.getWorld(dimNum);
            Block block1 = worldTo.getBlock(xCoord, yCoord, zCoord);
            Block block2 = worldTo.getBlock(xCoord, yCoord + 1, zCoord);
            stack.damageItem(499, player);

            if (yCoord > 0) {
                if (!block1.isOpaqueCube() && !block2.isOpaqueCube()) {
                    if ((!(block1 instanceof BlockStaticLiquid) && !(block2 instanceof BlockStaticLiquid))) {
                        if (worldTo.equals(world)) {
                            player.worldObj = worldTo;
                            player.setPositionAndUpdate(xCoord + .5, yCoord, zCoord + .5);
                        } else {
                            if (player.timeUntilPortal > 0)
                                player.addChatComponentMessage(new ChatComponentText("Teleport failed: Please wait " + TimeHelper.ticksToSeconds(player.timeUntilPortal) + " second(s) to teleport").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
                            else
                                TeleportHelper.teleportPlayerToDim(world, dimNum, xCoord + .5, yCoord, zCoord + .5, player);
                        }
                        return stack;
                    }
                }

                player.addChatComponentMessage(new ChatComponentText("Teleport failed").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
            }
        } else {
            player.addChatComponentMessage(new ChatComponentText("Teleport failed: Cooldown in progress, please wait " + TimeHelper.ticksToSeconds(stack.getItemDamage()) + " second(s)"));
        }
    }
    return stack;
}