PluginMessageListener isnt working with my class

Discussion in 'Plugin Development' started by rourke750, Apr 27, 2014.

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

    rourke750

    So I have this class:
    Code:java
    1.  
    2. public class PlayerEnteringStarGate implements PluginMessageListener {
    3.  
    4. private StarGateCraft plugin;
    5.  
    6. public PlayerEnteringStarGate(StarGateCraft plugin) {
    7. this.plugin = plugin;
    8. }
    9.  
    10. @Override
    11. public void onPluginMessageReceived(String channel, Player player, byte[] message) {
    12. System.out.println("Messengar ran");
    13. if (!channel.equals("BungeeCord")) {
    14. return;
    15. }
    16. try {
    17. String subchannel = in.readUTF();
    18. if (subchannel.equals("gatecraft")) {
    19. String world = in.readUTF();
    20. final String thisworld = plugin.getConfig().getString("world");
    21. System.out.println("Recieved gatecraft");
    22. System.out.println(thisworld + " " + world);
    23. if (!thisworld.equals(world))
    24. return;
    25. System.out.println("World equals world");
    26. StarGate.setActivePortal(thisworld);
    27. StarGate.startPlasmaAnimation(thisworld);
    28. StarGate.setDialedIntoGate(thisworld);
    29. SerializationClass person = (SerializationClass) objin.readObject();
    30. person.updatedatePlayer(player);
    31. Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
    32.  
    33. @Override
    34. public void run() {
    35. StarGate.resetDest(thisworld);
    36. }
    37.  
    38. }, 720);
    39. }
    40. // TODO Auto-generated catch block
    41. e.printStackTrace();
    42. }
    43. }
    44.  
    45. }
    46.  

    and it is being initialized in my main class like this:
    Code:java
    1.  
    2. public void onEnable(){
    3. PlayerEnteringStarGate othergate = new PlayerEnteringStarGate(this);
    4. this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
    5. this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", othergate);
    6. }
    7.  

    but for some reason when ever I do this:
    Code:java
    1.  
    2. try {
    3. dos.writeUTF("gatecraft");
    4. dos.writeUTF(world);
    5. out.writeObject(new SerializationClass(player));
    6. Bukkit.getOnlinePlayers()[0].sendPluginMessage(plugin, "BungeeCord", baos.toByteArray());
    7. } catch (IOException e) {
    8. // TODO Auto-generated catch block
    9. e.printStackTrace();
    10. }
    11.  

    It never runs the onPluginMessageReceived method. Anyone have any ideas? I know its not being run because I put this statement System.out.println("Messengar ran"); and it never gets triggered.
     
  2. Offline

    TGRHavoc

    rourke750
    Please could you use the
    Code:Java
    1. [syntax=java][/syntax] tags for your code
     
  3. Offline

    rourke750

    done.

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page