diff --git a/src/main/java/com/llamalad7/mixinextras/sugar/Cancellable.java b/src/main/java/com/llamalad7/mixinextras/sugar/Cancellable.java index 98fc5d0..9fcc682 100644 --- a/src/main/java/com/llamalad7/mixinextras/sugar/Cancellable.java +++ b/src/main/java/com/llamalad7/mixinextras/sugar/Cancellable.java @@ -1,10 +1,30 @@ package com.llamalad7.mixinextras.sugar; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyConstant; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * Allows you to receive a cancellable {@link CallbackInfo} or {@link CallbackInfoReturnable} as appropriate + * from any kind of injector. This allows you to optionally cancel the target method without being forced to use + * {@link Inject @Inject}. + *

+ * The same {@link CallbackInfo}s will be passed to every handler method in a chain of + * {@link WrapOperation @WrapOperation}s (i.e. any number of {@link WrapOperation @WrapOperation}s and at most one inner + * {@link Redirect @Redirect} / {@link ModifyConstant @ModifyConstant}). This means you can choose to use the + * {@link CallbackInfo#isCancelled()} and {@link CallbackInfoReturnable#getReturnValue()} methods to see if the wrapped + * handler cancelled, so you can respond accordingly. + *

+ * See the wiki article for more info. + */ @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.CLASS) public @interface Cancellable {