diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/elytra/ElytraHelper.java b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/elytra/ElytraHelper.java index 4ccbff961..4797edb39 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/elytra/ElytraHelper.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/elytra/ElytraHelper.java @@ -38,12 +38,13 @@ public class ElytraHelper implements AnarchyExploitFixesModule, Runnable, Listen private final Set PLAYERS_NEAR_NEW_CHUNKS; private final Cache PLAYER_SPEEDS; private final Cache LAST_GLIDE_POS; - private final int checkIntervalTicks; + private final int checkIntervalTicks, serverViewDistance; private final boolean doIntervalCheck; public ElytraHelper() { instance = this; this.plugin = AnarchyExploitFixes.getInstance(); + this.serverViewDistance = plugin.getServer().getViewDistance(); this.calculate3D = AnarchyExploitFixes.getConfiguration().elytra_calculate_3D; this.PLAYERS_GLIDING = plugin.getServer().getOnlinePlayers().stream() .filter(LivingEntity::isGliding) @@ -109,6 +110,14 @@ public boolean isGliding(Player player) { return PLAYERS_GLIDING.contains(player.getUniqueId()) || player.isGliding(); } + public int getViewDistance(Player player) { + try { + return player.getViewDistance(); + } catch (Exception e) { + return serverViewDistance; + } + } + @Override public void run() { for (Player player : plugin.getServer().getOnlinePlayers()) { @@ -152,7 +161,7 @@ private void onJoin(PlayerJoinEvent event) { @EventHandler(priority = EventPriority.LOWEST) private void onChunkLoad(ChunkLoadEvent event) { for (Player player : event.getWorld().getPlayers()) { - if (this.getChunkDistanceSquared(event.getChunk(), player.getLocation().clone()) < NumberConversions.square(player.getViewDistance())) { + if (this.getChunkDistanceSquared(event.getChunk(), player.getLocation().clone()) < NumberConversions.square(getViewDistance(player))) { if (event.isNewChunk()) { this.PLAYERS_NEAR_NEW_CHUNKS.add(player.getUniqueId()); } else {