Skip to content

Commit

Permalink
Seperated text update interval refresh into separate more frequent sc…
Browse files Browse the repository at this point in the history
…hedule (#133)
  • Loading branch information
OakLoaf authored Aug 5, 2024
1 parent b06556d commit 64ca484
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/java/de/oliver/fancyholograms/HologramManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,32 @@ void initializeTasks() {
if (data instanceof TextHologramData) {
updateTimes.put(hologram.getData().getName(), time);
}
} else if (data instanceof TextHologramData textData) {
}
}
}, 50, 1000, TimeUnit.MILLISECONDS);

hologramThread.scheduleAtFixedRate(() -> {
final var time = System.currentTimeMillis();

for (final var hologram : getHolograms()) {
if (hologram.getData() instanceof TextHologramData textData) {
final var interval = textData.getTextUpdateInterval();
if (interval < 1) {
continue; // doesn't update
}

final var lastUpdate = updateTimes.asMap().get(data.getName());
final var lastUpdate = updateTimes.asMap().get(textData.getName());
if (lastUpdate != null && time < (lastUpdate + interval)) {
continue;
}

if (lastUpdate == null || time > (lastUpdate + interval)) {
hologram.refreshForViewersInWorld();
updateTimes.put(data.getName(), time);
updateTimes.put(textData.getName(), time);
}
}
}
}, 50, 1000, TimeUnit.MILLISECONDS);
}, 50, 50, TimeUnit.MILLISECONDS);
}

/**
Expand Down

0 comments on commit 64ca484

Please sign in to comment.