I wonder why my events don't work! I registered them!

Discussion in 'Plugin Development' started by n31ln3t, Apr 6, 2013.

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

    n31ln3t

    Hello,
    My aim is to make my bukkit plugin say hi to every member who just joined. I've used the events & I think I've registered them, please have a look, code is down below.

    http://pastebin.com/Dbhf39UU
     
  2. Offline

    MrSparkzz

    n31ln3t
    Change your onEnable() method to this
    Code:java
    1.  
    2.  
    3. public void onEnable(){
    4. PluginDescriptionFile pdfFile = this.getDescription();
    5.  
    6. getServer().getPluginManager().registerEvents(this, this);
    7.  
    8. this.logger.info(pdfFile.getName()+" version "+pdfFile.getVersion() + " has been enabled!");
    9. }
    10.  
    11.  

    And you might need to change this
    Code:java
    1.  
    2. public class ServerKits extends JavaPlugin{
    3.  

    to
    Code:java
    1.  
    2. public class ServerKits extends JavaPlugin implements Listener {
    3.  
     
  3. Offline

    n31ln3t

    Hello,

    I heart you! Thanks!

    Do you know how to make it detects when the player joins for the first time?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  4. Offline

    MrSparkzz

    n31ln3t
    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerLogin(PlayerJoinEvent event){
    4. Player joinedPlayer = event.getPlayer();
    5.  
    6. if (!(joinedPlayer.hasPlayedBefore())) {
    7. // code for player's first join
    8. }
    9.  
    10. joinedPlayer.sendMessage("hi!");
    11. }
    12.  
     
  5. Offline

    n31ln3t

    Thank you so much, you've saved me hours! So I can work on my plugin now! :D I am grateful
     
Thread Status:
Not open for further replies.

Share This Page