@@ -0,0 +1,2825 @@
+package org.spongepowered.test;%0A%0Aimport com.google.inject.Inject;%0Aimport org.slf4j.Logger;%0Aimport org.spongepowered.api.Sponge;%0Aimport org.spongepowered.api.event.CauseStackManager;%0Aimport org.spongepowered.api.event.Listener;%0Aimport org.spongepowered.api.event.Order;%0Aimport org.spongepowered.api.event.game.state.GameStartedServerEvent;%0Aimport org.spongepowered.api.plugin.Plugin;%0A%0Aimport java.util.UUID;%0A%0A@Plugin(id = %22cause-stack-test%22, name = %22Cause Stack Test%22, description = %22A plugin testing the cause stack%22, version = %220.0.0%22)%0Apublic class CauseStackTest %7B%0A    %0A    @Inject private Logger logger;%0A    %0A    @Listener(order = Order.FIRST, beforeModifications = true)%0A    public void onGameStartedServer(GameStartedServerEvent event) %7B%0A        UUID randomUUID = UUID.randomUUID();%0A        %0A        // Initial Cause%0A        Sponge.getCauseStackManager().pushCause(randomUUID);%0A        %0A        // old_min_depth: 0 (Gets incremented to 2 after creating StackFrame).%0A        // lastCauseSize: 0.%0A        try (CauseStackManager.StackFrame stackFrameFirst = Sponge.getCauseStackManager().pushCauseFrame()) %7B%0A            // These have to be the same in order to increase the duplicateCauses count.%0A            String duplicateCause = %22Duplicate Cause Test%22;%0A            %0A            // Initial Cause%0A            stackFrameFirst.pushCause(duplicateCause);%0A            %0A            // Duplicate Causes%0A            stackFrameFirst.pushCause(duplicateCause);%0A            stackFrameFirst.pushCause(duplicateCause);%0A            stackFrameFirst.pushCause(duplicateCause);%0A            stackFrameFirst.pushCause(duplicateCause);%0A            stackFrameFirst.pushCause(duplicateCause);%0A            %0A            // old_min_depth: 2 (Plugin, UUID) (Gets incremented to 3 after creating StackFrame).%0A            // lastCauseSize: 5.%0A            try (CauseStackManager.StackFrame stackFrameSecond = Sponge.getCauseStackManager().pushCauseFrame()) %7B%0A                // This will result in index 2 (Which will be our randomUUID) of the duplicateCauses in the SpongeCauseStackManager to be set to 5.%0A            %7D%0A        %7D%0A        %0A        // Pop initial push.%0A        Sponge.getCauseStackManager().popCause();%0A        %0A        // Check for duplication.%0A        int count = 0;%0A        while (Sponge.getCauseStackManager().peekCause() == randomUUID) %7B%0A            Sponge.getCauseStackManager().popCause();%0A            count++;%0A        %7D%0A        %0A        if (count %3E 0) %7B%0A            this.logger.error(%22===================================================================%22);%0A            this.logger.error(%22CauseStack Duplication detected.%22);%0A            this.logger.error(count + %22 Objects were found when 0 was expected.%22);%0A            this.logger.error(%22===================================================================%22);%0A        %7D%0A    %7D%0A%7D

Add CauseStackTest plugin