Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2013
6,674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. package YOUR.PACKAGE.NAME;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.event.Listener;
  5. import org.bukkit.plugin.Plugin;
  6. import org.bukkit.plugin.java.JavaPlugin;
  7.  
  8.  
  9. public class Main extends JavaPlugin{ //Extending JavaPlugin so that Bukkit knows its the main class...
  10.  
  11. private static Plugin plugin;
  12.  
  13. public void onEnable() {
  14. plugin = this;
  15. registerEvents(this, new Events(), new Both());
  16. getCommand("hi").setExecutor(new Command());
  17. getCommand("hello").setExecutor(new Both());
  18. }
  19.  
  20. public void onDisable() {
  21.  
  22. }
  23.  
  24.  
  25. //Much eaisier then registering events in 10 diffirent methods
  26. public static void registerEvents(org.bukkit.plugin.Plugin plugin, Listener... listeners) {
  27. for (Listener listener : listeners) {
  28. Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
  29. }
  30. }
  31.  
  32. //To access the plugin variable from other classes
  33. public static Plugin getPlugin() {
  34. return plugin;
  35. }
  36.  
  37.  
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement