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
Post a Comment