Sponge Bungee

Hello, I know that this subject has already been treated but I have a problem.

I would like to use channel for send information and receive from bungee.
But I do not get any information.

I have this


import org.spongepowered.api.Game;
import org.spongepowered.api.Platform;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.spec.CommandExecutor;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.game.state.GameStartingServerEvent;
import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
import org.spongepowered.api.network.ChannelBinding.RawDataChannel;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.scheduler.Task;
import com.google.inject.Inject;

@Plugin(id = "test", name = "test", version = "1.0", authors = {
		"THEJean_Kevin" }, description = "test sponge")
public class Test implements CommandExecutor {

	private RawDataChannel channel;
	@Inject
	Game game;
	Task task;
	

		@Listener
	public void startingServer(GameStartingServerEvent e) {
		CommandSpec Cmd = CommandSpec.builder().executor(this).build();
		Sponge.getCommandManager().register(this, Cmd, "Test");
		
		
		channel = game.getChannelRegistrar().createRawChannel(this, "BungeeCord");
	
		}

	@Listener
	public void stoppingServer(GameStoppingServerEvent e) {
		game.getChannelRegistrar().unbindChannel(channel);
	}

	
	@Override
	public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
		channel.sendTo((Player)src, buf -> {
		    buf.writeString("PlayerCount");
		    buf.writeString("ALL");
		});
		
		channel.addListener(Platform.Type.SERVER, (buf, con, side) -> {
		    String subChannel = buf.readString();

		    if (subChannel.equals("PlayerCount")) {
		        String server = buf.readString();
		        int playerCount = buf.readInteger();
		        System.out.println("Player count on server " + server + " is " + playerCount);
		    }
		});
		return CommandResult.success();
	}
}

You need to write UTF, not just String.

Don’t work

@Plugin(id = "test", name = "test", version = "1.0", authors = {
		"THEJean_Kevin" }, description = "test sponge")
public class Test implements CommandExecutor {

	private RawDataChannel channel;
	@Inject
	Game game;
	Task task;
	

		@Listener
	public void startingServer(GameStartingServerEvent e) {
		CommandSpec Cmd = CommandSpec.builder().executor(this).build();
		Sponge.getCommandManager().register(this, Cmd, "test");
		
		
		channel = game.getChannelRegistrar().createRawChannel(this, "BungeeCord");
	
		}

	@Listener
	public void stoppingServer(GameStoppingServerEvent e) {
		game.getChannelRegistrar().unbindChannel(channel);
	}

	
	@Override
	public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
		channel.sendTo((Player)src, buf -> {
		    buf.writeUTF("PlayerCount");
		    buf.writeUTF("ALL");
		});
		
		channel.addListener(Platform.Type.SERVER, (buf, con, side) -> {
		    String subChannel = buf.readUTF();

		    if (subChannel.equals("PlayerCount")) {
		        String server = buf.readUTF();
		        int playerCount = buf.readInteger();
		        System.out.println("Player count on server " + server + " is " + playerCount);
		    }
		});
		return CommandResult.success();
	}
}

the problem is to send information, I tried this but I never get the message on my second account (on the same server, or on another)

channel.sendTo((Player)src, buf -> {
		    buf.writeUTF("Message");
		    buf.writeUTF("MissAmypinke");
		    buf.writeUTF("I'm sPonge");

@pie_flavor Do you know where the problem can come from

No, I don’t.

@pie_flavor Ok i found the problem, it’s the Ip forwarding, when it’s disable no problem, but when I turn to true, No communication with channels