Having problems with events

Discussion in 'Plugin Development' started by Th3Rokaz, Jan 15, 2017.

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

    Th3Rokaz

    Hello guys so I just started out and tried to make a join message plugin but it doesnt work idk why. This is my code:

    main:
    Code:
    package me.Rokas.JoinMessage;
    
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class JoinMessage extends JavaPlugin implements Listener {
      
        public void OnEnable() {
            registerEvents();
        }
      
        public void OnDisable() {
          
        }
        public void registerEvents() {
            PluginManager pm = getServer().getPluginManager();
          
            pm.registerEvents(this , this);
        }
        @EventHandler
        public void onPlayerJoinEvent(PlayerJoinEvent event) {
            Player player = event.getPlayer();
            player.sendMessage("Hello");
          
        }
    }
    my plugin.yml
    Code:
    name: JoinMessage
    main: me.Rokas.JoinMessage.JoinMessage
    version: 1.0
    description: A plugin that help with chat and messages
    author: Rokas
    
    idk maybe i did't export it right
     
    Last edited by a moderator: Jan 15, 2017
  2. Offline

    JanTuck

    The OnEnable should start with lowercase same goes with OnDisable.

    onEnable and onDisable.
     
  3. Offline

    Zombie_Striker

    @Th3Rokaz
    Do as @JanTuck recommend, and also refactor your package. Package names should be all lowercase.
     
  4. Offline

    Th3Rokaz

    Thank you guys
     
  5. Offline

    Zombie_Striker

    @Th3Rokaz
    If your problem has been solved, mark this thread as solved.
     
Thread Status:
Not open for further replies.

Share This Page