Package org.spongepowered.asm.mixin.extensibility

## Interface IMixinConfigPlugin

    public interface IMixinConfigPlugin

A companion plugin for a mixin configuration object. Objects implementing this interface get some limited power of veto over the mixin load process as well as an opportunity to apply their own transformations to the target class pre- and post-transform. Since all methods in this class are called indirectly from the transformer, the same precautions as for writing class transformers should be taken. Implementors should take care to not reference any game classes, and avoid referencing other classes in their own mod except those specificially designed to be available at early startup, such as coremod classes or other standalone bootstrap objects.

Instances of plugins are created by specifying the "plugin" key in the mixin config JSON as the fully-qualified class name of a class implementing this interface.

### Method Summary

All Methods Instance Methods Abstract Methods
`void` `acceptTargets​(java.util.Set<java.lang.String> myTargets, java.util.Set<java.lang.String> otherTargets)` Called after all configurations are initialised, this allows this plugin to observe classes targetted by other mixin configs and optionally remove targets from its own set.
`java.util.List<java.lang.String>` `getMixins()` After mixins specified in the configuration have been processed, this method is called to allow the plugin to add any additional mixins to load.
`java.lang.String` `getRefMapperConfig()` Called only if the "referenceMap" key in the config is not set.
`void` `onLoad​(java.lang.String mixinPackage)` Called after the plugin is instantiated, do any setup here.
`void` `postApply​(java.lang.String targetClassName, org.objectweb.asm.tree.ClassNode targetClass, java.lang.String mixinClassName, IMixinInfo mixinInfo)` Called immediately after a mixin is applied to a target class, allows any post-application transformations to be applied.
`void` `preApply​(java.lang.String targetClassName, org.objectweb.asm.tree.ClassNode targetClass, java.lang.String mixinClassName, IMixinInfo mixinInfo)` Called immediately before a mixin is applied to a target class, allows any pre-application transformations to be applied.
`boolean` `shouldApplyMixin​(java.lang.String targetClassName, java.lang.String mixinClassName)` Called during mixin intialisation, allows this plugin to control whether a specific will be applied to the specified target.

### Method Detail

#### onLoad

    void onLoad​(java.lang.String mixinPackage)

Called after the plugin is instantiated, do any setup here.

Parameters:
  `mixinPackage` - The mixin root package from the config

#### getRefMapperConfig

    java.lang.String getRefMapperConfig()

Called only if the "referenceMap" key in the config is not set. This allows the refmap file name to be supplied by the plugin programatically if desired. Returning `null` will revert to the default behaviour of using the default refmap json file.

Returns:
  Path to the refmap resource or null to revert to the default

#### shouldApplyMixin

    boolean shouldApplyMixin​(java.lang.String targetClassName,
                             java.lang.String mixinClassName)

Called during mixin intialisation, allows this plugin to control whether a specific will be applied to the specified target. Returning false will remove the target from the mixin's target set, and if all targets are removed then the mixin will not be applied at all.

Parameters:
  `targetClassName` - Fully qualified class name of the target class
  `mixinClassName` - Fully qualified class name of the mixin
Returns:
  True to allow the mixin to be applied, or false to remove it from target's mixin set

#### acceptTargets

    void acceptTargets​(java.util.Set<java.lang.String> myTargets,
                       java.util.Set<java.lang.String> otherTargets)

Called after all configurations are initialised, this allows this plugin to observe classes targetted by other mixin configs and optionally remove targets from its own set. The set myTargets is a direct view of the targets collection in this companion config and keys may be removed from this set to suppress mixins in this config which target the specified class. Adding keys to the set will have no effect.

Parameters:
  `myTargets` - Target class set from the companion config
  `otherTargets` - Target class set incorporating targets from all other configs, read-only

#### getMixins

    java.util.List<java.lang.String> getMixins()

After mixins specified in the configuration have been processed, this method is called to allow the plugin to add any additional mixins to load. It should return a list of mixin class names or return null if the plugin does not wish to append any mixins of its own.

Returns:
  additional mixins to apply

#### preApply

    void preApply​(java.lang.String targetClassName,
                  org.objectweb.asm.tree.ClassNode targetClass,
                  java.lang.String mixinClassName,
                  IMixinInfo mixinInfo)

Called immediately before a mixin is applied to a target class, allows any pre-application transformations to be applied.

Parameters:
  `targetClassName` - Transformed name of the target class
  `targetClass` - Target class tree
  `mixinClassName` - Name of the mixin class
  `mixinInfo` - Information about this mixin

#### postApply

    void postApply​(java.lang.String targetClassName,
                   org.objectweb.asm.tree.ClassNode targetClass,
                   java.lang.String mixinClassName,
                   IMixinInfo mixinInfo)

Called immediately after a mixin is applied to a target class, allows any post-application transformations to be applied.

Parameters:
  `targetClassName` - Transformed name of the target class
  `targetClass` - Target class tree
  `mixinClassName` - Name of the mixin class
  `mixinInfo` - Information about this mixin