*/
public void addReaction(String name, Reaction reaction) {
synchronized (reactions) {
*/
public void addReaction(String name, Reaction reaction) {
synchronized (reactions) {
Reaction nextReaction;
synchronized (reactions) {
for (Entry<String, Reaction> reactionEntry : reactions.entrySet()) {
Reaction nextReaction;
synchronized (reactions) {
for (Entry<String, Reaction> reactionEntry : reactions.entrySet()) {
long stateTime = (state != null) ? state.time() : 0;
nextReactions.put(stateTime + reactionEntry.getValue().updateInterval(), Pair.of(reactionEntry.getKey(), reactionEntry.getValue()));
}
long stateTime = (state != null) ? state.time() : 0;
nextReactions.put(stateTime + reactionEntry.getValue().updateInterval(), Pair.of(reactionEntry.getKey(), reactionEntry.getValue()));
}
logger.debug(String.format("Next Reaction: %s.", nextReaction));
/* wait until the next reaction has to run. */
logger.debug(String.format("Next Reaction: %s.", nextReaction));
/* wait until the next reaction has to run. */
long lastStateTime = (lastState != null) ? lastState.time() : 0;
int lastStateFailCount = (lastState != null) ? lastState.failCount() : 0;
long waitTime = (lastStateTime + nextReaction.updateInterval()) - System.currentTimeMillis();
long lastStateTime = (lastState != null) ? lastState.time() : 0;
int lastStateFailCount = (lastState != null) ? lastState.failCount() : 0;
long waitTime = (lastStateTime + nextReaction.updateInterval()) - System.currentTimeMillis();
stateManager.saveState(reactionName, state);
/* only run trigger if we have collected two successful states. */
Trigger trigger = nextReaction.trigger();
boolean triggerHit = false;
stateManager.saveState(reactionName, state);
/* only run trigger if we have collected two successful states. */
Trigger trigger = nextReaction.trigger();
boolean triggerHit = false;