For(){} Dont work in Events?

Discussion in 'Plugin Development' started by Kingzuck, Mar 6, 2014.

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

    Kingzuck

    Hey Guys,

    today i tested to spawn 40Chicken with the for() function in the EntityShootBowEvent (But i tested other Events, too)...
    In no Event it works but per Command it works...why?

    Code:java
    1. for(int i = 0;i<40;i++){
    2.  
    3. el.getWorld().spawnCreature(el,CreatureType.CHICKEN);
    4. }
    5.  
    6. //el = a Location


    I hope you can help me....Btw sorry for my bad english :(
     
  2. Offline

    naorpeled

    I think its: el.getWorld().spawnEntity(EntityType.CHICKEN , el);

    if that doesnt work try el, EntityType.CHICKEN
     
  3. Offline

    Barinade

    You didn't register events? Also, world.spawn(location, entityclass) is the new (non-deprecated) method

    Deprecation means it's advised not to use due to the possibility of it doing something bad, or because there's an alternative method that is better to use. The deprecated methods are kept to prevent plugins from breaking.
     
  4. Offline

    Kingzuck

    I register my events :p
    If i use my code per Command it works fine but it is in a Event it doesnt work :/
    (It doesent work with sendMessage too.., also CreatureType is not the error...)

    Ps. thanks for the new method :)
     
  5. Offline

    Desle

    Kingzuck
    Does your event event trigger.. or..?
     
  6. Offline

    Garris0n

    spawnEntity is not deprecated either.
     
  7. Offline

    Kingzuck

    Yes....
     
  8. Offline

    Barinade

    Show the entire event code block please.
     
  9. Offline

    qlimax5000

    Code:java
    1. for(int i = 0;i<40;i++){
    2. el.getWorld().spawn(el,Chicken.class);
    3. }
     
  10. Offline

    Desle

  11. Offline

    qlimax5000

    Desle
    What? I'm not the guys who made the thread... i Solved it...
     
    Desle likes this.
  12. Offline

    Barinade

    Give alternative method, consider it solves
    Best
     
  13. Offline

    qlimax5000

    Barinade
    Well, that's what i use and it works, so unless he cocked up somewhere else and didn't post everything i can't do anything.
    He probably just forgot to add @EventHandler tho...
     
Thread Status:
Not open for further replies.

Share This Page