org.bukkit.craftbukkit.util.CraftChatMessage Java Examples
The following examples show how to use
org.bukkit.craftbukkit.util.CraftChatMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftMetaBook.java From Kettle with GNU General Public License v3.0 | 6 votes |
@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 (ITextComponent comp : pages) { pagesString.add(CraftChatMessage.fromComponent(comp)); } builder.put(BOOK_PAGES.BUKKIT, pagesString); } if (generation != null) { builder.put(GENERATION.BUKKIT, generation); } return builder; }
Example #2
Source File: CraftPlayer.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public void sendRawMessage(String message) { if (getHandle().connection == null) { return; } for (ITextComponent component : CraftChatMessage.fromString(message)) { getHandle().connection.sendPacket(new SPacketChat(component)); } }
Example #3
Source File: CraftPlayer.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public void setPlayerListName(String name) { if (name == null) { name = getName(); } getHandle().listName = name.equals(getName()) ? null : CraftChatMessage.fromString(name)[0]; for (EntityPlayerMP player : server.getHandle().getPlayers()) { if (player.getBukkitEntity().canSee(this)) { player.connection.sendPacket(new SPacketPlayerListItem(SPacketPlayerListItem.Action.UPDATE_DISPLAY_NAME, getHandle())); } } }
Example #4
Source File: CraftPlayer.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut) { SPacketTitle times = new SPacketTitle(fadeIn, stay, fadeOut); getHandle().connection.sendPacket(times); if (title != null) { SPacketTitle packetTitle = new SPacketTitle(SPacketTitle.Type.TITLE, CraftChatMessage.fromString(title)[0]); getHandle().connection.sendPacket(packetTitle); } if (subtitle != null) { SPacketTitle packetSubtitle = new SPacketTitle(SPacketTitle.Type.SUBTITLE, CraftChatMessage.fromString(subtitle)[0]); getHandle().connection.sendPacket(packetSubtitle); } }
Example #5
Source File: CraftSign.java From Kettle with GNU General Public License v3.0 | 5 votes |
public static ITextComponent[] sanitizeLines(String[] lines) { ITextComponent[] components = new ITextComponent[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 TextComponentString(""); } } return components; }
Example #6
Source File: CraftPlayer.java From Thermos with GNU General Public License v3.0 | 5 votes |
@Override public void sendRawMessage(String message) { if (getHandle().playerNetServerHandler == null) return; for (net.minecraft.util.IChatComponent component : CraftChatMessage.fromString(message)) { getHandle().playerNetServerHandler.sendPacket(new net.minecraft.network.play.server.S02PacketChat(component)); } }
Example #7
Source File: CraftMetaBook.java From Kettle with GNU General Public License v3.0 | 5 votes |
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 (ITextComponent page : pages) { list.appendTag(new NBTTagString(CraftChatMessage.fromComponent(page))); } itemData.setTag(BOOK_PAGES.NBT, list); } itemData.removeTag(RESOLVED.NBT); } if (generation != null) { itemData.setInteger(GENERATION.NBT, generation); } }
Example #8
Source File: CraftMetaBook.java From Kettle with GNU General Public License v3.0 | 5 votes |
public void setPage(final int page, final String text) { if (!isValidPage(page)) { throw new IllegalArgumentException("Invalid page number " + page + "/" + pages.size()); } String newText = text == null ? "" : text.length() > MAX_PAGE_LENGTH ? text.substring(0, MAX_PAGE_LENGTH) : text; pages.set(page - 1, CraftChatMessage.fromString(newText, true)[0]); }
Example #9
Source File: CraftMetaBook.java From Kettle with GNU General Public License v3.0 | 5 votes |
public void addPage(final String... pages) { for (String page : pages) { if (this.pages.size() >= MAX_PAGES) { return; } if (page == null) { page = ""; } else if (page.length() > MAX_PAGE_LENGTH) { page = page.substring(0, MAX_PAGE_LENGTH); } this.pages.add(CraftChatMessage.fromString(page, true)[0]); } }
Example #10
Source File: CraftMetaBook.java From Kettle with GNU General Public License v3.0 | 5 votes |
public List<String> getPages() { final List<ITextComponent> 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(); } }; }
Example #11
Source File: CraftTeam.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public void setColor(ChatColor color) { Validate.notNull(color, "Color cannot be null"); CraftScoreboard scoreboard = checkState(); team.setColor(CraftChatMessage.getColor(color)); scoreboard.board.broadcastTeamInfoUpdate(team); // SPIGOT-3684 - backing team fires this for prefix/suffix but not colour }
Example #12
Source File: CraftBossBar.java From Kettle with GNU General Public License v3.0 | 5 votes |
public CraftBossBar(String title, BarColor color, BarStyle style, BarFlag... flags) { this.flags = flags.length > 0 ? EnumSet.of(flags[0], flags) : EnumSet.noneOf(BarFlag.class); this.color = color; this.style = style; handle = new BossInfoServer( CraftChatMessage.fromString(title, true)[0], convertColor(color), convertStyle(style) ); updateFlags(); }
Example #13
Source File: PlayerTabEntry.java From CardinalPGM with MIT License | 4 votes |
private String getDisplayName() { // The method is broken, removes black color, https://hub.spigotmc.org/jira/browse/SPIGOT-2711 //return player.getPlayerListName(); return CraftChatMessage.fromComponent(((CraftPlayer) player).getHandle().listName, EnumChatFormat.WHITE); }
Example #14
Source File: CraftFunctionCommandSender.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public void sendMessage(String message) { for (ITextComponent component : CraftChatMessage.fromString(message)) { handle.sendMessage(component); } }
Example #15
Source File: CraftBlockCommandSender.java From Kettle with GNU General Public License v3.0 | 4 votes |
public void sendMessage(String message) { for (ITextComponent component : CraftChatMessage.fromString(message)) { block.sendMessage(component); } }
Example #16
Source File: CraftBossBar.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public void setTitle(String title) { handle.name = CraftChatMessage.fromString(title, true)[0]; handle.sendUpdate(SPacketUpdateBossInfo.Operation.UPDATE_NAME); }
Example #17
Source File: CraftBossBar.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public String getTitle() { return CraftChatMessage.fromComponent(handle.getName()); }
Example #18
Source File: CraftTeam.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public ChatColor getColor() throws IllegalStateException { CraftScoreboard scoreboard = checkState(); return CraftChatMessage.getColor(team.getColor()); }
Example #19
Source File: InventoryWrapper.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public ITextComponent getDisplayName() { return CraftChatMessage.fromString(getName())[0]; }
Example #20
Source File: CraftMetaBook.java From Kettle with GNU General Public License v3.0 | 4 votes |
public String getPage(final int page) { Validate.isTrue(isValidPage(page), "Invalid page number"); return CraftChatMessage.fromComponent(pages.get(page - 1)); }
Example #21
Source File: CraftSign.java From Kettle with GNU General Public License v3.0 | 4 votes |
private static String revertComponent(ITextComponent component) { return CraftChatMessage.fromComponent(component); }
Example #22
Source File: CraftPlayer.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public String getPlayerListName() { return getHandle().listName == null ? getName() : CraftChatMessage.fromComponent(getHandle().listName, TextFormatting.WHITE); }