Skip to content

Commit

Permalink
Use scheduleWithFixedDelay
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Jan 15, 2025
1 parent c0ba6fd commit 4cdd978
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private boolean isWithinVisibilityDistance(@NotNull final Hologram hologram, @No
}

public void initRefreshTask() {
FancyHologramsPlugin.get().getHologramThread().scheduleAtFixedRate(() -> {
FancyHologramsPlugin.get().getHologramThread().scheduleWithFixedDelay(() -> {
for (Hologram hologram : FancyHologramsPlugin.get().getRegistry().getAll()) {
refreshHologram(hologram, Bukkit.getOnlinePlayers().toArray(new Player[0]));
}
Expand All @@ -87,10 +87,10 @@ public void initRefreshTask() {

public void initUpdateTask() {
final var updateTimes = CacheBuilder.newBuilder()
.expireAfterAccess(Duration.ofMinutes(5))
.<String, Long>build();
.expireAfterAccess(Duration.ofMinutes(5))
.<String, Long>build();

FancyHologramsPlugin.get().getHologramThread().scheduleAtFixedRate(() -> {
FancyHologramsPlugin.get().getHologramThread().scheduleWithFixedDelay(() -> {
final var time = System.currentTimeMillis();

for (final var hologram : FancyHologramsPlugin.get().getRegistry().getAll()) {
Expand All @@ -109,7 +109,7 @@ public void initUpdateTask() {
}
}, 50, 1000, TimeUnit.MILLISECONDS);

FancyHologramsPlugin.get().getHologramThread().scheduleAtFixedRate(() -> {
FancyHologramsPlugin.get().getHologramThread().scheduleWithFixedDelay(() -> {
final var time = System.currentTimeMillis();

for (final var hologram : FancyHologramsPlugin.get().getRegistry().getAll()) {
Expand All @@ -136,7 +136,7 @@ public void initUpdateTask() {
}, 50, 50, TimeUnit.MILLISECONDS);
}

/**
/**
* Syncs a hologram with its linked NPC, if any.
*
* @param hologram The hologram to sync.
Expand All @@ -158,7 +158,7 @@ public void syncHologramWithNpc(@NotNull final Hologram hologram) {

final var npcScale = npc.getData().getScale();

if(hologram.getData() instanceof DisplayHologramData displayData) {
if (hologram.getData() instanceof DisplayHologramData displayData) {
displayData.setScale(new Vector3f(npcScale));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void onEnable() {
controller.initUpdateTask();

if (configuration.isAutosaveEnabled()) {
getHologramThread().scheduleAtFixedRate(
getHologramThread().scheduleWithFixedDelay(
this::savePersistentHolograms,
configuration.getAutosaveInterval(),
120L, TimeUnit.SECONDS
Expand Down

0 comments on commit 4cdd978

Please sign in to comment.