Class ExperimentRegistry

java.lang.Object
org.skriptlang.skript.lang.experiment.ExperimentRegistry
All Implemented Interfaces:
Experimented

public class ExperimentRegistry extends Object implements Experimented
A manager for registering (and identifying) experimental feature flags.
  • Constructor Details

    • ExperimentRegistry

      public ExperimentRegistry(Skript skript)
  • Method Details

    • find

      @NotNull public @NotNull Experiment find(String text)
      Finds an experiment matching this name. If none exist, an 'unknown' one will be created.
      Parameters:
      text - The text provided by the user.
      Returns:
      An experiment.
    • registered

      public Experiment[] registered()
      Returns:
      All currently-registered experiments.
    • register

      public void register(SkriptAddon addon, Experiment experiment)
      Registers a new experimental feature flag, which will be available to scripts with the using %name% structure.
      Parameters:
      addon - The source of this feature.
      experiment - The experimental feature flag.
    • registerAll

      public void registerAll(SkriptAddon addon, Experiment... experiments)
      See Also:
    • unregister

      public void unregister(SkriptAddon addon, Experiment experiment)
      Unregisters an experimental feature flag. Loaded scripts currently using the flag will not have it disabled.
      Parameters:
      addon - The source of this feature.
      experiment - The experimental feature flag.
    • register

      public Experiment register(SkriptAddon addon, String codeName, LifeCycle phase, String... patterns)
      Creates (and registers) a new experimental feature flag, which will be available to scripts with the using %name% structure.
      Parameters:
      addon - The source of this feature.
      codeName - The debug 'code name' of this feature.
      phase - The stability of this feature.
      patterns - What the user may write to match the feature. Defaults to the codename if not set.
      Returns:
      An experiment flag.
    • hasExperiment

      public boolean hasExperiment(Experiment experiment)
      Specified by:
      hasExperiment in interface Experimented
      Parameters:
      experiment - The experimental feature to test.
      Returns:
      Whether this uses the given feature.
    • hasExperiment

      public boolean hasExperiment(String featureName)
      Specified by:
      hasExperiment in interface Experimented
      Parameters:
      featureName - The name of the experimental feature to test.
      Returns:
      Whether this has a feature with the given name.
    • isUsing

      public boolean isUsing(Script script, Experiment experiment)
      Whether a script is using an experiment.
      Parameters:
      script - The script to test
      experiment - The experimental flag
      Returns:
      Whether the script declared itself as `using X`
    • isUsing

      public boolean isUsing(Script script, String featureName)
      Whether a script is using an experiment.
      Parameters:
      script - The script to test
      featureName - The experimental flag's name
      Returns:
      Whether the script declared itself as `using X`