Created
January 3, 2014 18:38
-
-
Save fourohfour/8243657 to your computer and use it in GitHub Desktop.
Get nearest player Bukkit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double closest = Double.MAX_VALUE; | |
Player closestp = null; | |
for(Player i : Bukkit.getOnlinePlayers()){ | |
double dist = i.getLocation().distance(event.getPlayer().getLocation()); | |
if (closest == Double.MAX_VALUE || dist < closest){ | |
closest = dist; | |
closestp = i; | |
} | |
} | |
if (closestp == null){ | |
//No players found | |
} | |
else{ | |
//the closest player is closestp | |
} |
zitreF
commented
Feb 6, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment