Send player to different server

Discussion in 'Plugin Development' started by PikaThieme, Oct 20, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    PikaThieme

    Why does this not work?
    No errors...
    It just doesn't do anything

    Might be handy: https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/

    Code:java
    1.  
    2. public void onEnable() {
    3. getServer().getMessenger().registerOutgoingPluginChannel(this,"Waterfall");
    4. }
    5.  
    6. public void sendPlayerToServer(Playerp,Stringserver){
    7.  
    8.  
    9.  
    10. try{
    11.  
    12. out.writeUTF("Connect");
    13.  
    14. out.writeUTF(server);
    15.  
    16. } catch (Exception e) {
    17.  
    18. e.printStackTrace();
    19.  
    20. }
    21.  
    22. p.sendPluginMessage(this,"Waterfall",b.toByteArray());
    23.  
    24. }
    25.  
     
  2. Offline

    coldguy101

  3. Offline

    PikaThieme

    @coldguy101 I dont really understand what you mean ._.

    Do you mean that I have to have this as well in my code?
    Code:java
    1.  
    2. public class MyPlugin extends JavaPlugin implements PluginMessageListener {
    3. @Override
    4. publicvoid onEnable(){
    5. this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
    6. this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this);
    7. }
    8.  
    9. @Override
    10. public void onPluginMessageReceived(String channel, Player player, byte[] message){
    11. if(!channel.equals("BungeeCord")){
    12. return;
    13. }
    14. ByteArrayDataInput in = ByteStreams.newDataInput(message);
    15. String subchannel = in.readUTF();
    16. }
    17. }
    18.  
     
Thread Status:
Not open for further replies.

Share This Page