Search in sources :

Example 6 with CommandSourceStackBridge

use of org.spongepowered.common.bridge.commands.CommandSourceStackBridge in project SpongeCommon by SpongePowered.

the class CommandSourceStackMixin method impl$copyPermissionOnCopy.

/*
     * All the with* methods copy this CommandSource, so we need to do our own copy.
     * This method MUST be above all other with* return injections so that the cause copy happens
     * FIRST. That way, we don't overwrite any changes we then need to make.
     */
@Inject(method = { "withEntity", "withPosition", "withRotation(Lnet/minecraft/world/phys/Vec2;)Lnet/minecraft/commands/CommandSourceStack;", "withCallback(Lcom/mojang/brigadier/ResultConsumer;)Lnet/minecraft/commands/CommandSourceStack;", "withSuppressedOutput", "withPermission", "withMaximumPermission", "withAnchor", "withLevel" }, at = @At("RETURN"))
private void impl$copyPermissionOnCopy(final CallbackInfoReturnable<CommandSourceStack> cir) {
    if (cir.getReturnValue() != (Object) this) {
        final CommandSourceStackBridge commandSourceStackBridge = ((CommandSourceStackBridge) cir.getReturnValue());
        commandSourceStackBridge.bridge$setPotentialPermissionNode(this.impl$potentialPermissionNode);
        commandSourceStackBridge.bridge$setCause(this.impl$cause);
    }
}
Also used : CommandSourceStackBridge(org.spongepowered.common.bridge.commands.CommandSourceStackBridge) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

CommandSourceStackBridge (org.spongepowered.common.bridge.commands.CommandSourceStackBridge)6 CauseStackManager (org.spongepowered.api.event.CauseStackManager)5 CommandCause (org.spongepowered.api.command.CommandCause)4 CommandSource (net.minecraft.commands.CommandSource)3 CommandSourceStack (net.minecraft.commands.CommandSourceStack)3 Component (net.minecraft.network.chat.Component)3 ServerLevel (net.minecraft.server.level.ServerLevel)3 Vec2 (net.minecraft.world.phys.Vec2)3 Vec3 (net.minecraft.world.phys.Vec3)3 Nullable (org.checkerframework.checker.nullness.qual.Nullable)3 Cause (org.spongepowered.api.event.Cause)3 EventContext (org.spongepowered.api.event.EventContext)3 EventContextKeys (org.spongepowered.api.event.EventContextKeys)3 Inject (org.spongepowered.asm.mixin.injection.Inject)3 PhaseTracker (org.spongepowered.common.event.tracking.PhaseTracker)3 VecHelper (org.spongepowered.common.util.VecHelper)3 ResultConsumer (com.mojang.brigadier.ResultConsumer)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Supplier (java.util.function.Supplier)2