Solved Error ChatSerializer

Discussion in 'Spigot Plugin Development' started by davdav45, Jun 26, 2016.

Thread Status:
Not open for further replies.
  1. So I was working on this util for a core plugin, just take a look

    Code (Text):
    import org.bukkit.ChatColor;
    import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
    import org.bukkit.entity.Player;

    import net.minecraft.server.v1_8_R1.IChatBaseComponent;
    import net.minecraft.server.v1_8_R1.IChatBaseComponent.ChatSerializer;
    import net.minecraft.server.v1_8_R1.PacketPlayOutChat;
    import net.minecraft.server.v1_8_R1.PlayerConnection;

    public class ActionBar {

        public static void send(Player p, String msg) {
            IChatBaseComponent chat = ChatSerializer.a("{\"text\":\"" +
           
                    ChatColor.translateAlternateColorCodes('&', msg) + "\"}");
                   
                    PacketPlayOutChat actionBarText = new PacketPlayOutChat(chat, (byte)2);
                   
                    PlayerConnection playerConnection = ((CraftPlayer)p).getHandle().playerConnection;
                   
                    playerConnection.sendPacket(actionBarText);
        }
    }
     
    The error is coming from " net.minecraft.server.v1_8_R1.IChatBaseComponent.ChatSerializer; "
    Witch I need for " IChatBaseComponent chat = ChatSerializer.a("{\"text\":\"" + " that to work.

    Anyway around this?
     
  2. I don't think you need to import child classes like that. o_O
     
  3. Got it working!
     
Thread Status:
Not open for further replies.