InventoryOpenEvent doesn't fire

Discussion in 'Plugin Development' started by xGhOsTkiLLeRx, Mar 17, 2012.

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

    xGhOsTkiLLeRx

    Hey!

    I got some problems with InventoryOpenEvent
    First: The same code, changed to InventoryCloseEvent works!

    Main class:

    Code:java
    1. public static final Logger log = Logger.getLogger("Minecraft");
    2. private final PasswordProtectInventoryListener inventoryListener = new PasswordProtectInventoryListener(this);
    3.  
    4. ...
    5.  
    6. // Start
    7. public void onEnable() {
    8. // Events
    9. PluginManager pm = getServer().getPluginManager();
    10. pm.registerEvents(inventoryListener, this);
    11. }
    12. ...


    InventoryListener:

    Code:java
    1. package de.xghostkillerx.passwordprotect;
    2.  
    3. import org.bukkit.event.EventHandler;
    4. import org.bukkit.event.Listener;
    5. import org.bukkit.event.inventory.InventoryOpenEvent;
    6.  
    7. public class PasswordProtectInventoryListener implements Listener {
    8. public PasswordProtect plugin;
    9. public PasswordProtectInventoryListener(PasswordProtect instance) {
    10. plugin = instance;
    11. }
    12.  
    13. @EventHandler
    14. public void onInventoryOpen(InventoryOpenEvent event){
    15. PasswordProtect.log.info("Test");
    16. // Player player = (Player) event.getPlayer();
    17. // if (plugin.jailedPlayers.contains(player)) {
    18. //event.setCancelled(true);
    19. //}
    20. }
    21. }


    Does anybody know why I don't get the message, if I open my inventory with "E"?
     
  2. Offline

    dsmyth1915

    what is the point of passwordprotect.log.info on line15. I'd make it log.info("[PassWordProtect]: your message here");
     
  3. Offline

    Milkywayz

    Passwordprotect is the name of one of his classes. It does the same thing except he doesn't have to define the logger in that class that his using
     
  4. Offline

    nisovin

    If you're hoping for that event to fire when a player opens their inventory, it's not gonna work. That event only works when a player opens another inventory, like a chest or dispenser.
     
  5. Offline

    xGhOsTkiLLeRx

    Thanks for the clearing.
    I guess I need Spout ;)
     
Thread Status:
Not open for further replies.

Share This Page