OnPlayerItem(PlayerItemEvent event) Doesn't Fire

Discussion in 'Plugin Development' started by Gandalf, Feb 27, 2011.

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


    I have tried this, and it does not fire. I have put println statements and it never goes into onPlayerItem when items are used.

    Is this a bug in craft bukkit?

    Relevant Code(I have registered the event in my main file):

    public class GriefAlertRPlayerListener extends PlayerListener {
        private final GriefAlertR plugin;
        private ItemManager method=new ItemManager();
        public GriefAlertRPlayerListener(GriefAlertR instance) {
            plugin = instance;
        public void onPlayerItem (PlayerItemEvent event){
            Player player = event.getPlayer();;
                if(ItemManager.isUseWatched(event.getItem().getTypeId())) {
                    GriefAction data = ItemManager.getOnUseWatchList().get(event.getItem().getTypeId());
                    doWork(player,data,"Used:","use of");//private helper method, not shown here
  2. Offline


    try the @Override annotation?

    Because for me, registering PLAYER_ITEM events and this works:
        public void onPlayerItem(PlayerItemEvent event) {
  3. Offline


    It compiles but doesn't fire....what does the @Override do?
  4. Offline


    and it could be nice for you to show me the bits where you register your event, too :3
    The annotation isn't the problem here (read more about annotations here

    try to right-click on some grass while holding an item, such as a shovel
  5. Offline


    I did, no events fire.

    Here let me show you my main class...

    This is my plugin btw, <Edit by Moderator: Redacted mediafire url>

    pm.registerEvent(Event.Type.BLOCK_PLACED, this.blockListener,Event.Priority.Normal, this);
    pm.registerEvent(Event.Type.BLOCK_INTERACT, this.blockListener,Event.Priority.Normal, this);
    pm.registerEvent(Event.Type.BLOCK_BREAK, this.blockListener,Event.Priority.Normal, this);
    pm.registerEvent(Event.Type.PLAYER_ITEM, this.playerListener,Event.Priority.Normal, this);
    Last edited by a moderator: Dec 15, 2016
  6. Offline


    Uhm, you sure your plugin is even loaded?

    because i get this in the log when i tried to load your plugin:

    01:09:06 [INFO] Attempting Creation of the GriefAlertr Log File
    01:09:06 [INFO] [GriefAlertR] is unloaded.
    01:09:06 [INFO] Done (0,060s)! For help, type "help" or "?"
  7. Offline


    Yes, it was loaded, I figured it out man, it was a misplaced constructor oddly enough. Thanks for all your help.
  8. Offline


    No problem!
Thread Status:
Not open for further replies.

Share This Page