Skip to content

Instantly share code, notes, and snippets.

@macalinao
Created May 20, 2014 21:27
Show Gist options
  • Save macalinao/3e287f325fc26b42e46e to your computer and use it in GitHub Desktop.
Save macalinao/3e287f325fc26b42e46e to your computer and use it in GitHub Desktop.
/**
* Gets the sponge that the player will modify.
*
* @param p
* @return
*/
public TrackerSponge getSponge(Player p) {
TrackerSponge closest = null;
for (TrackerSponge sponge : sponges) {
if (closest != null) {
continue;
}
if (!sponge.b.getWorld().equals(p.getWorld())) {
continue;
}
if (sponge.b.getLocation().distanceSquared(p.getLocation()) < closest.b.getLocation().distanceSquared(p.getLocation())) {
closest = sponge;
}
}
return closest;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment