Skip to content

Commit

Permalink
rename for more clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Jan 2, 2024
1 parent de94165 commit be71cb2
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
if (!player.isGliding()) return;
if (spawn_shouldCheckPermission && player.hasPermission("anarchyexploitfixes.bypass")) return;
Location playerLoc = player.getLocation();
if (LocationUtil.getDistanceTo00(playerLoc) > spawn_Radius) return;
if (LocationUtil.getFlatDistanceTo00(playerLoc) > spawn_Radius) return;

if (spawn_DenyElytra) {
if (teleportBack) player.teleportAsync(event.getFrom());
Expand Down Expand Up @@ -116,7 +116,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
return;
}

double flySpeed = LocationUtil.getXZDistance(event.getFrom(), event.getTo());
double flySpeed = LocationUtil.getFlatDistance(event.getFrom(), event.getTo());

if (plugin.NEW_CHUNK_PLAYERS.contains(player.getUniqueId())) {
// Speed New Chunks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
if (!player.isGliding()) return;
if (global_shouldCheckPermission && player.hasPermission("anarchyexploitfixes.bypass")) return;
Location playerLoc = player.getLocation();
if (spawn_SettingsEnabled && LocationUtil.getDistanceTo00(playerLoc) <= spawn_Radius) return;
if (spawn_SettingsEnabled && LocationUtil.getFlatDistanceTo00(playerLoc) <= spawn_Radius) return;
if (ceiling_SettingsEnabled && LocationUtil.isNetherCeiling(playerLoc)) return;

if (global_DenyElytra) {
Expand Down Expand Up @@ -125,7 +125,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
return;
}

double flySpeed = LocationUtil.getXZDistance(event.getFrom(), event.getTo());
double flySpeed = LocationUtil.getFlatDistance(event.getFrom(), event.getTo());

if (plugin.NEW_CHUNK_PLAYERS.contains(player.getUniqueId())) {
// Speed New Chunks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
if (ceiling_shouldCheckPermission && player.hasPermission("anarchyexploitfixes.bypass")) return;
Location playerLoc = player.getLocation();
if (!LocationUtil.isNetherCeiling(playerLoc)) return;
if (spawn_SettingsEnabled && LocationUtil.getDistanceTo00(playerLoc) <= spawn_Radius) return;
if (spawn_SettingsEnabled && LocationUtil.getFlatDistanceTo00(playerLoc) <= spawn_Radius) return;

if (ceiling_DenyElytra) {
if (teleportBack) player.teleportAsync(event.getFrom());
Expand Down Expand Up @@ -122,7 +122,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
return;
}

double flySpeed = LocationUtil.getXZDistance(event.getFrom(), event.getTo());
double flySpeed = LocationUtil.getFlatDistance(event.getFrom(), event.getTo());

if (plugin.NEW_CHUNK_PLAYERS.contains(player.getUniqueId())) {
// Speed New Chunks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void tempVanish(Player player) {
private void onTeleport(PlayerTeleportEvent event) {
switch (event.getCause()) {
case ENDER_PEARL, COMMAND, PLUGIN -> {
if (LocationUtil.getXZDistance(event.getFrom(), event.getTo()) >= minDistanceToVanishPlayers) {
if (LocationUtil.getFlatDistance(event.getFrom(), event.getTo()) >= minDistanceToVanishPlayers) {
this.tempVanish(event.getPlayer());
}
}
Expand All @@ -84,7 +84,7 @@ private void onTeleport(PlayerTeleportEvent event) {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onSpawn(PlayerRespawnEvent event) {
final Player player = event.getPlayer();
if (LocationUtil.getXZDistance(player.getLocation(), event.getRespawnLocation()) >= minDistanceToVanishPlayers) {
if (LocationUtil.getFlatDistance(player.getLocation(), event.getRespawnLocation()) >= minDistanceToVanishPlayers) {
this.tempVanish(player);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void onCreatureSpawn(CreatureSpawnEvent event) {

final Integer disabledRadius = worldsAndTheirRadiuses.get(world);
Location witherLocation = wither.getLocation();
if (LocationUtil.getDistanceTo00(witherLocation) > disabledRadius) return;
if (LocationUtil.getFlatDistanceTo00(witherLocation) > disabledRadius) return;

event.setCancelled(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

public class LocationUtil {

public static double getDistanceTo00(Location location) {
public static double getFlatDistanceTo00(Location location) {
return FastMath.hypot(location.x(), location.z());
}

public static double getXZDistance(Location from, Location to) {
public static double getFlatDistance(Location from, Location to) {
double toX = to.x();
double toZ = to.z();
double fromX = from.x();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
if (!player.isGliding()) return;
if (spawn_shouldCheckPermission && player.hasPermission("anarchyexploitfixes.bypass")) return;
Location playerLoc = player.getLocation();
if (LocationUtil.getDistanceTo00(playerLoc) > spawn_Radius) return;
if (LocationUtil.getFlatDistanceTo00(playerLoc) > spawn_Radius) return;

if (spawn_DenyElytra) {
if (teleportBack) player.teleport(event.getFrom());
Expand Down Expand Up @@ -112,7 +112,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
return;
}

double flySpeed = LocationUtil.getXZDistance(event.getFrom(), event.getTo());
double flySpeed = LocationUtil.getFlatDistance(event.getFrom(), event.getTo());

if (plugin.NEW_CHUNK_PLAYERS.contains(player.getUniqueId())) {
// Speed New Chunks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
if (!player.isGliding()) return;
if (global_shouldCheckPermission && player.hasPermission("anarchyexploitfixes.bypass")) return;
Location playerLoc = player.getLocation();
if (spawn_SettingsEnabled && LocationUtil.getDistanceTo00(playerLoc) <= spawn_Radius) return;
if (spawn_SettingsEnabled && LocationUtil.getFlatDistanceTo00(playerLoc) <= spawn_Radius) return;
if (ceiling_SettingsEnabled && LocationUtil.isNetherCeiling(playerLoc)) return;

if (global_DenyElytra) {
Expand Down Expand Up @@ -121,7 +121,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
return;
}

double flySpeed = LocationUtil.getXZDistance(event.getFrom(), event.getTo());
double flySpeed = LocationUtil.getFlatDistance(event.getFrom(), event.getTo());

if (plugin.NEW_CHUNK_PLAYERS.contains(player.getUniqueId())) {
// Speed New Chunks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
if (ceiling_shouldCheckPermission && player.hasPermission("anarchyexploitfixes.bypass")) return;
Location playerLoc = player.getLocation();
if (!LocationUtil.isNetherCeiling(playerLoc)) return;
if (spawn_SettingsEnabled && LocationUtil.getDistanceTo00(playerLoc) <= spawn_Radius) return;
if (spawn_SettingsEnabled && LocationUtil.getFlatDistanceTo00(playerLoc) <= spawn_Radius) return;

if (ceiling_DenyElytra) {
if (teleportBack) player.teleport(event.getFrom());
Expand Down Expand Up @@ -118,7 +118,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
return;
}

double flySpeed = LocationUtil.getXZDistance(event.getFrom(), event.getTo());
double flySpeed = LocationUtil.getFlatDistance(event.getFrom(), event.getTo());

if (plugin.NEW_CHUNK_PLAYERS.contains(player.getUniqueId())) {
// Speed New Chunks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void onTeleport(PlayerTeleportEvent event) {
|| cause.equals(PlayerTeleportEvent.TeleportCause.COMMAND)
|| cause.equals(PlayerTeleportEvent.TeleportCause.ENDER_PEARL)
) {
if (LocationUtil.getXZDistance(event.getFrom(), event.getTo()) >= minDistanceToVanishPlayers) {
if (LocationUtil.getFlatDistance(event.getFrom(), event.getTo()) >= minDistanceToVanishPlayers) {
Player player = event.getPlayer();
this.vanish(player);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> this.unVanish(player), teleportVanishTime);
Expand All @@ -89,7 +89,7 @@ private void onTeleport(PlayerTeleportEvent event) {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onSpawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if (LocationUtil.getXZDistance(player.getLocation(), event.getRespawnLocation()) >= minDistanceToVanishPlayers) {
if (LocationUtil.getFlatDistance(player.getLocation(), event.getRespawnLocation()) >= minDistanceToVanishPlayers) {
this.vanish(player);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> this.unVanish(player), teleportVanishTime);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void onCreatureSpawn(CreatureSpawnEvent event) {

final Integer disabledRadius = worldsAndTheirRadiuses.get(world);
final Location witherLocation = entity.getLocation();
if (LocationUtil.getDistanceTo00(witherLocation) > disabledRadius) return;
if (LocationUtil.getFlatDistanceTo00(witherLocation) > disabledRadius) return;

event.setCancelled(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

public class LocationUtil {

public static double getDistanceTo00(Location location) {
public static double getFlatDistanceTo00(Location location) {
return FastMath.hypot(location.getX(), location.getZ());
}

public static double getXZDistance(Location from, Location to) {
public static double getFlatDistance(Location from, Location to) {
double toX = to.getX();
double toZ = to.getZ();
double fromX = from.getX();
Expand Down

0 comments on commit be71cb2

Please sign in to comment.