use of net.minecraft.server.v1_8_R1.IChatBaseComponent in project L2X9RebootCore by 254nm.
the class AntiLink method outgoing.
@Override
public void outgoing(PacketEvent.Outgoing event) throws Throwable {
if (event.getPacket() instanceof PacketPlayOutChat) {
PacketPlayOutChat packet = (PacketPlayOutChat) event.getPacket();
IChatBaseComponent message = (IChatBaseComponent) messageF.get(packet);
if (message == null)
return;
List<String> list = manager.getConfig().getStringList("Blocked");
for (String word : list) {
if (message.toPlainText().contains(word)) {
event.setCancelled(true);
break;
}
}
}
}
use of net.minecraft.server.v1_8_R1.IChatBaseComponent in project L2X9RebootCore by 254nm.
the class TabRunnable method run.
@Override
public void run() {
Bukkit.getOnlinePlayers().forEach(player -> {
try {
String headerStr = String.join("\n", manager.getConfig().getStringList("Header"));
String footerStr = String.join("\n", manager.getConfig().getStringList("Footer"));
IChatBaseComponent header = new ChatComponentText(manager.parsePlaceHolders(headerStr, player));
IChatBaseComponent footer = new ChatComponentText(manager.parsePlaceHolders(footerStr, player));
CraftPlayer craftPlayer = (CraftPlayer) player;
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
headerField.set(packet, header);
footerField.set(packet, footer);
craftPlayer.getHandle().playerConnection.sendPacket(packet);
} catch (Throwable t) {
t.printStackTrace();
}
});
}
use of net.minecraft.server.v1_8_R1.IChatBaseComponent in project Ublisk by Derkades.
the class V1_12_R1 method sendActionBarMessage.
@Override
public void sendActionBarMessage(Player player, String message) {
IChatBaseComponent dummyComponent = ChatSerializer.a("{\"text\":\"herobrine1337\"}");
PacketPlayOutChat packet = new PacketPlayOutChat(dummyComponent, ChatMessageType.GAME_INFO);
packet.components = new BaseComponent[] { new TextComponent(message) };
CraftPlayer craftPlayer = (CraftPlayer) player;
craftPlayer.getHandle().playerConnection.sendPacket(packet);
}
use of net.minecraft.server.v1_8_R1.IChatBaseComponent in project FireAPI by FireBlade-Serv.
the class FireTitle method send.
public void send() {
IChatBaseComponent basetitle = ChatSerializer.a("{\"text\": \"" + this.title + "\"}");
IChatBaseComponent basesubtitle = ChatSerializer.a("{\"text\": \"" + this.subtitle + "\"}");
PacketPlayOutTitle titlepacket = new PacketPlayOutTitle(EnumTitleAction.TITLE, basetitle);
PacketPlayOutTitle subtitlepacket = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, basesubtitle);
((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(titlepacket);
((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(subtitlepacket);
sendTime();
}
use of net.minecraft.server.v1_8_R1.IChatBaseComponent in project McWiki by skylerdev.
the class CommandWiki method showBook.
/**
* Shows book.
*
* @param pages
* The pages of the book to display in List<String>
* @param playerName
* The name of the player
*/
private void showBook(List<String> pages, String playerName) {
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) book.getItemMeta();
// Fancy stuff to serialize pages
List<IChatBaseComponent> cPages = null;
try {
cPages = (List<IChatBaseComponent>) CraftMetaBook.class.getDeclaredField("pages").get(meta);
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
for (String page : pages) {
IChatBaseComponent cPage = IChatBaseComponent.ChatSerializer.a(page);
cPages.add(cPage);
}
meta.setTitle("McWiki");
meta.setAuthor("Article");
book.setItemMeta(meta);
Bukkit.getPlayer(playerName).openBook(book);
}
Aggregations