Skip to content

Commit

Permalink
work around NotImplementedException in 1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Feb 2, 2024
1 parent 26ca07c commit 23604a2
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ public class ElytraHelper implements AnarchyExploitFixesModule, Runnable, Listen
private final Set<UUID> PLAYERS_NEAR_NEW_CHUNKS;
private final Cache<UUID, Double> PLAYER_SPEEDS;
private final Cache<UUID, Location> 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)
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 23604a2

Please sign in to comment.