Class PotionEffectProvider<T>

java.lang.Object
org.skriptlang.skript.bukkit.potion.providers.PotionEffectProvider<T>
Type Parameters:
T - The type providing potion effects.
Direct Known Subclasses:
NullProvider

@Internal public abstract class PotionEffectProvider<T> extends Object
A wrapper for working with objects that provide potion effects.
See Also:
  • Field Details

    • source

      protected final T source
      Source object providing potion effects.
  • Constructor Details

    • PotionEffectProvider

      public PotionEffectProvider(T source)
      Parameters:
      source - The source object providing potion effects.
  • Method Details

    • of

      public static PotionEffectProvider<?> of(Object object, Consumer<String> errorProducer)
      Parameters:
      object - The object to obtain a provider from.
      errorProducer - A consumer to use for printing errors.
      Returns:
      A provider wrapping object. If object is not a known potion provider, errorProducer is invoked and a dummy provider is returned.
    • get

      public abstract Collection<SkriptPotionEffect> get(org.bukkit.potion.PotionEffectType[] potionEffectTypes, PotionEffectProvider.RetrievalState state)
      Obtains specific types of potion effects from this provider.
      Parameters:
      potionEffectTypes - The type of potion effects to obtain.
      state - The type of retrieval to perform.
      Returns:
      All potion effects of potionEffectTypes present on this provider.
    • getAll

      Obtains all potion effects from this provider.
      Parameters:
      state - The type of retrieval to perform.
      Returns:
      All potion effects present on this provider.
    • add

      public abstract void add(org.bukkit.potion.PotionEffect potionEffect)
      Adds a potion effect to this provider.
      Parameters:
      potionEffect - The potion effect to add.
    • remove

      public abstract void remove(SkriptPotionEffect potionEffect, PotionEffectProvider.RetrievalState state)
      Removes a potion effect from this provider. A potion effect only needs to match the qualities of potionEffect to be removed. Thus, an effect will be removed even if it has other, distinguishing qualities.
      Parameters:
      potionEffect - The potion effect to remove.
      state - State determining whether certain types of potion effects should be ignored.
    • removeAll

      public abstract void removeAll(org.bukkit.potion.PotionEffectType potionEffectType, PotionEffectProvider.RetrievalState state)
      Removes all potion effects of a specific type from this provider.
      Parameters:
      potionEffectType - The type of potion effect to remove.
      state - State determining whether certain types of potion effects should be preserved.
    • clear

      public abstract void clear(org.bukkit.potion.PotionEffectType[] potionEffectTypes, PotionEffectProvider.RetrievalState state)
      Clears all potion effects of potionEffectTypes from this provider.
      Parameters:
      potionEffectTypes - The types of potion effects to clear.
      state - State determining whether certain types of potion effects should be ignored.
    • clearAll

      public abstract void clearAll(PotionEffectProvider.RetrievalState state)
      Clears all potion effects from this provider.
      Parameters:
      state - State determining whether certain types of potion effects should be preserved.
    • modify

      public void modify(org.bukkit.potion.PotionEffectType[] types, PotionEffectProvider.RetrievalState state, Object[] delta, Changer.ChangeMode mode)
      Modifies properties of existing potion effects on this provider.
      Parameters:
      types - The types of potion effects to modify.
      state - State determining whether certain types of potion effects should be ignored.
      delta - The change values.
      mode - The type of modification to perform.
    • mirrorEffectChanges

      public abstract void mirrorEffectChanges(SkriptPotionEffect potionEffect, Runnable runnable)
      Used for mirroring modifications of a potion effect actively applied to this provider.
      Parameters:
      potionEffect - The potion effect being modified.
      runnable - A runnable that applies the modification(s) to potionEffect when invoked.