本文整理汇总了Java中net.minecraft.util.text.Style.setUnderlined方法的典型用法代码示例。如果您正苦于以下问题:Java Style.setUnderlined方法的具体用法?Java Style.setUnderlined怎么用?Java Style.setUnderlined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.text.Style
的用法示例。
在下文中一共展示了Style.setUnderlined方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getITextComponent
import net.minecraft.util.text.Style; //导入方法依赖的package包/类
public static ITextComponent getITextComponent(String chatMessage) {
ITextComponent textComponent = new net.minecraft.util.text.TextComponentString("");
String[] messageParts = chatMessage.split(" ");
int pathIndex = 0;
for (String messagePart : messageParts) {
ITextComponent append = new net.minecraft.util.text.TextComponentString(messagePart);
Style chatStyle = new Style();
if (URL_PATTERN.matcher(ChatColor.stripColor(messagePart)).matches()) {
chatStyle.setUnderlined(Boolean.valueOf(true));
chatStyle.setClickEvent(new net.minecraft.util.text.event.ClickEvent(
net.minecraft.util.text.event.ClickEvent.Action.OPEN_URL, ChatColor.stripColor(messagePart)));
}
String currentPath = chatMessage.substring(0, chatMessage.indexOf(messagePart, pathIndex));
String lastColor = ChatColor.getLastColors(currentPath);
if (lastColor.length() >= 2) {
char formattingChar = lastColor.charAt(1);
formatChatStyle(chatStyle, formattingChar);
}
append.setStyle(chatStyle);
textComponent.appendSibling(append);
textComponent.appendText(" ");
pathIndex += messagePart.length() - 1;
}
return textComponent;
}
示例2: printChatMessage
import net.minecraft.util.text.Style; //导入方法依赖的package包/类
public static void printChatMessage(String chatMessage) {
ITextComponent textComponent = new net.minecraft.util.text.TextComponentString("");
String[] messageParts = chatMessage.split(" ");
int pathIndex = 0;
for (String messagePart : messageParts) {
ITextComponent append = new net.minecraft.util.text.TextComponentString(messagePart);
Style chatStyle = new Style();
if (URL_PATTERN.matcher(ChatColor.stripColor(messagePart)).matches()) {
chatStyle.setUnderlined(Boolean.valueOf(true));
chatStyle.setClickEvent(new net.minecraft.util.text.event.ClickEvent(
net.minecraft.util.text.event.ClickEvent.Action.OPEN_URL, ChatColor.stripColor(messagePart)));
}
String currentPath = chatMessage.substring(0, chatMessage.indexOf(messagePart, pathIndex));
String lastColor = ChatColor.getLastColors(currentPath);
if (lastColor.length() >= 2) {
char formattingChar = lastColor.charAt(1);
formatChatStyle(chatStyle, formattingChar);
}
append.setStyle(chatStyle);
textComponent.appendSibling(append);
textComponent.appendText(" ");
pathIndex += messagePart.length() - 1;
}
Minecraft.getMinecraft().ingameGUI.getChatGUI().setChatLine(textComponent, 0,
Minecraft.getMinecraft().ingameGUI.getUpdateCounter(), false);
}
示例3: formatChatStyle
import net.minecraft.util.text.Style; //导入方法依赖的package包/类
private static Style formatChatStyle(Style chatStyle, char formattingChar) {
switch (formattingChar) {
case 'k':
chatStyle.setObfuscated(Boolean.valueOf(true));
break;
case 'm':
chatStyle.setStrikethrough(Boolean.valueOf(true));
break;
case 'l':
chatStyle.setBold(Boolean.valueOf(true));
break;
case 'n':
chatStyle.setUnderlined(Boolean.valueOf(true));
break;
case 'o':
chatStyle.setItalic(Boolean.valueOf(true));
break;
case 'r':
chatStyle.setObfuscated(Boolean.valueOf(false));
chatStyle.setStrikethrough(Boolean.valueOf(false));
chatStyle.setBold(Boolean.valueOf(false));
chatStyle.setUnderlined(Boolean.valueOf(false));
chatStyle.setItalic(Boolean.valueOf(false));
chatStyle.setColor(TextFormatting.RESET);
break;
case 'p':
case 'q':
default:
chatStyle.setColor(getTextFormattingByValue(formattingChar));
}
return chatStyle;
}
示例4: aprilFools
import net.minecraft.util.text.Style; //导入方法依赖的package包/类
@SubscribeEvent
public static void aprilFools(ServerChatEvent event)
{
if (D3Core.isAprilFools())
{
Style style = event.getComponent().getStyle();
float chance = 0.25f;
if (CoreConstants.RANDOM.nextFloat() < chance)
{
style.setBold(true);
chance *= chance;
}
if (CoreConstants.RANDOM.nextFloat() < chance)
{
style.setItalic(true);
chance *= chance;
}
if (CoreConstants.RANDOM.nextFloat() < chance)
{
style.setUnderlined(true);
chance *= chance;
}
if (CoreConstants.RANDOM.nextFloat() < chance)
{
style.setStrikethrough(true);
chance *= chance;
}
if (CoreConstants.RANDOM.nextFloat() < chance)
{
style.setObfuscated(true);
}
style.setColor(TextFormatting.values()[CoreConstants.RANDOM.nextInt(TextFormatting.values().length)]);
event.getComponent().setStyle(style);
}
}
示例5: execute
import net.minecraft.util.text.Style; //导入方法依赖的package包/类
@Override
public String execute(String commandName, CommandSender sender, String[] params) throws CommandException {
boolean global = commandName.endsWith("global");
if (params.length > (global ? 0 : 1)) {
String type = global ? null : params[0];
if (!global) params = Arrays.copyOfRange(params, 1, params.length);
Style style = new Style();
if (params[0].equalsIgnoreCase("reset")) style = null;
else {
for (String formatting : params) {
String[] split = formatting.split(":");
if (split.length != 2) throw new CommandException("command.chatstyle.invalidArg", sender, formatting);
if (formatting.startsWith("color")) {
TextFormatting color = TextFormatting.getValueByName(split[1]);
if (color == null || !color.isColor()) throw new CommandException("command.chatstyle.noColor", sender, split[1]);
style.setColor(color);
}
else if (split[0].equalsIgnoreCase("bold")) style.setBold(split[1].equalsIgnoreCase("true") || split[1].equals("1"));
else if (split[0].equalsIgnoreCase("italic")) style.setItalic(split[1].equalsIgnoreCase("true") || split[1].equals("1"));
else if (split[0].equalsIgnoreCase("underlined")) style.setUnderlined(split[1].equalsIgnoreCase("true") || split[1].equals("1"));
else if (split[0].equalsIgnoreCase("strikethrough")) style.setStrikethrough(split[1].equalsIgnoreCase("true") || split[1].equals("1"));
else if (split[0].equalsIgnoreCase("obfuscated")) style.setObfuscated(split[1].equalsIgnoreCase("true") || split[1].equals("1"));
else throw new CommandException("command.chatstyle.invalidArg", sender, formatting);
}
}
if (global) ReflectionHelper.set(ObfuscatedField.Style_defaultStyle, null, style);
else {
ServerPlayerSettings settings = getPlayerSettings(getSenderAsEntity(sender.getMinecraftISender(), EntityPlayerMP.class));
if (type.equals("name")) settings.nameStyle = style;
else if (type.equals("text")) settings.textStyle = style;
else if (type.equals("both")) settings.nameStyle = settings.textStyle = style;
}
}
return null;
}