Registering an event from another class

Discussion in 'Plugin Development' started by CBaer4848, Aug 6, 2014.

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

    CBaer4848

    I was wondering on how I could register an event from another class. The class name is called InventoryClick, and when the player clicks in the inventory, the event cancels. I was wondering how I could register it to my main class :p Thanks.
     
  2. Offline

    Forseth11

    Code:java
    1. this.getServer().getPluginManager().registerEvents(new CLASS(), this);
     
  3. Offline

    KaitouKidFTW

    This is how I normally do it.

    Code:java
    1. public void onEnable(){
    2.  
    3. PluginManager pm = Bukkit.getPluginManager();
    4.  
    5. pm.registerEvents(new PlayerInteract(), this);
    6.  
    7. }


    And have this in your other class. If you want to access things from the main class through other class.

    Code:java
    1. private MainClass plugin;
    2.  
    3. public InventoryClick(MainClass plugin){
    4. this.plugin = plugin;
    5.  
    6. }
     
Thread Status:
Not open for further replies.

Share This Page