Class EventTransformations

java.lang.Object
xyz.janboerman.scalaloader.event.transform.EventTransformations

public class EventTransformations extends Object
This class is NOT part of the public API!
  • Method Details

    • transform

      public static byte[] transform(byte[] clazz, ClassLoader pluginClassLoader) throws EventError

      The following transformations are applied:

      1: Make the class extend org.bukkit.event.Event if the superclass is xyz.janboerman.scalaloader.event.Event. If that transformation is applied, then also the following transformations are applied:

      • inject static field of type HandlerList (if absent)
      • inject static method "static getHandlerList()" (if absent), make it public
      • inject virtual method "HandlerList getHandlers()" (if absent), make it public

      2: If the class implements the xyz.janboerman.scalaloader.event.Cancellable interface directly, it is replaced by the org.bukkit.event.Cancellable interface and the isCancelled and setCancelled methods are added as virtual methods to the event's class.

      3: If a class implements xyz.janboerman.scalaloader.event.EventExecutor, it is replaced by org.bukkit.plugin.EventExecutor. The descriptor of the functional method "execute" will be be updated to accept an org.bukkit.event.Event instead.

      4: Every class that is using xyz.janboerman.scalaloader.event.Event, xyz.janboerman.scalaloder.event.Cancellable or xyz.janboerman.scalaloader.event.EventExecutor will be transformed to use their Bukkit counterparts instead.

      5: Calls to EventBus.callEvent(Object) are replaced by calls to EventBus.callEvent(Event)

      Parameters:
      clazz - the class to be transformed
      pluginClassLoader - the classloader that ASM uses to compute the least upper bound for the StackMapTable
      Returns:
      the transformed class bytes
      Throws:
      EventError