Search in sources :

Example 6 with ChatMessage

use of net.minecraft.server.v1_16_R3.ChatMessage in project PublicCrafters by BananaPuncher714.

the class ContainerManager_v1_16_R1 method openWorkbench.

@Override
public void openWorkbench(Player player, Location loc, InventoryType type) {
    TileInventory tileEntity = new TileInventory(new CustomTileEntityContainerWorkbench(this, loc), new ChatMessage("container.crafting", new Object[0]));
    ((CraftPlayer) player).getHandle().openContainer(tileEntity);
}
Also used : ChatMessage(net.minecraft.server.v1_16_R1.ChatMessage) TileInventory(net.minecraft.server.v1_16_R1.TileInventory)

Example 7 with ChatMessage

use of net.minecraft.server.v1_16_R3.ChatMessage in project PublicCrafters by BananaPuncher714.

the class ContainerManager_v1_16_R2 method openWorkbench.

@Override
public void openWorkbench(Player player, Location loc, InventoryType type) {
    TileInventory tileEntity = new TileInventory(new CustomTileEntityContainerWorkbench(this, loc), new ChatMessage("container.crafting", new Object[0]));
    ((CraftPlayer) player).getHandle().openContainer(tileEntity);
}
Also used : ChatMessage(net.minecraft.server.v1_16_R2.ChatMessage) TileInventory(net.minecraft.server.v1_16_R2.TileInventory)

Example 8 with ChatMessage

use of net.minecraft.server.v1_16_R3.ChatMessage in project PaperDev by Kamillaova.

the class CraftChatMessage method fixComponent.

private static IChatBaseComponent fixComponent(IChatBaseComponent component, Matcher matcher) {
    if (component instanceof ChatComponentText) {
        ChatComponentText text = ((ChatComponentText) component);
        String msg = text.g();
        if (matcher.reset(msg).find()) {
            matcher.reset();
            ChatModifier modifier = text.getChatModifier() != null ? text.getChatModifier() : new ChatModifier();
            List<IChatBaseComponent> extras = new ArrayList<IChatBaseComponent>();
            List<IChatBaseComponent> extrasOld = new ArrayList<IChatBaseComponent>(text.a());
            component = text = new ChatComponentText("");
            int pos = 0;
            while (matcher.find()) {
                String match = matcher.group();
                if (!(match.startsWith("http://") || match.startsWith("https://"))) {
                    match = "http://" + match;
                }
                ChatComponentText prev = new ChatComponentText(msg.substring(pos, matcher.start()));
                prev.setChatModifier(modifier);
                extras.add(prev);
                ChatComponentText link = new ChatComponentText(matcher.group());
                ChatModifier linkModi = modifier.clone();
                linkModi.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match));
                link.setChatModifier(linkModi);
                extras.add(link);
                pos = matcher.end();
            }
            ChatComponentText prev = new ChatComponentText(msg.substring(pos));
            prev.setChatModifier(modifier);
            extras.add(prev);
            extras.addAll(extrasOld);
            for (IChatBaseComponent c : extras) {
                text.addSibling(c);
            }
        }
    }
    List extras = component.a();
    for (int i = 0; i < extras.size(); i++) {
        IChatBaseComponent comp = (IChatBaseComponent) extras.get(i);
        if (comp.getChatModifier() != null && comp.getChatModifier().h() == null) {
            extras.set(i, fixComponent(comp, matcher));
        }
    }
    if (component instanceof ChatMessage) {
        Object[] subs = ((ChatMessage) component).j();
        for (int i = 0; i < subs.length; i++) {
            Object comp = subs[i];
            if (comp instanceof IChatBaseComponent) {
                IChatBaseComponent c = (IChatBaseComponent) comp;
                if (c.getChatModifier() != null && c.getChatModifier().h() == null) {
                    subs[i] = fixComponent(c, matcher);
                }
            } else if (comp instanceof String && matcher.reset((String) comp).find()) {
                subs[i] = fixComponent(new ChatComponentText((String) comp), matcher);
            }
        }
    }
    return component;
}
Also used : ChatMessage(net.minecraft.server.v1_12_R1.ChatMessage) ChatClickable(net.minecraft.server.v1_12_R1.ChatClickable) ChatModifier(net.minecraft.server.v1_12_R1.ChatModifier) ArrayList(java.util.ArrayList) IChatBaseComponent(net.minecraft.server.v1_12_R1.IChatBaseComponent) ArrayList(java.util.ArrayList) List(java.util.List) ChatComponentText(net.minecraft.server.v1_12_R1.ChatComponentText)

Aggregations

Field (java.lang.reflect.Field)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ChatMessage (net.minecraft.server.v1_10_R1.ChatMessage)1 IChatBaseComponent (net.minecraft.server.v1_10_R1.IChatBaseComponent)1 PacketPlayOutPlayerListHeaderFooter (net.minecraft.server.v1_10_R1.PacketPlayOutPlayerListHeaderFooter)1 ChatMessage (net.minecraft.server.v1_11_R1.ChatMessage)1 IChatBaseComponent (net.minecraft.server.v1_11_R1.IChatBaseComponent)1 PacketPlayOutPlayerListHeaderFooter (net.minecraft.server.v1_11_R1.PacketPlayOutPlayerListHeaderFooter)1 ChatClickable (net.minecraft.server.v1_12_R1.ChatClickable)1 ChatComponentText (net.minecraft.server.v1_12_R1.ChatComponentText)1 ChatMessage (net.minecraft.server.v1_12_R1.ChatMessage)1 ChatModifier (net.minecraft.server.v1_12_R1.ChatModifier)1 IChatBaseComponent (net.minecraft.server.v1_12_R1.IChatBaseComponent)1 ChatMessage (net.minecraft.server.v1_14_R1.ChatMessage)1 TileInventory (net.minecraft.server.v1_14_R1.TileInventory)1 ChatMessage (net.minecraft.server.v1_15_R1.ChatMessage)1 TileInventory (net.minecraft.server.v1_15_R1.TileInventory)1 ChatMessage (net.minecraft.server.v1_16_R1.ChatMessage)1 TileInventory (net.minecraft.server.v1_16_R1.TileInventory)1