Beginner Help

Discussion in 'Plugin Development' started by Raggarcowboy, Sep 9, 2012.

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

    Raggarcowboy

    Hi everybody! I am so new to plugin development, I can't even make an onPlayerLogin event.
    I read some of the plugin tutorial on the bukkit wiki. And I got the onEnable() and onDisable to work *yay*. But when I tried to register an event (onPlayerLogin) I just couldn't get it to work. Here's my code, what do I do wrong?
    Code:
    package me.raggarcowboy.TestPlugin;
     
    import org.bukkit.plugin.java.JavaPlugin;
    import java.util.logging.Logger;
     
    public class TestPlugin extends JavaPlugin {
        @Override
        public void onEnable() {
            getLogger().info("TestPlugin enabled");
            getServer().getPluginManager().registerEvents(new StartMessage(), this);
        }
       
        @Override
        public void onDisable() {
            getLogger().info("TestPlugin disabled");
        }
    }
    Code:
    package me.raggarcowboy.TestPlugin;
     
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerLoginEvent;
     
    public class StartMessage implements Listener {
        @EventHandler
        public void onPlayerLogin(PlayerLoginEvent event) {
            event.getPlayer().sendMessage("Welcome!");
        }
    }
    Thank you very much for at least viewing this thread! :D
     
  2. Offline

    Assult

    Dont use playerLoginEvent, use PlayerJoinEvent
     
    Raggarcowboy likes this.
  3. Offline

    ZeusAllMighty11

    PlayerLoginEvent fires before the player is actually in the server and loaded. Login event is what happens when the player is logging in...

    As said above, use join event
     
    Raggarcowboy likes this.
Thread Status:
Not open for further replies.

Share This Page