Skip to content

Commit

Permalink
Replace PlayerMoveEvent with scheduler (#73)
Browse files Browse the repository at this point in the history
Co-authored-by: BuildTools <[email protected]>
  • Loading branch information
kforbro and BuildTools authored Mar 3, 2024
1 parent 6005c92 commit c6d9582
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ void initializeTasks() {
updateTimes.put(hologram.getData().getName(), time);
}
});

this.plugin.getScheduler().runTaskTimerAsynchronously(20L, 20L, () -> {
for (final Hologram hologram : this.plugin.getHologramsManager().getHolograms()) {
for (final Player player : Bukkit.getOnlinePlayers()) {
hologram.checkAndUpdateShownStateForPlayer(player);
}
}
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ public void onQuit(@NotNull final PlayerQuitEvent event) {
});
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMove(@NotNull final PlayerMoveEvent event) {
if (!event.hasChangedBlock()) {
return; // reduce checks we need to do
}

for (final Hologram hologram : this.plugin.getHologramsManager().getHolograms()) {
hologram.checkAndUpdateShownStateForPlayer(event.getPlayer());
}
}

@EventHandler(priority = EventPriority.MONITOR)
public void onTeleport(@NotNull final PlayerTeleportEvent event) {
for (final Hologram hologram : this.plugin.getHologramsManager().getHolograms()) {
Expand Down

0 comments on commit c6d9582

Please sign in to comment.