Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE on PlayerInteractEvent in RpgEntities #148

Open
Lochnair opened this issue Jun 17, 2013 · 0 comments
Open

NPE on PlayerInteractEvent in RpgEntities #148

Lochnair opened this issue Jun 17, 2013 · 0 comments

Comments

@Lochnair
Copy link

How to reproduce:
Right-click a block without holding anything

Fix:
Simply changing the method from

@EventHandler
    public void onplayerInteract(PlayerInteractEvent event){
        if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
            if(event.getItem().getTypeId() == Material.STICK.getId()){
                Location l = event.getClickedBlock().getLocation().add(0, 1, 0);
                RpgEntities.em.spawnRpgEntity(l, EntityType.WOLF);
            }
        }
    }

To this

@EventHandler
    public void onplayerInteract(PlayerInteractEvent event){
        if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
            if(event.getItem() != null && event.getItem().getTypeId() == Material.STICK.getId()){
                Location l = event.getClickedBlock().getLocation().add(0, 1, 0);
                RpgEntities.em.spawnRpgEntity(l, EntityType.WOLF);
            }
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant