Inventory Click Event Help

Discussion in 'Plugin Development' started by AXCoding, Jul 18, 2014.

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

    AXCoding

    Hi, I'm writing a plugin that doesn't allow modifications or moving of the inventory, and I just can't seem to see why this code won't work... Any help would be greatly appreciated :).
    Code:java
    1. package me.JasonBourne685.AntiModifyInventory;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.inventory.InventoryClickEvent;
    10. import org.bukkit.plugin.PluginDescriptionFile;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. public class AntiModifyInventory extends JavaPlugin implements Listener {
    14.  
    15. public final Logger logger = Logger.getLogger("Minecraft");
    16. public static AntiModifyInventory plugin;
    17. @Override
    18. public void onDisable() {
    19. PluginDescriptionFile pdfFile = this.getDescription();
    20. this.logger.info(pdfFile.getName() + " has been DISABLED!");
    21. }
    22.  
    23. @Override
    24. public void onEnable() {
    25. PluginDescriptionFile pdfFile = this.getDescription();
    26. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has been ENABLED!");
    27. getConfig().options().copyDefaults(true);
    28. saveConfig();
    29. }
    30. @EventHandler
    31. public void onInvClick(InventoryClickEvent event)
    32. {
    33. Player p = (Player) event.getWhoClicked();
    34. p.sendMessage(ChatColor.GREEN + "[AntiModifyInventory] This is a test!");
    35. if (event.getWhoClicked().hasPermission("AntiModifyInventory.bypass")){
    36. event.setCancelled(true);
    37. }
    38. }
    39.  
    40. }
    41.  

    _LB if you can help me that would be great :D
     
  2. Offline

    Gater12

  3. Offline

    _LB

    As Gater12 pointed out you simply forgot to register your events ;)
     
  4. Offline

    AXCoding

    Thanks so much Gater12 I'm such a noob forgetting to register the event. Oh and _LB
     
Thread Status:
Not open for further replies.

Share This Page