Skip to content

Commit

Permalink
make marker cache key more unique
Browse files Browse the repository at this point in the history
  • Loading branch information
granny committed Feb 2, 2024
1 parent f8b8890 commit f67b857
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import net.pl3x.map.core.Pl3xMap;
import net.pl3x.map.core.log.Logger;
import net.pl3x.map.core.markers.JsonObjectWrapper;
import net.pl3x.map.core.markers.layer.Layer;
import net.pl3x.map.core.markers.marker.Marker;
Expand Down Expand Up @@ -113,10 +114,10 @@ private void parseLayers() {

List<Marker<?>> list = new ArrayList<>(layer.getMarkers());
String json = this.gson.toJson(list);
String markerCacheIfPresent = markerCache.getIfPresent(key);
String markerCacheIfPresent = markerCache.getIfPresent(this.world.getKey() + "|" + key);
if (markerCacheIfPresent == null || !markerCacheIfPresent.equals(json)) {
Pl3xMap.api().getHttpdServer().sendSSE("markers", String.format("{ \"world\": \"%s\", \"key\": \"%s\", \"markers\": %s}", this.world.getName(), key, json));
markerCache.put(key, json);
markerCache.put(this.world.getKey() + "|" + key, json);
}

if (now - lastUpdated > Math.max(TickUtil.toMilliseconds(layer.getUpdateInterval()), 1000)) {
Expand Down

0 comments on commit f67b857

Please sign in to comment.