From 67c416770e847c09df106b31d03c9227e738a429 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 6 Jan 2013 23:13:26 +0100 Subject: [PATCH] Use the last successful state for the trigger. --- src/main/java/net/pterodactylus/reactor/engine/Engine.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/reactor/engine/Engine.java b/src/main/java/net/pterodactylus/reactor/engine/Engine.java index e82267c..2825b54 100644 --- a/src/main/java/net/pterodactylus/reactor/engine/Engine.java +++ b/src/main/java/net/pterodactylus/reactor/engine/Engine.java @@ -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. */ -- 2.7.4