Java 类net.minecraft.server.ChatClickable 实例源码

项目:CraftBukkit    文件:CraftChatMessage.java   
private StringMessage(String message) {
    this.message = message;
    if (message == null) {
        output = new IChatBaseComponent[] { currentChatComponent };
        return;
    }
    list.add(currentChatComponent);

    Matcher matcher = INCREMENTAL_PATTERN.matcher(message);
    String match = null;
    while (matcher.find()) {
        int groupId = 0;
        while ((match = matcher.group(++groupId)) == null) {
            // NOOP
        }
        appendNewComponent(matcher.start(groupId));
        switch (groupId) {
        case 1:
            EnumChatFormat format = formatMap.get(match.toLowerCase().charAt(1));
            if (format == EnumChatFormat.RESET) {
                modifier = new ChatModifier();
            } else if (format.isFormat()) {
                switch (format) {
                case BOLD:
                    modifier.setBold(Boolean.TRUE);
                    break;
                case ITALIC:
                    modifier.setItalic(Boolean.TRUE);
                    break;
                case STRIKETHROUGH:
                    modifier.setStrikethrough(Boolean.TRUE);
                    break;
                case UNDERLINE:
                    modifier.setUnderline(Boolean.TRUE);
                    break;
                case RANDOM:
                    modifier.setRandom(Boolean.TRUE);
                    break;
                default:
                    throw new AssertionError("Unexpected message format");
                }
            } else { // Color resets formatting
                modifier = new ChatModifier().setColor(format);
            }
            break;
        case 2:
            currentChatComponent = null;
            break;
        case 3:
            modifier.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match));
            appendNewComponent(matcher.end(groupId));
            modifier.setChatClickable((ChatClickable) null);
        }
        currentIndex = matcher.end(groupId);
    }

    if (currentIndex < message.length()) {
        appendNewComponent(message.length());
    }

    output = list.toArray(new IChatBaseComponent[0]);
}
项目:Craftbukkit    文件:CraftChatMessage.java   
private StringMessage(String message,  boolean keepNewlines) {
    this.message = message;
    if (message == null) {
        output = new IChatBaseComponent[] { currentChatComponent };
        return;
    }
    list.add(currentChatComponent);

    Matcher matcher = INCREMENTAL_PATTERN.matcher(message);
    String match = null;
    while (matcher.find()) {
        int groupId = 0;
        while ((match = matcher.group(++groupId)) == null) {
            // NOOP
        }
        appendNewComponent(matcher.start(groupId));
        switch (groupId) {
        case 1:
            EnumChatFormat format = formatMap.get(match.toLowerCase().charAt(1));
            if (format == EnumChatFormat.RESET) {
                modifier = new ChatModifier();
            } else if (format.isFormat()) {
                switch (format) {
                case BOLD:
                    modifier.setBold(Boolean.TRUE);
                    break;
                case ITALIC:
                    modifier.setItalic(Boolean.TRUE);
                    break;
                case STRIKETHROUGH:
                    modifier.setStrikethrough(Boolean.TRUE);
                    break;
                case UNDERLINE:
                    modifier.setUnderline(Boolean.TRUE);
                    break;
                case OBFUSCATED:
                    modifier.setRandom(Boolean.TRUE);
                    break;
                default:
                    throw new AssertionError("Unexpected message format");
                }
            } else { // Color resets formatting
                modifier = new ChatModifier().setColor(format);
            }
            break;
        case 2:
            if (keepNewlines) {
                currentChatComponent.addSibling(new ChatComponentText("\n"));
            } else {
                currentChatComponent = null;
            }
            break;
        case 3:
            if ( !( match.startsWith( "http://" ) || match.startsWith( "https://" ) ) ) {
                match = "http://" + match;
            }
            modifier.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match));
            appendNewComponent(matcher.end(groupId));
            modifier.setChatClickable((ChatClickable) null);
        }
        currentIndex = matcher.end(groupId);
    }

    if (currentIndex < message.length()) {
        appendNewComponent(message.length());
    }

    output = list.toArray(new IChatBaseComponent[list.size()]);
}
项目:Tweakkit-Server    文件:CraftChatMessage.java   
private StringMessage(String message) {
    this.message = message;
    if (message == null) {
        output = new IChatBaseComponent[] { currentChatComponent };
        return;
    }
    list.add(currentChatComponent);

    Matcher matcher = INCREMENTAL_PATTERN.matcher(message);
    String match = null;
    while (matcher.find()) {
        int groupId = 0;
        while ((match = matcher.group(++groupId)) == null) {
            // NOOP
        }
        appendNewComponent(matcher.start(groupId));
        switch (groupId) {
        case 1:
            EnumChatFormat format = formatMap.get(match.toLowerCase().charAt(1));
            if (format == EnumChatFormat.RESET) {
                modifier = new ChatModifier();
            } else if (format.isFormat()) {
                switch (format) {
                case BOLD:
                    modifier.setBold(Boolean.TRUE);
                    break;
                case ITALIC:
                    modifier.setItalic(Boolean.TRUE);
                    break;
                case STRIKETHROUGH:
                    modifier.setStrikethrough(Boolean.TRUE);
                    break;
                case UNDERLINE:
                    modifier.setUnderline(Boolean.TRUE);
                    break;
                case RANDOM:
                    modifier.setRandom(Boolean.TRUE);
                    break;
                default:
                    throw new AssertionError("Unexpected message format");
                }
            } else { // Color resets formatting
                modifier = new ChatModifier().setColor(format);
            }
            break;
        case 2:
            currentChatComponent = null;
            break;
        case 3:
            if ( !( match.startsWith( "http://" ) || match.startsWith( "https://" ) ) ) {
                match = "http://" + match;
            }
            modifier.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match));
            appendNewComponent(matcher.end(groupId));
            modifier.setChatClickable((ChatClickable) null);
        }
        currentIndex = matcher.end(groupId);
    }

    if (currentIndex < message.length()) {
        appendNewComponent(message.length());
    }

    output = list.toArray(new IChatBaseComponent[list.size()]);
}
项目:SpigotSource    文件:CraftChatMessage.java   
private StringMessage(String message,  boolean keepNewlines) {
    this.message = message;
    if (message == null) {
        output = new IChatBaseComponent[] { currentChatComponent };
        return;
    }
    list.add(currentChatComponent);

    Matcher matcher = INCREMENTAL_PATTERN.matcher(message);
    String match = null;
    while (matcher.find()) {
        int groupId = 0;
        while ((match = matcher.group(++groupId)) == null) {
            // NOOP
        }
        appendNewComponent(matcher.start(groupId));
        switch (groupId) {
        case 1:
            EnumChatFormat format = formatMap.get(match.toLowerCase().charAt(1));
            if (format == EnumChatFormat.RESET) {
                modifier = new ChatModifier();
            } else if (format.isFormat()) {
                switch (format) {
                case BOLD:
                    modifier.setBold(Boolean.TRUE);
                    break;
                case ITALIC:
                    modifier.setItalic(Boolean.TRUE);
                    break;
                case STRIKETHROUGH:
                    modifier.setStrikethrough(Boolean.TRUE);
                    break;
                case UNDERLINE:
                    modifier.setUnderline(Boolean.TRUE);
                    break;
                case OBFUSCATED:
                    modifier.setRandom(Boolean.TRUE);
                    break;
                default:
                    throw new AssertionError("Unexpected message format");
                }
            } else { // Color resets formatting
                modifier = new ChatModifier().setColor(format);
            }
            break;
        case 2:
            if (keepNewlines) {
                currentChatComponent.addSibling(new ChatComponentText("\n"));
            } else {
                currentChatComponent = null;
            }
            break;
        case 3:
            if ( !( match.startsWith( "http://" ) || match.startsWith( "https://" ) ) ) {
                match = "http://" + match;
            }
            modifier.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match));
            appendNewComponent(matcher.end(groupId));
            modifier.setChatClickable((ChatClickable) null);
        }
        currentIndex = matcher.end(groupId);
    }

    if (currentIndex < message.length()) {
        appendNewComponent(message.length());
    }

    output = list.toArray(new IChatBaseComponent[list.size()]);
}