Bukkit Plugin Exploding Arrow -


i have bukkit plugin want arrows explode. have piece of code:

 public void arrowhit(projectilehitevent e)       {         if (((e.getentity() instanceof arrow)) &&            ((e.getentity().getshooter() instanceof player)))         {           player shooter = (player)e.getentity().getshooter();              double x = e.getentity().getlocation().getx();             double y = e.getentity().getlocation().gety();             double z = e.getentity().getlocation().getz();             e.getentity().getworld().createexplosion(x, y, z, 2.0f, false,   false);          } 

at bottom of main class. , doesnt work. care explain?

first, should make sure have registered listener in onenable() method! example:

public void onenable() {     this.getserver().getpluginmanager().registerevents(this, plugin); } 

once done, check if have @eventhandler annotation before event.

you can add priority! example:

@eventhandler(priority = eventpriority.high) public void arrowhit(projectilehitevent e) {     if (e.getentity() instanceof arrow && e.getentity().getshooter() instanceof player) {         player shooter = (player) e.getentity().getshooter();          double x = e.getentity().getlocation().getx();         double y = e.getentity().getlocation().gety();         double z = e.getentity().getlocation().getz();         e.getentity().getworld().createexplosion(x, y, z, 2.0f, false,   false);     } } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -