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 hidden or 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 | |
| } | 
    loc.getWorld().getNearbyEntities(loc, distance, distance, distance).stream()
            .filter(e -> e instanceof Player)
            .findFirst()
            .orElse(null);
           just do this
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
hey thank you for the code but the closest player is the player interact how i can do ? sorry for my english : P
@fourohfour