Search in sources :

Example 36 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class CommandDumpPermissions method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    sender.addChatMessage(new ChatComponentText("Dumping permission nodes to file in the server's base directory"));
    PermissionsRegistry.dumpNodesToFile();
    return true;
}
Also used : ChatComponentText(net.minecraft.util.ChatComponentText)

Example 37 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class CommandGroups method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    if (args[0].equalsIgnoreCase("list")) {
        sender.addChatMessage(new ChatComponentText("==== Groups ===="));
        for (AccessGroup group : GroupProfileHandler.GLOBAL.getAccessProfile().getGroups()) {
            sender.addChatMessage(new ChatComponentText("  Group[" + group.getName() + (group.getExtendGroupName() != null ? " extends " + group.getExtendGroupName() : "") + "]  Members: " + group.getMembers().size()));
        }
        sender.addChatMessage(new ChatComponentText("================"));
    }
    return true;
}
Also used : AccessGroup(com.builtbroken.mc.lib.access.AccessGroup) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 38 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class CommandNewRegion method handleEntityPlayerCommand.

@Override
public boolean handleEntityPlayerCommand(EntityPlayer player, String[] args) {
    if (args.length > 0) {
        String name = args[0];
        if (RegionManager.getControllerForWorld(player.worldObj).getRegion(name) == null) {
            Cube cube = SelectionHandler.getSelection(player);
            if (cube != null && cube.isValid()) {
                Region region = RegionManager.getControllerForWorld(player.worldObj).createNewRegion(name, cube);
                if (region != null) {
                    region.getAccessProfile().getGroup("owner").addMember(player);
                    player.addChatMessage(new ChatComponentText("Region created"));
                } else {
                    player.addChatMessage(new ChatComponentText("Error creating region"));
                }
            } else {
                player.addChatMessage(new ChatComponentText("Invalid selection to create region"));
            }
        } else {
            player.addChatMessage(new ChatComponentText("A region by that name already exists"));
        }
    } else {
        player.addChatMessage(new ChatComponentText("Need a region name"));
    }
    return true;
}
Also used : Cube(com.builtbroken.mc.lib.transform.region.Cube) Region(com.builtbroken.mc.lib.modflags.Region) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 39 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project watson by totemo.

the class Text method toChatComponent.

// --------------------------------------------------------------------------
/**
 * Return the IChatComponent representation of the Text.
 *
 * @return the IChatComponent representation of the Text.
 */
public IChatComponent toChatComponent() {
    ArrayList<IChatComponent> result = new ArrayList<IChatComponent>();
    StringBuilder text = new StringBuilder();
    // Sentinel:
    char colourStyle = Colour.white.getCode();
    ChatStyle style = new ChatStyle();
    for (int i = 0; i < _unformatted.length(); ++i) {
        // Detect a change in colour or style and add new component to result.
        if (_colourStyles.charAt(i) != colourStyle) {
            // Set the new colour. This also clears the current style.
            char newColourStyle = _colourStyles.charAt(i);
            char colour = (char) (newColourStyle & Format.COLOUR_MASK);
            // Put all of the characters accumulated so far in ChatComponentText.
            IChatComponent sibling = new ChatComponentText(text.toString());
            sibling.setChatStyle(style);
            result.add(sibling);
            // Reuse StringBuilder to accumulate characters for the next sibling.
            text.setLength(0);
            // Configure the style of the next sibling to be appended to result.
            style = new ChatStyle();
            EnumChatFormatting chatFormatting = _TO_ENUM_CHAT_FORMATTING.get(colour);
            style.setColor(chatFormatting);
            if ((newColourStyle & Format.BOLD) != 0) {
                style.setBold(true);
            }
            if ((newColourStyle & Format.ITALIC) != 0) {
                style.setItalic(true);
            }
            if ((newColourStyle & Format.UNDERLINE) != 0) {
                style.setUnderlined(true);
            }
            if ((newColourStyle & Format.STRIKE) != 0) {
                style.setStrikethrough(true);
            }
            if ((newColourStyle & Format.RANDOM) != 0) {
                style.setObfuscated(true);
            }
            colourStyle = newColourStyle;
        }
        // colour or style changed
        text.append(_unformatted.charAt(i));
    }
    // for
    IChatComponent sibling = new ChatComponentText(text.toString());
    sibling.setChatStyle(style);
    result.add(sibling);
    return ChatComponents.toChatComponent(result);
}
Also used : ChatStyle(net.minecraft.util.ChatStyle) EnumChatFormatting(net.minecraft.util.EnumChatFormatting) IChatComponent(net.minecraft.util.IChatComponent) ArrayList(java.util.ArrayList) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 40 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project watson by totemo.

the class ChatComponents method getComponents.

// --------------------------------------------------------------------------
/**
 * Return an array containing the specified IChatComponent and all its
 * siblings.
 *
 * @return an array containing the specified IChatComponent and all its
 *         siblings.
 */
@SuppressWarnings("unchecked")
public static ArrayList<IChatComponent> getComponents(IChatComponent chat) {
    ArrayList<IChatComponent> components = new ArrayList<IChatComponent>();
    for (Object o : chat) {
        IChatComponent component = (IChatComponent) o;
        IChatComponent copy = new ChatComponentText(component.getUnformattedTextForChat());
        copy.setChatStyle(component.getChatStyle().createDeepCopy());
        components.add(copy);
    }
    return components;
}
Also used : IChatComponent(net.minecraft.util.IChatComponent) ArrayList(java.util.ArrayList) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

ChatComponentText (net.minecraft.util.ChatComponentText)383 IChatComponent (net.minecraft.util.IChatComponent)55 EntityPlayer (net.minecraft.entity.player.EntityPlayer)43 ChatStyle (net.minecraft.util.ChatStyle)39 ItemStack (net.minecraft.item.ItemStack)36 ClickEvent (net.minecraft.event.ClickEvent)31 World (net.minecraft.world.World)28 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)26 TileEntity (net.minecraft.tileentity.TileEntity)25 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)25 HoverEvent (net.minecraft.event.HoverEvent)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 ArrayList (java.util.ArrayList)17 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)16 Block (net.minecraft.block.Block)15 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)15 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)14 Entity (net.minecraft.entity.Entity)14 DimensionInformation (mcjty.rftools.dimension.DimensionInformation)13 File (java.io.File)12