From c6d958261eb7ea3f4f3dd5988f8c00242eca2dcb Mon Sep 17 00:00:00 2001 From: kFor <39985355+kforbro@users.noreply.github.com> Date: Sun, 3 Mar 2024 22:34:10 +0300 Subject: [PATCH] Replace PlayerMoveEvent with scheduler (#73) Co-authored-by: BuildTools --- .../de/oliver/fancyholograms/HologramManagerImpl.java | 8 ++++++++ .../fancyholograms/listeners/PlayerListener.java | 11 ----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/oliver/fancyholograms/HologramManagerImpl.java b/src/main/java/de/oliver/fancyholograms/HologramManagerImpl.java index bcaa3fc5..77684852 100644 --- a/src/main/java/de/oliver/fancyholograms/HologramManagerImpl.java +++ b/src/main/java/de/oliver/fancyholograms/HologramManagerImpl.java @@ -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); + } + } + }); } /** diff --git a/src/main/java/de/oliver/fancyholograms/listeners/PlayerListener.java b/src/main/java/de/oliver/fancyholograms/listeners/PlayerListener.java index 4c9f015d..b7694042 100644 --- a/src/main/java/de/oliver/fancyholograms/listeners/PlayerListener.java +++ b/src/main/java/de/oliver/fancyholograms/listeners/PlayerListener.java @@ -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()) {