diff --git a/src/main/java/com/troblecodings/signals/handler/SignalStateHandler.java b/src/main/java/com/troblecodings/signals/handler/SignalStateHandler.java index aa696b00e..585b659a8 100644 --- a/src/main/java/com/troblecodings/signals/handler/SignalStateHandler.java +++ b/src/main/java/com/troblecodings/signals/handler/SignalStateHandler.java @@ -149,21 +149,28 @@ public static void setStates(final SignalStateInfo info, final Map changedProperties = new HashMap<>(); synchronized (CURRENTLY_LOADED_STATES) { if (CURRENTLY_LOADED_STATES.containsKey(info)) { contains.set(true); final Map oldStates = new HashMap<>( CURRENTLY_LOADED_STATES.get(info)); + states.entrySet().stream().filter(entry -> { + final String oldState = oldStates.get(entry.getKey()); + return !entry.getValue().equals(oldState); + }).forEach(entry -> changedProperties.put(entry.getKey(), entry.getValue())); oldStates.putAll(states); CURRENTLY_LOADED_STATES.put(info, ImmutableMap.copyOf(oldStates)); + } else { + changedProperties.putAll(states); } } new Thread(() -> { - sendToAll(info, states); + sendToAll(info, changedProperties); updateListeners(info, false); info.signal.getUpdate(info.world, info.pos); if (!contains.get()) - createToFile(info, states); + createToFile(info, changedProperties); }, "OSSignalStateHandler:setStates").start(); info.world.updateNeighborsAt(info.pos, info.signal); }