Search in sources :

Example 6 with ChatStyle

use of net.minecraft.util.ChatStyle in project ForestryMC by ForestryMC.

the class CommandVersion method processSubCommand.

@Override
public void processSubCommand(ICommandSender sender, String[] args) {
    ChatStyle style = new ChatStyle();
    if (Version.isOutdated()) {
        style.setColor(EnumChatFormatting.RED);
    } else {
        style.setColor(EnumChatFormatting.GREEN);
    }
    CommandHelpers.sendLocalizedChatMessage(sender, style, "for.chat.version", Version.getVersion(), Proxies.common.getMinecraftVersion(), Version.getRecommendedVersion());
    if (Version.isOutdated()) {
        for (String updateLine : Version.getChangelog()) {
            CommandHelpers.sendChatMessage(sender, EnumChatFormatting.BLUE + updateLine);
        }
    }
}
Also used : ChatStyle(net.minecraft.util.ChatStyle)

Example 7 with ChatStyle

use of net.minecraft.util.ChatStyle in project BloodMagic by WayofTime.

the class CommandBloodMagic method processCommand.

@Override
public void processCommand(ICommandSender commandSender, String[] args) {
    if (args.length > 0 && subCommands.containsKey(args[0])) {
        ISubCommand subCommand = subCommands.get(args[0]);
        String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
        if (subCommand.canSenderUseSubCommand(commandSender))
            subCommand.processSubCommand(commandSender, subArgs);
        else
            commandSender.addChatMessage(new ChatComponentTranslation("commands.error.perm").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
    } else {
        commandSender.addChatMessage(new ChatComponentTranslation("commands.error.unknown").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
    }
}
Also used : ChatStyle(net.minecraft.util.ChatStyle) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ISubCommand(WayofTime.alchemicalWizardry.api.command.ISubCommand)

Example 8 with ChatStyle

use of net.minecraft.util.ChatStyle in project ct.js by ChatTriggers.

the class Message method parseMessages.

// helper method to parse chat component parts
private void parseMessages() {
    this.chatMessage = new ChatComponentText("");
    for (Object message : this.messageParts) {
        if (message instanceof String) {
            String toAdd = ((String) message);
            ChatComponentText cct = new ChatComponentText(this.formatted ? ChatLib.addColor(toAdd) : toAdd);
            cct.setChatStyle(new ChatStyle().setParentStyle(null));
            this.chatMessage.appendSibling(cct);
        } else if (message instanceof TextComponent) {
            this.chatMessage.appendSibling(((TextComponent) message).getChatComponentText());
        }
    }
}
Also used : ChatStyle(net.minecraft.util.ChatStyle) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 9 with ChatStyle

use of net.minecraft.util.ChatStyle in project watson by totemo.

the class WatsonCommandBase method sendColouredText.

// --------------------------------------------------------------------------
/**
 * Send a message to the specified command sender in the specified colour.
 *
 * @param sender the command sender who is the message recipient.
 * @param colour the colour.
 * @param message the text.
 */
public void sendColouredText(ICommandSender sender, EnumChatFormatting colour, String message) {
    ChatComponentText chat = new ChatComponentText(message);
    ChatStyle style = new ChatStyle();
    style.setColor(colour);
    chat.setChatStyle(style);
    sender.addChatMessage(chat);
}
Also used : ChatStyle(net.minecraft.util.ChatStyle) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 10 with ChatStyle

use of net.minecraft.util.ChatStyle in project watson by totemo.

the class Chat method localChat.

// --------------------------------------------------------------------------
/**
 * Display a chat message locally.
 *
 * @param colour the colour to format the text as.
 * @param message the text to display.
 */
public static void localChat(EnumChatFormatting colour, String message) {
    ChatComponentText chat = new ChatComponentText(message);
    ChatStyle style = new ChatStyle();
    style.setColor(colour);
    chat.setChatStyle(style);
    localChat(chat);
}
Also used : ChatStyle(net.minecraft.util.ChatStyle) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

ChatStyle (net.minecraft.util.ChatStyle)13 ChatComponentText (net.minecraft.util.ChatComponentText)8 IChatComponent (net.minecraft.util.IChatComponent)5 ClickEvent (net.minecraft.event.ClickEvent)4 InvokeEvent (cc.hyperium.event.InvokeEvent)2 HoverEvent (net.minecraft.event.HoverEvent)2 ISubCommand (WayofTime.alchemicalWizardry.api.command.ISubCommand)1 LevelheadDisplay (cc.hyperium.mods.levelhead.display.LevelheadDisplay)1 ToggleBase (cc.hyperium.mods.togglechat.toggles.ToggleBase)1 TypeMessageSeparator (cc.hyperium.mods.togglechat.toggles.defaults.TypeMessageSeparator)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)1 EnumChatFormatting (net.minecraft.util.EnumChatFormatting)1