Extending the Effects
Class Effect
The Effect
class has parameters such as its conditions and the filter that it will carry, you can create your own filters as well as conditions or else directly pass it a predefined filter or conditions.
Packages and Imports
Annotation@EffectName
:
@EffectName
:The SpawnParticlesEffect
class is annotated with @EffectName
, with a name parameter equal to "spawn_particles". This suggests that the instance of this class represents an effect involving particle generation in the game.
Class Declaration:
SpawnParticlesEffect
extends the Effect
class, meaning that it inherits its functionality and can have additional specific behavior.
Class Attributes:
The class has two private and final
attributes called particle
and amount
. particle is of type Particle (enum) and amount is an integer representing the number of particles to be generated. You can implement your own attributes
depending on the use you will give to this effect.
Constructor:
The class has a constructor that takes a particle
name as a string (particle
) and the number of particles (amount
). Converts the string particle to a Particle enumeration value and assigns the corresponding values to the particle
and amount attributes.
Methoddispatch
:
dispatch
:This overridden (@Override
) method belongs to the Effect
base class. It is responsible for the execution of the effect. If player
is not null, invokes the spawnParticle
method in the player world, generating particles of the type and quantity specified in the class attributes.
In short, this class represents an effect that generates particles at a player's location in the game when activated. Specific information about the type and number of particles is set by the constructor when instantiating the class.
Last updated