Solved Send custom mesage from Bungeecord to spigot

Discussion in 'BungeeCord Plugin Development' started by KarmaConfigs, Feb 11, 2020.

  1. Hi, I've been searching a lot and I found the way to send a plugin message from bungeecord to spigot, but for some reason, I'm getting a NullPointerException

    Code (Text):
    Error dispatching event PostLoginEvent(player=EdwinCrack) to listener [email protected]
        at io.github.karmaconfigs.Bungee.Utils.Proxy.sendData.sendCustomData(
        at io.github.karmaconfigs.Bungee.Events.JoinEvent.OnJoin(
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at net.md_5.bungee.event.EventHandlerMethod.invoke(
        at net.md_5.bungee.api.plugin.PluginManager.callEvent(
        at net.md_5.bungee.connection.InitialHandler$6$
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(
        at io.netty.util.concurrent.SingleThreadEventExecutor$
        at io.netty.util.internal.ThreadExecutorMap$
        at Source)
    My sendCustomData void is this


    Code (Java):
    public void sendCustomData(ProxiedPlayer player, String data1, int data2)
            Collection<ProxiedPlayer> networkPlayers = ProxyServer.getInstance().getPlayers();
            if ( networkPlayers == null || networkPlayers.isEmpty()) return;

            ByteArrayDataOutput out = ByteStreams.newDataOutput();
            out.writeUTF( "RegStatus" );
            out.writeUTF( data1 );
            out.writeInt( data2 );

            player.getServer().getInfo().sendData( "ll:pinfo", out.toByteArray() );
    And I registered the channel

    Code (Java):
        public void onEnable() {
            new Main().onEnable();
            getProxy().registerChannel( "ll:pinfo" );
    I'm sending the message when the player joins the server

    Why is it getting me a Null error?
  2. Fixed by myself by scheduling the task of sending the message
    • Like Like x 1