From: David ‘Bombe’ Roden Date: Fri, 28 Mar 2014 19:28:21 +0000 (+0100) Subject: Reorder some code. X-Git-Tag: v2~237 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=af25c8e67815ae6882eff47dba7a00e2f9234471;p=rhynodge.git Reorder some code. --- diff --git a/src/main/java/net/pterodactylus/rhynodge/engine/Engine.java b/src/main/java/net/pterodactylus/rhynodge/engine/Engine.java index af64e04..9234cfd 100644 --- a/src/main/java/net/pterodactylus/rhynodge/engine/Engine.java +++ b/src/main/java/net/pterodactylus/rhynodge/engine/Engine.java @@ -146,27 +146,18 @@ public class Engine extends AbstractExecutionThreadService { Optional lastSuccessfulState = stateManager.loadLastSuccessfulState(reactionName); /* merge states. */ - boolean triggerHit = false; - Trigger trigger = nextReaction.get().getReaction().trigger(); if (lastSuccessfulState.isPresent() && lastSuccessfulState.get().success() && state.success()) { + Trigger trigger = nextReaction.get().getReaction().trigger(); net.pterodactylus.rhynodge.State newState = trigger.mergeStates(lastSuccessfulState.get(), state); - - /* save new state. */ stateManager.saveState(reactionName, newState); - - triggerHit = trigger.triggers(); + if (trigger.triggers()) { + logger.info("Executing Action..."); + nextReaction.get().getReaction().action().execute(trigger.output(nextReaction.get().getReaction())); + } } else { /* save first or error state. */ stateManager.saveState(reactionName, state); } - - /* run action if trigger was hit. */ - logger.debug(format("Trigger was hit: %s.", triggerHit)); - if (triggerHit) { - logger.info("Executing Action..."); - nextReaction.get().getReaction().action().execute(trigger.output(nextReaction.get().getReaction())); - } - } }