Use the last successful state for the trigger.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 6 Jan 2013 22:13:26 +0000 (23:13 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 6 Jan 2013 22:13:26 +0000 (23:13 +0100)
src/main/java/net/pterodactylus/reactor/engine/Engine.java

index e82267c..2825b54 100644 (file)
@@ -177,14 +177,15 @@ public class Engine extends AbstractExecutionThreadService {
                        if (!state.success()) {
                                state.setFailCount(lastStateFailCount + 1);
                        }
+                       net.pterodactylus.reactor.State lastSuccessfulState = stateManager.loadLastSuccessfulState(reactionName);
                        stateManager.saveState(reactionName, state);
 
                        /* only run trigger if we have collected two successful states. */
                        Trigger trigger = nextReaction.trigger();
                        boolean triggerHit = false;
-                       if ((lastState != null) && lastState.success() && state.success()) {
+                       if ((lastSuccessfulState != null) && lastSuccessfulState.success() && state.success()) {
                                logger.debug("Checking Trigger for changes...");
-                               triggerHit = trigger.triggers(state, lastState);
+                               triggerHit = trigger.triggers(state, lastSuccessfulState);
                        }
 
                        /* run action if trigger was hit. */