Class EffectComponent

java.lang.Object
studio.magemonkey.fabled.dynamic.EffectComponent
Direct Known Subclasses:
ConditionComponent, CustomEffectComponent, MechanicComponent, TargetComponent, TriggerComponent

public abstract class EffectComponent extends Object
A component for dynamic skills which takes care of one effect
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Child components
    protected final Settings
    The preview settings for the component
    protected final Settings
    The settings for the component
    protected DynamicSkill
    Parent class of the component
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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 component
    abstract 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 targets
    protected String
    filter(org.bukkit.entity.LivingEntity caster, org.bukkit.entity.LivingEntity target, String text)
     
    Retrieves the config key for the component
    abstract String
     
    protected double
    getNum(org.bukkit.entity.LivingEntity caster, String key, double fallback)
    Retrieves a numerical value while using non-numerical values as keys for the cast data.
    Retrieves the settings of the dynamic component
    protected PlayerSkill
    getSkillData(org.bukkit.entity.LivingEntity caster)
    Gets the skill data for the caster
    abstract ComponentType
    Retrieves the type of the component
    boolean
     
    protected boolean
    Checks whether the last component passed or not
    void
    load(DynamicSkill skill, studio.magemonkey.codex.mccore.config.parse.DataSection config)
    Loads component data from the configuration
    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
    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 (see isPreviewEnabled()), and adds their onPreviewStop Runnables to the provided List.
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • children

      public final List<EffectComponent> children
      Child components
    • settings

      protected final Settings settings
      The settings for the component
    • preview

      protected final Settings preview
      The preview settings for the component
    • skill

      protected DynamicSkill skill
      Parent class of the component
  • Constructor Details

    • EffectComponent

      public EffectComponent()
  • Method Details

    • getKey

      public abstract String getKey()
    • getType

      public abstract ComponentType 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 skill
      key - key of the value to grab
      level - level of the skill
      fallback - default value for the attribute
      Returns:
      the value with attribute modifications if applicable
    • getNum

      protected double getNum(org.bukkit.entity.LivingEntity caster, String key, double fallback)
      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 skill
      key - key of the value
      fallback - 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 skill
      level - level of the skill
      targets - targets to execute on
      force - 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

      protected PlayerSkill getSkillData(org.bukkit.entity.LivingEntity caster)
      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

      protected String filter(org.bukkit.entity.LivingEntity caster, org.bukkit.entity.LivingEntity target, String text)
    • 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 skill
      level - level of the skill
      targets - 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 skill
      level - level of the skill
      targets - targets to execute on
      force - 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)
      Starts the component's preview effects. Removal of any registered listeners, tasks, entities, or other temporary effects should be included in a Runnable added to the provided List.
      Parameters:
      onPreviewStop - List of Runnables to add to
      caster - caster reference
      level - the level of the skill to preview for
      targetSupplier - targets to preview on
    • 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 (see isPreviewEnabled()), and adds their onPreviewStop Runnables to the provided List.
      Parameters:
      onPreviewStop - List of Runnables to add to
      caster - caster reference
      level - the level of the skill to preview for
      targetSupplier - targets to preview on
    • 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 component
      config - config data to load from
    • getSettings

      public Settings getSettings()
      Retrieves the settings of the dynamic component
      Returns:
      settings of the dynamic component
    • getInstanceKey

      public String getInstanceKey()
      Retrieves the config key for the component
      Returns:
      config key of the component