本文整理汇总了Java中net.minecraft.server.IChatBaseComponent类的典型用法代码示例。如果您正苦于以下问题:Java IChatBaseComponent类的具体用法?Java IChatBaseComponent怎么用?Java IChatBaseComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IChatBaseComponent类属于net.minecraft.server包,在下文中一共展示了IChatBaseComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
super.serialize(builder);
if (hasTitle()) {
builder.put(BOOK_TITLE.BUKKIT, title);
}
if (hasAuthor()) {
builder.put(BOOK_AUTHOR.BUKKIT, author);
}
if (hasPages()) {
List<String> pagesString = new ArrayList<String>();
for (IChatBaseComponent comp : pages) {
pagesString.add(CraftChatMessage.fromComponent(comp));
}
builder.put(BOOK_PAGES.BUKKIT, pagesString);
}
if (generation != null) {
builder.put(GENERATION.BUKKIT, generation);
}
return builder;
}
示例2: fromComponent
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
public static String fromComponent(IChatBaseComponent component, EnumChatFormat defaultColor) {
if (component == null) return "";
StringBuilder out = new StringBuilder();
for (IChatBaseComponent c : (Iterable<IChatBaseComponent>) component) {
ChatModifier modi = c.getChatModifier();
out.append(modi.getColor() == null ? defaultColor : modi.getColor());
if (modi.isBold()) {
out.append(EnumChatFormat.BOLD);
}
if (modi.isItalic()) {
out.append(EnumChatFormat.ITALIC);
}
if (modi.isUnderlined()) {
out.append(EnumChatFormat.UNDERLINE);
}
if (modi.isStrikethrough()) {
out.append(EnumChatFormat.STRIKETHROUGH);
}
if (modi.isRandom()) {
out.append(EnumChatFormat.OBFUSCATED);
}
out.append(c.getText());
}
return out.toString().replaceFirst("^(" + defaultColor + ")*", "");
}
示例3: a
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
@Override
public PacketTracer a(IChatBaseComponent chat) {
value("Chat", chat);
try {
mute = true;
super.a(chat);
} finally {
mute = false;
}
return this;
}
示例4: update
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
@Override
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
IChatBaseComponent[] newLines = sanitizeLines(lines);
System.arraycopy(newLines, 0, sign.lines, 0, 4);
sign.update();
}
return result;
}
示例5: sanitizeLines
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
public static IChatBaseComponent[] sanitizeLines(String[] lines) {
IChatBaseComponent[] components = new IChatBaseComponent[4];
for (int i = 0; i < 4; i++) {
if (i < lines.length && lines[i] != null) {
components[i] = CraftChatMessage.fromString(lines[i])[0];
} else {
components[i] = new ChatComponentText("");
}
}
return components;
}
示例6: revertComponents
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
public static String[] revertComponents(IChatBaseComponent[] components) {
String[] lines = new String[components.length];
for (int i = 0; i < lines.length; i++) {
lines[i] = revertComponent(components[i]);
}
return lines;
}
示例7: applyToItem
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
@Override
void applyToItem(NBTTagCompound itemData) {
super.applyToItem(itemData, false);
if (hasTitle()) {
itemData.setString(BOOK_TITLE.NBT, this.title);
} else {
itemData.setString(BOOK_TITLE.NBT, " ");
}
if (hasAuthor()) {
itemData.setString(BOOK_AUTHOR.NBT, this.author);
} else {
itemData.setString(BOOK_AUTHOR.NBT, " ");
}
if (hasPages()) {
NBTTagList list = new NBTTagList();
for (IChatBaseComponent page : pages) {
list.add(new NBTTagString(
ChatSerializer.a(page)
));
}
itemData.set(BOOK_PAGES.NBT, list);
}
itemData.setBoolean(RESOLVED.NBT, true);
if (generation != null) {
itemData.setInt(GENERATION.NBT, generation);
} else {
itemData.setInt(GENERATION.NBT, 0);
}
}
示例8: applyToItem
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
void applyToItem(NBTTagCompound itemData, boolean handlePages) {
super.applyToItem(itemData);
if (hasTitle()) {
itemData.setString(BOOK_TITLE.NBT, this.title);
}
if (hasAuthor()) {
itemData.setString(BOOK_AUTHOR.NBT, this.author);
}
if (handlePages) {
if (hasPages()) {
NBTTagList list = new NBTTagList();
for (IChatBaseComponent page : pages) {
list.add(new NBTTagString(CraftChatMessage.fromComponent(page)));
}
itemData.set(BOOK_PAGES.NBT, list);
}
itemData.remove(RESOLVED.NBT);
}
if (generation != null) {
itemData.setInt(GENERATION.NBT, generation);
}
}
示例9: getPages
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
public List<String> getPages() {
final List<IChatBaseComponent> copy = ImmutableList.copyOf(pages);
return new AbstractList<String>() {
@Override
public String get(int index) {
return CraftChatMessage.fromComponent(copy.get(index));
}
@Override
public int size() {
return copy.size();
}
};
}
示例10: StringMessage
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
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]);
}
示例11: getOutput
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
private IChatBaseComponent[] getOutput() {
return output;
}
示例12: fromString
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
public static IChatBaseComponent[] fromString(String message) {
return new StringMessage(message).getOutput();
}
示例13: revertComponent
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
private static String revertComponent(IChatBaseComponent component) {
return CraftChatMessage.fromComponent(component);
}
示例14: getScoreboardDisplayName
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
@Override
public IChatBaseComponent getScoreboardDisplayName() {
return new ChatComponentText(title);
}
示例15: clone
import net.minecraft.server.IChatBaseComponent; //导入依赖的package包/类
@Override
public CraftMetaBook clone() {
CraftMetaBook meta = (CraftMetaBook) super.clone();
meta.pages = new ArrayList<IChatBaseComponent>(pages);
return meta;
}