Solved Run Events from other classes

Discussion in 'Plugin Development' started by MunchMallow, Nov 9, 2013.

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

    MunchMallow

    Hello everybody.

    First of all, i want to apologize for my English.
    It's not my first language.

    I've began coding some weeks ago, and i absolutely love it!
    But, there is one problem though, that bugs me. :mad:

    I have this really big class, where all my different EventHandlers are in, and it's really messy.
    Is there any possible way i can run all the EventHandlers in each class?

    For example, i have this class called Main, and the class called SpeedBoost.
    And in SpeedBoost there is an EventHandler, that is getting runned
    in the class, Main.

    The reason why i want this, is because all the things get sorted much more!

    I want to appreciate all future comments, for the help!

    This is only an example of a class with many EventHandlers.
    Code:java
    1. package me.MunchMallow.Test;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.event.EventHandler;
    9. import org.bukkit.event.player.PlayerJoinEvent;
    10. import org.bukkit.event.player.PlayerQuitEvent;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. public class Test extends JavaPlugin {
    14.  
    15. private static final Logger log = Logger.getLogger("Minecraft");
    16.  
    17. @Override
    18. public void onEnable() {
    19. log.info(" Enabled!");
    20. }
    21.  
    22. @Override
    23. public void onDisable() {
    24. getLogger().info(" Disabled! :(");
    25. }
    26.  
    27.  
    28.  
    29.  
    30. @EventHandler
    31. public void onJoin(PlayerJoinEvent e) {
    32. Player p = e.getPlayer();
    33. p.sendMessage(ChatColor.GOLD + "Hello.... Remember to....");
    34. p.sendMessage(ChatColor.GOLD + "THROWWWW THE CHEASSEEEEE!");
    35. }
    36.  
    37.  
    38.  
    39.  
    40. @EventHandler
    41. public void onQuit(PlayerQuitEvent e) {
    42. Bukkit.broadcastMessage("NOOO, someone quit!");
    43. }
    44. }
     
  2. Offline

    drtshock

  3. Offline

    MunchMallow

    drtshock likes this.
Thread Status:
Not open for further replies.

Share This Page