use of net.minecraft.server.v1_14_R1.IChatBaseComponent in project TheAPI by TheDevTec.
the class v1_9_R1 method toIChatBaseComponents.
@Override
public Object toIChatBaseComponents(Component c) {
List<IChatBaseComponent> chat = new ArrayList<>();
chat.add(new ChatComponentText(""));
while (c != null) {
if (c.getText() == null || c.getText().isEmpty()) {
c = c.getExtra();
continue;
}
ChatComponentText current = new ChatComponentText(c.getText());
chat.add(current);
ChatModifier modif = current.getChatModifier();
if (c.getColor() != null && !c.getColor().isEmpty()) {
modif = modif.setColor(EnumChatFormat.a(c.getColor().charAt(0)));
}
if (c.getClickEvent() != null)
modif = modif.setChatClickable(new ChatClickable(EnumClickAction.valueOf(c.getClickEvent().getAction().name()), c.getClickEvent().getValue()));
if (c.getHoverEvent() != null)
modif = modif.setChatHoverable(new ChatHoverable(EnumHoverAction.valueOf(c.getHoverEvent().getAction().name()), (IChatBaseComponent) toIChatBaseComponent(c.getHoverEvent().getValue())));
modif = modif.setBold(c.isBold());
modif = modif.setItalic(c.isItalic());
modif = modif.setRandom(c.isObfuscated());
modif = modif.setUnderline(c.isUnderlined());
modif = modif.setStrikethrough(c.isStrikethrough());
current.setChatModifier(modif);
c = c.getExtra();
}
return chat.toArray(new IChatBaseComponent[0]);
}
use of net.minecraft.server.v1_14_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_14_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_14_R1.IChatBaseComponent in project Cauldron by GhastGames.
the class TitleManager method set.
@Override
public void set(Player player, Title newTitle) {
CraftPlayer craftPlayer = (CraftPlayer) player;
IChatBaseComponent title = IChatBaseComponent.ChatSerializer.a("{text: \"" + newTitle.getTitle().replace("\"", "") + "\"}");
PacketPlayOutTitle packetPlayOutTitle = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, title, newTitle.fadeIn, newTitle.stay, newTitle.fadeOut);
IChatBaseComponent subtitle = IChatBaseComponent.ChatSerializer.a("{text: \"" + newTitle.getTitle().replace("\"", "") + "\"}");
PacketPlayOutTitle packetPlayOutTitle2 = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, subtitle, newTitle.fadeIn, newTitle.stay, newTitle.fadeOut);
craftPlayer.getHandle().playerConnection.sendPacket(packetPlayOutTitle);
craftPlayer.getHandle().playerConnection.sendPacket(packetPlayOutTitle2);
}
use of net.minecraft.server.v1_14_R1.IChatBaseComponent in project PaperDev by Kamillaova.
the class CraftMetaBook method serialize.
@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;
}
Aggregations