Event not work ?!

Discussion in 'Plugin Development' started by Kingzuck, Apr 22, 2012.

Thread Status:
Not open for further replies.
  1. Hey,

    I will learn write Plugins, now i have my first Problem the Events not Work.

    My Class:

    Tut:
    Code:
    package me.False.Tut;
     
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
     
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Tut extends JavaPlugin {
     
        public void OnEnabled() {
            new Tutlistener(this);
            System.out.print("[Tut]Erfolgreich geladen");
        }
     
        public void OnDisabled() {
            System.out.print("[Tut]Erfolgreich deladen");
        }
     
        public boolean onCommand(CommandSender sender, Command cmd,
                String commandLabel, String[] args) {
            if (sender instanceof Player) {
                Player p = (Player) sender;
                if (cmd.getName().equalsIgnoreCase("Test")) {
                    p.sendMessage("Test, Its work!");
                    return true;
                }
               
            }
     
            return false;
        }
    }
    
    Tutlistener :
    Code:
    package me.False.Tut;
     
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerMoveEvent;
     
    public class Tutlistener implements Listener {
     
        public Tutlistener(Tut plugin) {
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
        }
     
        @EventHandler
        public void OnPlayerMove(PlayerMoveEvent e) {
            e.getPlayer().damage(2);
        }
     
        @EventHandler
        public void OnPlayerJoin(PlayerJoinEvent e) {
            e.getPlayer().sendMessage("test");
     
        }
    }
    
    PlayerMove and PlayerJoinEvent not work, why ?
     
  2. it's onEnable and onDisable, not the way you have it.
     
  3. Offline

    VeryBIgCorp

    That, and this isn't C#, so methods AreNotNamedLikeThis. They areNamedLikeThis. It just makes it easier to peruse the code to differentiate between methods and classes.
     
  4. Sure it's always better use such standards but it's not that you are forced to use them all the time.
     
  5. I've done it like in the tutorial from Bukkitwiki ...
    Where is the error?
     
  6. Offline

    dsmyth1915

    The error is that OnEnable and OnDisable, should be onEnable and onDisable.
     
    Kingzuck likes this.
  7. Like I said already.
     
  8. Offline

    dsmyth1915

    From what I can see English is not his best language. Its better to spell everything out, but not do it for them.
     
  9. Its work now.
    But it´s exist a Tutotiral for Creaste/Loader/Set yml ?
     
  10. Offline

    dsmyth1915

Thread Status:
Not open for further replies.

Share This Page