Class ProjectileScript<T extends AProjectile>
java.lang.Object
me.deecaad.weaponmechanics.weapon.projectile.ProjectileScript<T>
- Type Parameters:
T- The projectile type the script expects.
A projectile script is a class that can be attached to a projectile. The script can listen for
projectile related events (colliding with blocks, for example). The
AProjectile class
stores a list of scripts, and each script is updated for each event.
In order for you to attach a script to a projectile, you need to register your
ProjectileScriptManager (which handles which projectiles to use) using
ProjectileSpawner.addScriptManager(ProjectileScriptManager).
While you can use bukkit events and scripts interchangeably, scripts have the added advantage of better OOP and less overhead from the EventHandler. Scripts may also allow better control over when you want code to execute.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.plugin.PlugingetOwner()booleanEach time a projectile iterates through its list of scripts, it will check this method AFTER calling any api methods [onStart(),onTickStart(),onTickEnd(),onEnd(),onCollide(RayTraceResult)].booleanEach time a projectile iterates through its list of scripts, it will check this method BEFORE calling any api methods [onStart(),onTickStart(),onTickEnd(),onEnd(),onCollide(RayTraceResult)].voidonCollide(me.deecaad.core.utils.ray.RayTraceResult hit) Called when the projectile collides with a block or living entity.voidonEnd()Called when the projectile is removed.voidonStart()Called while the projectile is spawning.voidCalled towards the end ofAProjectile.tick().voidCalled towards the beginning ofAProjectile.tick().
-
Field Details
-
projectile
-
removeScript
protected boolean removeScript -
removeProjectile
protected boolean removeProjectile
-
-
Constructor Details
-
ProjectileScript
-
-
Method Details
-
getOwner
@NotNull public org.bukkit.plugin.Plugin getOwner() -
getProjectile
-
isRemoveScript
public boolean isRemoveScript()Each time a projectile iterates through its list of scripts, it will check this method BEFORE calling any api methods [onStart(),onTickStart(),onTickEnd(),onEnd(),onCollide(RayTraceResult)]. This can be used to remove a script from a projectile without removing the projectile.- Returns:
truewill remove the script from the projectile.
-
isRemoveProjectile
public boolean isRemoveProjectile()Each time a projectile iterates through its list of scripts, it will check this method AFTER calling any api methods [onStart(),onTickStart(),onTickEnd(),onEnd(),onCollide(RayTraceResult)]. This can be used to completely remove a projectile.- Returns:
truewill remove the projectile.
-
onStart
public void onStart()Called while the projectile is spawning. It is guaranteed that this method will be called before all other methods in this class. This method is called after the projectile is shot, so getting the shooter (for WeaponProjectile) is a safe operation. -
onTickStart
public void onTickStart()Called towards the beginning ofAProjectile.tick(). This method probably should be used instead ofonTickEnd()when you are modifying projectile values (Changing speed/location, for example). -
onTickEnd
public void onTickEnd()Called towards the end ofAProjectile.tick(). This method probably should be used instead ofonTickStart()when you only want to read the result of a tick method (See how a projectile moved, for example). -
onEnd
public void onEnd()Called when the projectile is removed. -
onCollide
public void onCollide(@NotNull me.deecaad.core.utils.ray.RayTraceResult hit) Called when the projectile collides with a block or living entity.- Parameters:
hit- The non-null ray trace result of block or living entity.
-