- /* find next reaction. */
- SortedMap<Long, Pair<String, Reaction>> nextReactions = Maps.newTreeMap();
- String reactionName;
- Reaction nextReaction;
- synchronized (reactions) {
- for (Entry<String, Reaction> reactionEntry : reactions.entrySet()) {
- net.pterodactylus.rhynodge.State state = stateManager.loadLastState(reactionEntry.getKey());
- long stateTime = (state != null) ? state.time() : 0;
- nextReactions.put(stateTime + reactionEntry.getValue().updateInterval(), Pair.of(reactionEntry.getKey(), reactionEntry.getValue()));
- }
- reactionName = nextReactions.get(nextReactions.firstKey()).getLeft();
- nextReaction = nextReactions.get(nextReactions.firstKey()).getRight();
- }