How can I check whether the player is in a house or a cave or any shelter really?

Discussion in 'Spigot Plugin Development' started by JohnyTheCarrot, Apr 15, 2017.

  1. I'm making a plugin where I need to know whether the player is inside or not.
    The only problem is is I have no clue how I need to do this.
    Anyone any idea on how to achieve this?

    I know I'm not suppose to ask for code but I've really thought this through how I would do this and I don't know. It's a really important part of my plugin so help would be greatly appreciated.
  2. joehot200


    Why not check if they're on the highest block in the world in a given vicinity?
  3. You could check the amount of sky lighting.
    • Agree Agree x 2
  4. You could check to see if a block is over a players head in a certain radius.
    • Agree Agree x 1
  5. How can I do this?
    • Useful Useful x 2
  6. Try a custom method?
    Code (Text):
    public boolean isUnderBlock(Player p){
    int y = p.getLocation().getY();
    Location l = new Location (p.getworld(),p.getLocation().getX(),(double)y,p.getLocation().getZ());
    if (l.getBlock().getType() != Material.AIR)return true;
    return false;