Solved Send plugin messages between spigot servers

Discussion in 'Spigot Help' started by Mher, Jun 28, 2021.

  1. Hey, I need help to send plugin messages between spigot servers

    This is what I have tried:
    spigot server that is sending the message
    Code (Java):

    ByteArrayOutputStream b = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(b);
    try {
    } catch (IOException e) {
    player.sendPluginMessage(PracticeGui.getInstance(), "ChannelName", b.toByteArray());
    register part
    Code (Java):

    Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(this, "ChannelName");
    the part that the plugin getting the plugin message
    Code (Java):

    public void onPluginMessageReceived(String channel, Player player, byte[] bytes) {
        if (!channel.equals("ChannelName")) return;
        ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
        String subChannel = in.readUTF();
        if (subChannel.equalsIgnoreCase("Example")) {
    register part
    Code (Java):

    getServer().getMessenger().registerIncomingPluginChannel(this, "ChannelName", new PluginMessagesHandler());
    Thanks in advance!
  2. Maybe use Sockets to make connection between servers?
  3. Ok thanks!
  4. U r welcome.;)
    • Like Like x 1