当前位置: 首页>>代码示例>>Java>>正文


Java TextColor类代码示例

本文整理汇总了Java中org.spongepowered.api.text.format.TextColor的典型用法代码示例。如果您正苦于以下问题:Java TextColor类的具体用法?Java TextColor怎么用?Java TextColor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TextColor类属于org.spongepowered.api.text.format包,在下文中一共展示了TextColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTagColored

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
@Override
public Text getTagColored() {
    TextColor colonColor = TextColors.GRAY;
    if (Config.getBoolean(Config.USE_COLORED_TAGS_BASED_ON_CLAN_KDR)) {
        ClanImpl firstClan = ClansImpl.getInstance().getFirstClan();
        ClanImpl secondClan = ClansImpl.getInstance().getSecondClan();
        ClanImpl thirdClan = ClansImpl.getInstance().getThirdClan();
        if (firstClan != null && firstClan.getTag().equalsIgnoreCase(getTag())) {
            colonColor = TextColors.DARK_RED;
        } else if (secondClan != null && secondClan.getTag().equalsIgnoreCase(getTag())) {
            colonColor = TextColors.GOLD;
        } else if (thirdClan != null && thirdClan.getTag().equalsIgnoreCase(getTag())) {
            colonColor = TextColors.DARK_BLUE;
        }
    }

    return Text.join(
            Text.builder("[").color(colonColor).build(),
            Text.builder(tag).color(tagColor).build(),
            Text.builder("]").color(colonColor).build()
    );
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:23,代码来源:ClanImpl.java

示例2: getColor

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
private TextColor getColor(BlockType type) {
    TextColor color = TextColors.WHITE;

    if (type.equals(BlockTypes.IRON_ORE)) {
        color = TextColors.GRAY;
    }
    else if (type.equals(BlockTypes.LAPIS_ORE)) {
        color = TextColors.BLUE;
    }
    else if (type.equals(BlockTypes.GOLD_ORE)) {
        color = TextColors.YELLOW;
    }
    else if (type.equals(BlockTypes.EMERALD_ORE)) {
        color = TextColors.GREEN;
    }
    else if (type.equals(BlockTypes.DIAMOND_ORE)) {
        color = TextColors.AQUA;
    }

    return color;
}
 
开发者ID:prism,项目名称:OreAlerts,代码行数:22,代码来源:ChangeBlockBreakListener.java

示例3: getColor

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
private TextColor getColor(IBlockOperation op) {
    switch (op.getStatus()) {
        case RUNNING:
            return TextColors.DARK_GREEN;
        case DONE:
            return TextColors.DARK_BLUE;
        case ERRORED:
            return TextColors.DARK_RED;
        case PAUSED:
            return TextColors.YELLOW;
        case CANCELED:
            return TextColors.GRAY;
        default:
            return TextColors.BLACK;
    }
}
 
开发者ID:Valandur,项目名称:Web-API,代码行数:17,代码来源:CmdBlockUpdatesList.java

示例4: addColor

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
private Text addColor(Text text, String name, TextColor color) {
    if (!text.getChildren().isEmpty()) {
        text = text.toBuilder().removeAll().append(text.getChildren().stream().map(child -> addColor(child, name, color)).collect(Collectors.toList())).build();
    }
    String plain = text.toPlainSingle();
    if (plain.toLowerCase().contains(name.toLowerCase())) {
        Text nameText = Text.of(color, name);
        if (plain.equals(name)) return nameText;
        Text.Builder builder = Text.builder();
        String[] sections = plain.split(Pattern.quote(name));
        for (int i = 0; i < sections.length - 1; i++) {
            builder.append(Text.of(sections[i]));
            builder.append(nameText);
        }
        builder.append(Text.of(sections[sections.length - 1]));
        if (plain.endsWith(name)) {
            builder.append(nameText);
        }
        builder.style(text.getStyle()).color(text.getColor()).append(text.getChildren());
        return builder.build();
    }
    return text;
}
 
开发者ID:pie-flavor,项目名称:Boop,代码行数:24,代码来源:BoopableChannel.java

示例5: getLastColourAndStyle

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
private static StyleTuple getLastColourAndStyle(Text text, StyleTuple current) {
    List<Text> texts = flatten(text);
    TextColor tc = TextColors.NONE;
    TextStyle ts = TextStyles.NONE;
    for (int i = texts.size() - 1; i > -1; i--) {
        // If we have both a Text Colour and a Text Style, then break out.
        if (tc != TextColors.NONE && ts != TextStyles.NONE) {
            break;
        }

        if (tc == TextColors.NONE) {
            tc = texts.get(i).getColor();
        }

        if (ts == TextStyles.NONE) {
            ts = texts.get(i).getStyle();
        }
    }

    if (current == null) {
        return new StyleTuple(tc, ts);
    }

    return new StyleTuple(tc != TextColors.NONE ? tc : current.colour, ts != TextStyles.NONE ? ts : current.style);
}
 
开发者ID:nguyenquyhy,项目名称:DiscordBridge,代码行数:26,代码来源:TextUtil.java

示例6: registerDefaults

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
@Override
public void registerDefaults() {
    register(new LanternDisplaySlot("minecraft", "list", null, 0));
    register(new LanternDisplaySlot("minecraft", "sidebar", null, 1));
    register(new LanternDisplaySlot("minecraft", "below_name", "belowName", null, 2));
    for (TextColor textColor : Sponge.getRegistry().getAllOf(TextColor.class)) {
        // There is not mapping for "none"
        if (textColor == TextColors.NONE) {
            continue;
        }
        final char character = FormattingCodeTextSerializer.FORMATS_TO_CODE.get(textColor);
        final String id = "below_name_" + textColor.getId();
        final String name = "sidebar.team." + textColor.getId();
        register(new LanternDisplaySlot("minecraft", id, name, textColor, 3 + character));
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:17,代码来源:DisplaySlotRegistryModule.java

示例7: LanternTeam

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
LanternTeam(String name, TextColor color, Text displayName, Text prefix, Text suffix,
            boolean allowFriendlyFire, boolean canSeeFriendlyInvisibles, Visibility nameTagVisibility,
            Visibility deathMessageVisibility, CollisionRule collisionRule) {
    this.displayName = displayName;
    this.legacyDisplayName = LanternTexts.toLegacy(displayName);
    this.prefix = prefix;
    this.legacyPrefix = LanternTexts.toLegacy(prefix);
    this.suffix = suffix;
    this.legacySuffix = LanternTexts.toLegacy(suffix);
    this.name = name;
    this.color = color;
    this.allowFriendlyFire = allowFriendlyFire;
    this.canSeeFriendlyInvisibles = canSeeFriendlyInvisibles;
    this.nameTagVisibility = nameTagVisibility;
    this.deathMessageVisibility = deathMessageVisibility;
    this.collisionRule = collisionRule;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:18,代码来源:LanternTeam.java

示例8: generateHealthMessage

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
private Text generateHealthMessage(double currentHealth, double maxHealth) {
    double percent = currentHealth * 100 / maxHealth;
    //10-steps -> 1=10% 2=20% 3=30%
    int steps = (int) Math.ceil(percent / 10);

    char displayChar = settings.getConfig().getDisplayChar();

    TextColor highlightColor = getHealthColor(steps);

    Text.Builder textBuilder = Text.builder();
    for (int i = 0; i < percent / 10; i++) {
        textBuilder.append(Text
                .builder(displayChar)
                .color(highlightColor)
                .build());
    }

    textBuilder.append(Text.builder().color(TextColors.RESET).build());

    return textBuilder.build();
}
 
开发者ID:games647,项目名称:HealthName,代码行数:22,代码来源:DamageListener.java

示例9: Job

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
public Job(String id, String displayName, int maxLevel, TextColor textColor, boolean silkTouch, boolean worldGen, boolean ignoreData,
        String expEquation, String curEquation, Map<String, Reward> blockBreaks, Map<String, Reward> blockPlaces,
        Map<String, Reward> mobKills) {
    this.id = id;
    this.displayName = displayName;
    this.maxLevel = maxLevel;
    this.textColor = textColor;
    this.silkTouch = silkTouch;
    this.worldGen = worldGen;
    this.ignoreData = ignoreData;
    this.expEquation = expEquation;
    this.curEquation = curEquation;
    this.blockBreaks = blockBreaks;
    this.blockPlaces = blockPlaces;
    this.mobKills = mobKills;
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:17,代码来源:Job.java

示例10: initialize

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void initialize() {
    Player player = getPlayer();
    CreatingJob parent = getParent();
    JobManager jobManager = JobsLite.getJobManager();
    if (jobManager.createJob((String) parent.getData(DataTypes.NAME).getValue(), (String) parent.getData(DataTypes.DISPLAY_NAME).getValue(),
            (Integer) parent.getData(DataTypes.MAX_LEVEL).getValue(), (TextColor) parent.getData(DataTypes.COLOR).getValue(),
            (Boolean) parent.getData(DataTypes.SILK_TOUCH).getValue(), (Boolean) parent.getData(DataTypes.WORLD_GEN).getValue(),
            (Boolean) parent.getData(DataTypes.BLOCK_DATA).getValue(),
            (HashMap<BlockState, Reward>) parent.getData(DataTypes.BREAK_REWARDS).getValue(),
            (HashMap<BlockState, Reward>) parent.getData(DataTypes.PLACE_REWARDS).getValue(),
            (HashMap<EntityType, Reward>) parent.getData(DataTypes.KILL_REWARDS).getValue())) {
        getParent().cancel();
        player.sendMessage(messages.getMessage("creation.success"));
    } else {
        player.sendMessage(messages.getMessage("creation.fail"));
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:19,代码来源:FinalTask.java

示例11: parseValue

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
@Override
public ParseResult<TextColor> parseValue(CommandSource commandSource, String value, NormalFilledParameter parameter) {
    TextColor textColor = Utils.getTextColorByName(value, null);
    if (textColor == null) {
        return ParseResult.newErrorResult(Messages.THIS_IS_NOT_A_VALID_COLOR);
    } else {
        return ParseResult.newSuccessResult(textColor);
    }
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:10,代码来源:TextColorParser.java

示例12: getTextColorByName

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
public static TextColor getTextColorByName(String textColorName, TextColor fallbackColor) {
    if (TextColors.AQUA.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.AQUA;
    } else if (TextColors.BLACK.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.BLACK;
    } else if (TextColors.BLUE.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.BLUE;
    } else if (TextColors.DARK_AQUA.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.DARK_AQUA;
    } else if (TextColors.DARK_BLUE.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.DARK_BLUE;
    } else if (TextColors.DARK_GRAY.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.DARK_GRAY;
    } else if (TextColors.DARK_GREEN.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.DARK_GREEN;
    } else if (TextColors.DARK_PURPLE.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.DARK_PURPLE;
    } else if (TextColors.DARK_RED.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.DARK_RED;
    } else if (TextColors.GOLD.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.GOLD;
    } else if (TextColors.GRAY.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.GRAY;
    } else if (TextColors.GREEN.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.GREEN;
    } else if (TextColors.LIGHT_PURPLE.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.LIGHT_PURPLE;
    } else if (TextColors.RED.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.RED;
    } else if (TextColors.WHITE.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.WHITE;
    } else if (TextColors.YELLOW.getName().equalsIgnoreCase(textColorName)) {
        return TextColors.YELLOW;
    } else {
        return fallbackColor;
    }
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:38,代码来源:Utils.java

示例13: getTextColorById

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
public static TextColor getTextColorById(String textColorId, TextColor fallbackColor) {
    if (TextColors.AQUA.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.AQUA;
    } else if (TextColors.BLACK.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.BLACK;
    } else if (TextColors.BLUE.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.BLUE;
    } else if (TextColors.DARK_AQUA.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.DARK_AQUA;
    } else if (TextColors.DARK_BLUE.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.DARK_BLUE;
    } else if (TextColors.DARK_GRAY.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.DARK_GRAY;
    } else if (TextColors.DARK_GREEN.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.DARK_GREEN;
    } else if (TextColors.DARK_PURPLE.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.DARK_PURPLE;
    } else if (TextColors.DARK_RED.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.DARK_RED;
    } else if (TextColors.GOLD.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.GOLD;
    } else if (TextColors.GRAY.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.GRAY;
    } else if (TextColors.GREEN.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.GREEN;
    } else if (TextColors.LIGHT_PURPLE.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.LIGHT_PURPLE;
    } else if (TextColors.RED.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.RED;
    } else if (TextColors.WHITE.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.WHITE;
    } else if (TextColors.YELLOW.getId().equalsIgnoreCase(textColorId)) {
        return TextColors.YELLOW;
    } else {
        return fallbackColor;
    }
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:38,代码来源:Utils.java

示例14: formatMinutes

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
private static Text formatMinutes(int minutes, TextColor textColor, TextColor highlightColor) {
    Text timeText = Text.builder(String.valueOf(minutes)).color(highlightColor).build();
    return Text.join(
            timeText, Text.of(" "),
            Text.builder((minutes == 1) ? "minute" : "minutes").color(textColor).build()
    );
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:8,代码来源:Utils.java

示例15: formatHours

import org.spongepowered.api.text.format.TextColor; //导入依赖的package包/类
private static Text formatHours(int hours, TextColor textColor, TextColor highlightColor) {
    Text timeText = Text.builder(String.valueOf(hours)).color(highlightColor).build();
    return Text.join(
            timeText, Text.of(" "),
            Text.builder((hours == 1) ? "hour" : "hours").color(textColor).build()
    );
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:8,代码来源:Utils.java


注:本文中的org.spongepowered.api.text.format.TextColor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。