Projectile damage event and scheduler

Discussion in 'Plugin Development' started by beatcomet, Jul 20, 2011.

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

    beatcomet

    Hi guys, I need some help here, The problem is the following :
    I'm making a plugin that uses archery, and I don't know which event should I use,
    EntityDamageByEntity or EntityDamageByProjectile, because they both may be called.

    The second question is how to use the scheduler to create a delay (20 ticks = 1 second, this is all I know).
    Thanks :)
     
  2. Offline

    DrBowe

    1) It really all depends on what exactly you wish to do with the plugin. Are you going to be dealing with special types of arrows, or simple manipulations of damage?

    2) (after creating a scheduler)
    Code:java
    1.  
    2. scheduler.scheduleSyncDelayedTask(Plugin yourPlugin, new Runnable(){
    3. public void run(){
    4. //do delayed stuff here
    5. }
    6. },<delay>);
    7.  


    So if if I wanted to delay a certain boolean from changing for 5 seconds:
    Code:java
    1.  
    2. scheduler.scheduleSyncDelayedTask(plugin, new Runnable(){
    3. public void run(){
    4. certainBoolean = false;
    5. }
    6. }, 100);
    7.  
     
  3. Offline

    bleachisback

    Also when using the scheduler, make sure any variables you want to use are declared as final.
     
  4. Offline

    DrBowe

    Well, be careful with this though. Since the moment you declare it final, it is not possible to change that variable. So if you were using a final location of a player, and delayed it by 5 seconds, it would use the location from 5 seconds ago (as opposed to the location of the player right then at that moment)
     
  5. Offline

    bleachisback

    that's why you declare the player final since it isn't going to change =3=
     
  6. Offline

    DrBowe

    And if they're a schizophrenic? :p
     
  7. Offline

    bleachisback

    Then they probably shouldn't be playing minecraft.
     
  8. Offline

    DrBowe

    Touché.

    EDIT:
    Imagine it...
    Amazing architect one night, destructive griefer the next.

    I'd imagine it would be a vicious cycle.
     
  9. Offline

    beatcomet

    I understand about the first one,
    The reason I need to use the scheduler is because I want to make a dealy between 2 arrow shots.

    anyone pleas?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
Thread Status:
Not open for further replies.

Share This Page