Package studio.magemonkey.fabled.dynamic
Class EffectComponent
java.lang.Object
studio.magemonkey.fabled.dynamic.EffectComponent
- Direct Known Subclasses:
ConditionComponent
,CustomEffectComponent
,MechanicComponent
,TargetComponent
,TriggerComponent
A component for dynamic skills which takes care of one effect
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal List
<EffectComponent> Child componentsprotected final Settings
The preview settings for the componentprotected final Settings
The settings for the componentprotected DynamicSkill
Parent class of the component -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanUp
(org.bukkit.entity.LivingEntity caster) protected void
doCleanUp
(org.bukkit.entity.LivingEntity caster) boolean
execute
(org.bukkit.entity.LivingEntity caster, int level, List<org.bukkit.entity.LivingEntity> targets) Executes the componentabstract boolean
execute
(org.bukkit.entity.LivingEntity caster, int level, List<org.bukkit.entity.LivingEntity> targets, boolean force) Executes the component (to be implemented)protected boolean
executeChildren
(org.bukkit.entity.LivingEntity caster, int level, List<org.bukkit.entity.LivingEntity> targets, boolean force) Executes the children of the component using the given targetsprotected String
Retrieves the config key for the componentabstract String
getKey()
protected double
Retrieves a numerical value while using non-numerical values as keys for the cast data.Retrieves the settings of the dynamic componentprotected PlayerSkill
getSkillData
(org.bukkit.entity.LivingEntity caster) Gets the skill data for the casterabstract ComponentType
getType()
Retrieves the type of the componentboolean
protected boolean
Checks whether the last component passed or notvoid
load
(DynamicSkill skill, studio.magemonkey.codex.mccore.config.parse.DataSection config) Loads component data from the configurationdouble
parseValues
(org.bukkit.entity.LivingEntity caster, String key, int level, double fallback) Retrieves an attribute value while applying attribute data if enabled and a player is using the skillvoid
playChildrenPreviews
(List<Runnable> onPreviewStop, org.bukkit.entity.Player caster, int level, Supplier<List<org.bukkit.entity.LivingEntity>> targetSupplier) Starts the preview effects of children components with previews enabled (seeisPreviewEnabled()
), and adds their onPreviewStopRunnable
s to the providedList
.void
playPreview
(List<Runnable> onPreviewStop, org.bukkit.entity.Player caster, int level, Supplier<List<org.bukkit.entity.LivingEntity>> targetSupplier) Starts the component's preview effects.void
save
(studio.magemonkey.codex.mccore.config.parse.DataSection config) Saves the component and its children to the config
-
Field Details
-
children
Child components -
settings
The settings for the component -
preview
The preview settings for the component -
skill
Parent class of the component
-
-
Constructor Details
-
EffectComponent
public EffectComponent()
-
-
Method Details
-
getKey
-
getType
Retrieves the type of the component- Returns:
- component type
-
isPreviewEnabled
public boolean isPreviewEnabled()- Returns:
- true if the component or its children should play their preview effects, or false otherwise
-
parseValues
public double parseValues(org.bukkit.entity.LivingEntity caster, String key, int level, double fallback) Retrieves an attribute value while applying attribute data if enabled and a player is using the skill- Parameters:
caster
- caster of the skillkey
- key of the value to grablevel
- level of the skillfallback
- default value for the attribute- Returns:
- the value with attribute modifications if applicable
-
getNum
Retrieves a numerical value while using non-numerical values as keys for the cast data. If the value doesn't exist, this will return the default value. If it is a key that doesn't have an attached value, it will return 0. Otherwise, it will return the appropriate value.- Parameters:
caster
- the caster of the skillkey
- key of the valuefallback
- fallback value in case the settings don't have it- Returns:
- the settings value or, if not a number, the cast data value
-
lastPassed
protected boolean lastPassed()Checks whether the last component passed or not- Returns:
- true if passed, false otherwise
-
executeChildren
protected boolean executeChildren(org.bukkit.entity.LivingEntity caster, int level, @NotNull List<org.bukkit.entity.LivingEntity> targets, boolean force) Executes the children of the component using the given targets- Parameters:
caster
- caster of the skilllevel
- level of the skilltargets
- targets to execute onforce
- whether skill should be forced- Returns:
- true if executed, false if conditions not met
-
cleanUp
public void cleanUp(org.bukkit.entity.LivingEntity caster) -
doCleanUp
protected void doCleanUp(org.bukkit.entity.LivingEntity caster) -
getSkillData
Gets the skill data for the caster- Parameters:
caster
- caster of the skill- Returns:
- skill data for the caster or null if not found
-
filter
-
execute
public boolean execute(org.bukkit.entity.LivingEntity caster, int level, List<org.bukkit.entity.LivingEntity> targets) Executes the component- Parameters:
caster
- caster of the skilllevel
- level of the skilltargets
- targets
-
execute
public abstract boolean execute(org.bukkit.entity.LivingEntity caster, int level, List<org.bukkit.entity.LivingEntity> targets, boolean force) Executes the component (to be implemented)- Parameters:
caster
- caster of the skilllevel
- level of the skilltargets
- targets to execute onforce
- whether skill should be forced- Returns:
- true if executed, false if conditions not met
-
playPreview
public void playPreview(List<Runnable> onPreviewStop, org.bukkit.entity.Player caster, int level, Supplier<List<org.bukkit.entity.LivingEntity>> targetSupplier) -
playChildrenPreviews
public void playChildrenPreviews(List<Runnable> onPreviewStop, org.bukkit.entity.Player caster, int level, Supplier<List<org.bukkit.entity.LivingEntity>> targetSupplier) Starts the preview effects of children components with previews enabled (seeisPreviewEnabled()
), and adds their onPreviewStopRunnable
s to the providedList
. -
save
public void save(studio.magemonkey.codex.mccore.config.parse.DataSection config) Saves the component and its children to the config- Parameters:
config
- config to save to
-
load
public void load(DynamicSkill skill, studio.magemonkey.codex.mccore.config.parse.DataSection config) Loads component data from the configuration- Parameters:
skill
- owning skill of the componentconfig
- config data to load from
-
getSettings
Retrieves the settings of the dynamic component- Returns:
- settings of the dynamic component
-
getInstanceKey
Retrieves the config key for the component- Returns:
- config key of the component
-