Search in sources :

Example 1 with TickTaskBridge

use of org.spongepowered.common.bridge.server.TickTaskBridge in project SpongeCommon by SpongePowered.

the class ScheduledTaskPhaseState method foldContextForThread.

@Override
public void foldContextForThread(final BasicPluginContext context, final TickTaskBridge returnValue) {
    @Nullable final Object source = context.getSource();
    final PluginContainer plugin = Objects.requireNonNull(context.container, "Scheduled Task has a null plugin!");
    returnValue.bridge$contextShift(((context1, stackFrame) -> {
        if (source != null) {
            stackFrame.pushCause(source);
        }
        stackFrame.pushCause(plugin);
    }));
}
Also used : Objects(java.util.Objects) TrackingUtil(org.spongepowered.common.event.tracking.TrackingUtil) PluginContainer(org.spongepowered.plugin.PluginContainer) Nullable(org.checkerframework.checker.nullness.qual.Nullable) TickTaskBridge(org.spongepowered.common.bridge.server.TickTaskBridge) PluginContainer(org.spongepowered.plugin.PluginContainer) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Example 2 with TickTaskBridge

use of org.spongepowered.common.bridge.server.TickTaskBridge in project SpongeCommon by SpongePowered.

the class MinecraftServerMixin_Tracker method tracker$associatePhaseContextWithWrappedTask.

@Inject(method = "wrapRunnable(Ljava/lang/Runnable;)Lnet/minecraft/server/TickTask;", at = @At("RETURN"))
private void tracker$associatePhaseContextWithWrappedTask(final Runnable runnable, final CallbackInfoReturnable<TickTask> cir) {
    final TickTask returnValue = cir.getReturnValue();
    if (!PhaseTracker.SERVER.onSidedThread()) {
        final PhaseContext<@NonNull ?> phaseContext = PhaseTracker.getInstance().getPhaseContext();
        if (phaseContext.isEmpty()) {
            return;
        }
        phaseContext.foldContextForThread(((TickTaskBridge) returnValue));
    }
}
Also used : TickTaskBridge(org.spongepowered.common.bridge.server.TickTaskBridge) TickTask(net.minecraft.server.TickTask) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

TickTaskBridge (org.spongepowered.common.bridge.server.TickTaskBridge)2 Objects (java.util.Objects)1 TickTask (net.minecraft.server.TickTask)1 Nullable (org.checkerframework.checker.nullness.qual.Nullable)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1 TrackingUtil (org.spongepowered.common.event.tracking.TrackingUtil)1 PluginContainer (org.spongepowered.plugin.PluginContainer)1