本文整理汇总了Java中org.spongepowered.api.text.format.TextStyle类的典型用法代码示例。如果您正苦于以下问题:Java TextStyle类的具体用法?Java TextStyle怎么用?Java TextStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextStyle类属于org.spongepowered.api.text.format包,在下文中一共展示了TextStyle类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getFormat
import org.spongepowered.api.text.format.TextStyle; //导入依赖的package包/类
private static TextStyle getFormat(char c) {
switch (c) {
case 'k':
return TextStyles.OBFUSCATED;
case 'l':
return TextStyles.BOLD;
case 'm':
return TextStyles.STRIKETHROUGH;
case 'n':
return TextStyles.UNDERLINE;
case 'o':
return TextStyles.ITALIC;
case 'r':
return TextStyles.RESET;
default:
return null;
}
}
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:19,代码来源:Colors.java
示例2: getTextStyle
import org.spongepowered.api.text.format.TextStyle; //导入依赖的package包/类
public static TextStyle getTextStyle(final String arg){
TextStyle style = TextStyles.NONE;
if (arg.equalsIgnoreCase("&k")){
style = TextStyles.OBFUSCATED;
} else if (arg.equalsIgnoreCase("&l")){
style = TextStyles.BOLD;
} else if (arg.equalsIgnoreCase("&m")){
style = TextStyles.STRIKETHROUGH;
} else if (arg.equalsIgnoreCase("&n")){
style = TextStyles.UNDERLINE;
} else if (arg.equalsIgnoreCase("&o")){
style = TextStyles.ITALIC;
} else if (arg.equalsIgnoreCase("&r")){
style = TextStyles.RESET;
}
return style;
}
开发者ID:EverCraft,项目名称:EverAPI,代码行数:18,代码来源:EChat.java
示例3: getLastColourAndStyle
import org.spongepowered.api.text.format.TextStyle; //导入依赖的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
示例4: inheritStyle
import org.spongepowered.api.text.format.TextStyle; //导入依赖的package包/类
private static TextStyle inheritStyle(TextStyle base, TextStyle overrides) {
// styles from base always exist as it must derive from DEFAULTS
return new TextStyle(overrides.isBold().orElse(base.isBold().get()),
overrides.isItalic().orElse(base.isItalic().get()),
overrides.hasUnderline().orElse(base.hasUnderline().get()),
overrides.hasStrikethrough().orElse(base.hasStrikethrough().get()),
overrides.isObfuscated().orElse(base.isObfuscated().get()));
}
开发者ID:simon816,项目名称:ChatUI,代码行数:9,代码来源:TextSplitter.java
示例5: applyStyle
import org.spongepowered.api.text.format.TextStyle; //导入依赖的package包/类
private static boolean applyStyle(Text.Builder builder, Object format) {
if (format instanceof TextStyle) {
builder.style((TextStyle) format);
return false;
} else if (format == TextColors.RESET) {
return true;
} else {
if (builder.getColor() == TextColors.NONE) {
builder.color((TextColor) format);
}
return true;
}
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:14,代码来源:FormattingCodeTextSerializer.java
示例6: constructMessage
import org.spongepowered.api.text.format.TextStyle; //导入依赖的package包/类
/**
* Constructs a message from the collection of {@link HammerText} messages.
*
* @param message The {@link HammerText} messages.
* @return The completed message.
*/
public static Text constructMessage(HammerText message) {
Text.Builder builder = Text.builder();
// For each HammerText element...
for (HammerText.Element e : message.getElements()) {
// Message
Text.Builder inner = Text.builder(e.message);
// Colour?
if (e.colour != null) {
TextColor c = HammerTextToTextColorCoverter.getCodeFromHammerText(e.colour);
if (c != null) {
inner.color(c);
}
}
// Format?
if (e.formats != null && e.formats.length > 0) {
List<TextStyle> styles = new ArrayList<>();
for (HammerTextFormats format : e.formats) {
// Sometimes can be null...
TextStyle ts = HammerTextToTextColorCoverter.getCodeFromHammerText(format);
if (ts != null) {
styles.add(ts);
}
}
inner.style(styles.toArray(new TextStyle[styles.size()]));
}
// Into the builder it goes.
builder.append(inner.build());
}
// Build the builder and return it!
return builder.build();
}
开发者ID:dualspiral,项目名称:Hammer,代码行数:44,代码来源:HammerTextConverter.java
示例7: addFormats
import org.spongepowered.api.text.format.TextStyle; //导入依赖的package包/类
private static void addFormats(Text.Builder builder, TextColor color, List<TextStyle> styles, String s) {
if (color != null) {
if (styles.size() == 0) {
builder.append(Text.of(color, s));
}
if (styles.size() == 1) {
builder.append(Text.of(color, styles.get(0), s));
}
if (styles.size() == 2) {
builder.append(Text.of(color, styles.get(0), styles.get(1), s));
}
if (styles.size() == 3) {
builder.append(Text.of(color, styles.get(0), styles.get(1), styles.get(2), s));
}
if (styles.size() == 4) {
builder.append(Text.of(color, styles.get(0), styles.get(1), styles.get(2), styles.get(3), s));
}
if (styles.size() > 4) {
builder.append(Text.of(color, styles.get(0), styles.get(1), styles.get(2), styles.get(3), styles.get(4), s));
}
} else {
if (styles.size() == 0) {
builder.append(Text.of(s));
}
if (styles.size() == 1) {
builder.append(Text.of(styles.get(0), s));
}
if (styles.size() == 2) {
builder.append(Text.of(styles.get(0), styles.get(1), s));
}
if (styles.size() == 3) {
builder.append(Text.of(styles.get(0), styles.get(1), styles.get(2), s));
}
if (styles.size() == 4) {
builder.append(Text.of(styles.get(0), styles.get(1), styles.get(2), styles.get(3), s));
}
if (styles.size() > 4) {
builder.append(Text.of(styles.get(0), styles.get(1), styles.get(2), styles.get(3), styles.get(4), s));
}
}
}
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:42,代码来源:Colors.java
示例8: StyleTuple
import org.spongepowered.api.text.format.TextStyle; //导入依赖的package包/类
StyleTuple(TextColor colour, TextStyle style) {
this.colour = colour;
this.style = style;
}
开发者ID:nguyenquyhy,项目名称:DiscordBridge,代码行数:5,代码来源:TextUtil.java
示例9: getStyleChar
import org.spongepowered.api.text.format.TextStyle; //导入依赖的package包/类
public static Character getStyleChar(TextStyle style) {
return styles.get(style);
}
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:4,代码来源:TextUtil.java
示例10: getCodeFromHammerText
import org.spongepowered.api.text.format.TextStyle; //导入依赖的package包/类
/**
* Gets the {@link TextStyle} form the {@link HammerTextFormats} provided.
*
* @param code The {@link HammerTextFormats} to convert.
* @return The {@link TextStyle}.
*/
public static TextStyle getCodeFromHammerText(HammerTextFormats code) {
return htf.get(code);
}
开发者ID:dualspiral,项目名称:Hammer,代码行数:10,代码来源:HammerTextToTextColorCoverter.java
注:本文中的org.spongepowered.api.text.format.TextStyle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论