Shooting Arrows Gives an Error

Discussion in 'Plugin Development' started by MoeMix, Feb 4, 2014.

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

    MoeMix

    Hi guys, so I set up an entitydamagebyentityevent and the plugin works and everything but now, whenever an arrow hits an entity it throws an error... here is how it looks like:

    http://pastebin.com/phTsbsKD

    And here is the plugin code itself:

    Code:java
    1. public ArrayList<Player> cooldown = new ArrayList<Player>();
    2.  
    3. @EventHandler
    4. public void onsnowballfallevent(EntityDamageByEntityEvent event){
    5. Snowball snowball = (Snowball) event.getDamager();
    6. final Player attacker = (Player) snowball.getShooter();
    7. if(event.getDamager() instanceof Snowball){
    8. if(attacker instanceof Player){
    9. if(!cooldown.contains(attacker)){
    10. Entity e = event.getEntity();
    11. Location l = e.getLocation();
    12. World world = l.getWorld();
    13. EntityType mob = EntityType.SQUID;
    14. world.spawnEntity(l, mob);
    15. world.playEffect(l, Effect.MOBSPAWNER_FLAMES, 20);
    16. cooldown.add(attacker);
    17. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    18. public void run(){
    19. cooldown.remove(attacker);
    20. }
    21. }, 100);
    22.  
    23. }else if(cooldown.contains(attacker)){
    24. event.setCancelled(true);
    25. }
    26. }
    27. }
    28. }
    29. }


    Thanks for checking this out for me!
     
  2. Offline

    Superckl1

  3. You should add a check to see if the entity is a Snowball

    if(event.getDamager() instanceof Snowball){

    //do the rest
     
Thread Status:
Not open for further replies.

Share This Page