From: David ‘Bombe’ Roden Date: Sun, 6 Jan 2013 22:13:26 +0000 (+0100) Subject: Use the last successful state for the trigger. X-Git-Tag: 0.1~55 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=67c416770e847c09df106b31d03c9227e738a429;p=rhynodge.git Use the last successful state for the trigger. --- 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. */