Solved What am I doing wrong - listener/event

Discussion in 'Plugin Development' started by unrealdesign, Jun 15, 2014.

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

    unrealdesign

    Okay so I'm baffled what I'm doing wrong.. It seems as though sendMessage(String message) isn't working for me in some cases.

    I have a event registered, PlayerLoginEvent to be exact, and I have some code in it. I get the player and I add him to an array. Sure that works. But when I try to send that player to a message it doesn't work. What the fuck?

    So again, I can manipulate the player, add him to an array just fine, but when I do p.sendMessage(String message) I get no errors and nothing works. I've tried it with just the message and it acts like the listener isn't even running. Soon as I do with just adding him to an array it works.

    What am I doing wrong?
     
  2. Offline

    amhokies

    Posting your code would probably enable us to help you better.
     
  3. Offline

    unrealdesign

    I mean, I have thousands of lines of code so a lot of it is unimportant. I tried to make it concise in what you would need.

    UPlayerLoginEvent
    Code:java
    1. package org.fragzone.unrealmmo.bukkit.events;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerLoginEvent;
    8. import org.fragzone.unrealmmo.bukkit.IntroManager;
    9. import org.fragzone.unrealmmo.bukkit.MainClass;
    10. import org.fragzone.unrealmmo.bukkit.UPlayerManager;
    11. import org.fragzone.unrealmmo.bukkit.player.UPlayer;
    12.  
    13. public class UPlayerLoginEvent implements Listener
    14. {
    15. private MainClass plugin;
    16.  
    17. public UPlayerLoginEvent(MainClass plugin)
    18. {
    19. System.out.println("SHOULD BE ENABLED!!!!");
    20. }
    21.  
    22. @EventHandler
    23. public void playerLogin(PlayerLoginEvent e)
    24. {
    25. final Player p = e.getPlayer();
    26. p.sendMessage("WELCOME!");
    27. UPlayer up = UPlayerManager.getInstance().login(p);
    28. up.sendMessage("WELCOME!");
    29.  
    30.  
    31. if(!up.hasPlayedBefore())
    32. {
    33. p.sendMessage("Starting intro");
    34. IntroManager.getInstance().createIntro(up);
    35. }
    36. else if(!up.isIntroFinished())
    37. {
    38. p.sendMessage("Starting intro");
    39. IntroManager.getInstance().createIntro(up);
    40. }
    41. else
    42. {
    43. p.sendMessage("Intro disabled");
    44. }
    45.  
    46. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
    47. {
    48.  
    49. @Override
    50. public void run() {
    51. p.sendMessage("HEYYY");
    52.  
    53. }
    54.  
    55. }, 40);
    56. }
    57. }
    58.  

    MainClass
    Code:java
    1. public void onEnable()
    2. {
    3. ConfigManager.getInstance().setup(this);
    4. DBManager.getInstance().setup(this);
    5. UPlayerManager.getInstance().setup();
    6.  
    7. AbilityManager.getInstance().setup(this);
    8. RPGClassManager.getInstance().setup(this);
    9. IntroManager.getInstance().setup();
    10.  
    11.  
    12. PluginManager pm = getServer().getPluginManager();
    13. pm.registerEvents(new UPlayerLoginEvent(this), this);
    14. pm.registerEvents(new UPlayerChatEvent(), this);
    15.  
    16. CommandController.registerCommands(this, new TestingCommands());
    17.  
    18. getLogger().info("[UnrealMMO] has successfully been enabled.");
    19.  
    20. Player p;
    21. p.
    22. }
    23.  
    24. public void onDisable()
    25. {
    26. getLogger().info("[UnrealMMO] has successfully been disabled.");
    27. }
    28.  
    29. public static MainClass getInstance()
    30. {
    31. return (MainClass) Bukkit.getPluginManager().getPlugin("UnrealMMO");
    32. }
     
  4. Offline

    es359



    Try using
    Code:java
    1. public void onPlayerJoin(PlayerJoinEvent event){
    2.  
    3. }
    4.  
     
  5. Offline

    unrealdesign

    That's the exact same thing except you changed the variable name. How would that help?
     
  6. unrealdesign No he didn't, he changed it to a PlayerJoinEvent too. Login is when they try to connect to the server, join is when they actually join.
     
  7. Offline

    unrealdesign

    Omg that makes so much sense. It has enough information to add them to an array, but not do most methods. I can't test it now but I'm positive it will work. Thanks!
     
    AdamQpzm likes this.
Thread Status:
Not open for further replies.

Share This Page