From af25c8e67815ae6882eff47dba7a00e2f9234471 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 28 Mar 2014 20:28:21 +0100 Subject: [PATCH] Reorder some code. --- .../net/pterodactylus/rhynodge/engine/Engine.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) 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())); - } - } } -- 2.7.4