From a05116a16c88a150d23d055ddee43d10d89781bd Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 17 Feb 2024 12:22:56 +0100 Subject: [PATCH] Fix SpectatorListener.resendChunks --- .../bausystem/features/world/SpectatorListener.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java index 51eb1fe5..58c0d508 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java @@ -42,7 +42,6 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.player.*; -import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -115,13 +114,11 @@ public class SpectatorListener implements Listener { } private static void resendChunks(Player player) { - int distance = player.getClientViewDistance(); - Location location = player.getLocation(); - for (int x = (int) Math.floor(location.getX() / 16.0) - distance; x <= (int) Math.ceil(location.getX() / 16.0) + distance; x++) { - for (int z = (int) Math.floor(location.getZ() / 16.0) - distance; z <= (int) Math.ceil(location.getZ() / 16.0) + distance; z++) { - CraftbukkitWrapper.impl.sendChunk(player, x, z); - } - } + Location location = player.getLocation().clone(); + player.teleport(location.clone().add(16.0 * player.getClientViewDistance(), 0, 16.0 * player.getClientViewDistance())); + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + player.teleport(location); + }, 5); } private boolean anySupervisorOnline(Player player) {