本文整理汇总了Java中net.minecraft.server.ChatComponentText类的典型用法代码示例。如果您正苦于以下问题:Java ChatComponentText类的具体用法?Java ChatComponentText怎么用?Java ChatComponentText使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChatComponentText类属于net.minecraft.server包,在下文中一共展示了ChatComponentText类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sanitizeLines
import net.minecraft.server.ChatComponentText; //导入依赖的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;
}
示例2: c
import net.minecraft.server.ChatComponentText; //导入依赖的package包/类
@Override
public boolean c(EntityHuman entityhuman) {
if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
return true;
}
// If the window type has changed for some reason, update the player
// This method will be called every tick or something, so it's
// as good a place as any to put something like this.
boolean typeChanged = (cachedType != view.getType());
cachedType = view.getType();
cachedTitle = view.getTitle();
if (view.getPlayer() instanceof CraftPlayer) {
CraftPlayer player = (CraftPlayer) view.getPlayer();
String type = getNotchInventoryType(cachedType);
IInventory top = ((CraftInventory)view.getTopInventory()).getInventory();
IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory();
this.b.clear();
this.c.clear();
if (typeChanged) {
setupSlots(top, bottom);
}
int size = getSize();
player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle), size));
player.updateInventory();
}
return true;
}
示例3: c
import net.minecraft.server.ChatComponentText; //导入依赖的package包/类
@Override
public boolean c(EntityHuman entityhuman) {
if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
return true;
}
// If the window type has changed for some reason, update the player
// This method will be called every tick or something, so it's
// as good a place as any to put something like this.
boolean typeChanged = (cachedType != view.getType());
cachedType = view.getType();
cachedTitle = view.getTitle();
if (view.getPlayer() instanceof CraftPlayer) {
CraftPlayer player = (CraftPlayer) view.getPlayer();
String type = getNotchInventoryType(cachedType);
IInventory top = ((CraftInventory) view.getTopInventory()).getInventory();
IInventory bottom = ((CraftInventory) view.getBottomInventory()).getInventory();
this.b.clear();
this.c.clear();
if (typeChanged) {
setupSlots(top, bottom);
}
int size = getSize();
player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle), size));
player.updateInventory();
}
return true;
}
示例4: getScoreboardDisplayName
import net.minecraft.server.ChatComponentText; //导入依赖的package包/类
@Override
public IChatBaseComponent getScoreboardDisplayName() {
return new ChatComponentText(title);
}
示例5: StringMessage
import net.minecraft.server.ChatComponentText; //导入依赖的package包/类
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()]);
}
示例6: sendMessage
import net.minecraft.server.ChatComponentText; //导入依赖的package包/类
@Override
public void sendMessage(String message) {
RemoteControlCommandListener.getInstance().sendMessage(new ChatComponentText(message + "\n")); // Send a newline after each message, to preserve formatting.
}
示例7: getPlayerInfo
import net.minecraft.server.ChatComponentText; //导入依赖的package包/类
public PacketPlayOutPlayerInfo.PlayerInfoData getPlayerInfo(Player viewer, PacketPlayOutPlayerInfo listPacket) {
int ping = getPing();
return listPacket.new PlayerInfoData(getProfile(), ping < 0 ? 1000 : ping, EnumGamemode.SURVIVAL,
new ChatComponentText(getDisplayName(viewer)));
}
示例8: sendMessage
import net.minecraft.server.ChatComponentText; //导入依赖的package包/类
@Override
public void sendMessage(String message) {
listener.sendMessage(new ChatComponentText(message + "\n")); // Send a newline after each message, to preserve formatting.
}