From 23604a2416d3896d6c9fa4030c3d90ce019128fa Mon Sep 17 00:00:00 2001 From: xGinko Date: Fri, 2 Feb 2024 11:26:06 +0100 Subject: [PATCH] work around NotImplementedException in 1.16 --- .../modules/elytra/ElytraHelper.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 {