// It is important to note that there is no way to accurately determine if the player is in rain or snow.
public boolean isInWeather (Player player) {
Location location = player.getLocation();
Block block = player.getWorld().getHighestBlockAt(location.getBlockX(), location.getBlockZ());
// Offset the location for the player's height.
location.setY(location.getY() + 2.0D);
// Rough list of the biomes where rain/snow don't occur.
Biome[] invalidBiomes = { Biome.DESERT, Biome.DESERT_HILLS, Biome.DESERT_MOUNTAINS, Biome.SAVANNA, Biome.SAVANNA_MOUNTAINS, Biome.SAVANNA_PLATEAU, Biome.SAVANNA_PLATEAU_MOUNTAINS, Biome.MESA, Biome.MESA_BRYCE, Biome.MESA_PLATEAU, Biome.MESA_PLATEAU_FOREST, Biome.MESA_PLATEAU_FOREST_MOUNTAINS, Biome.MESA_PLATEAU_MOUNTAINS};
// Make sure it is raining in the world.
if(player.getWorld().hasStorm()) {
// Make sure the player isn't in an invalid biome.
if(!Arrays.asList(invalidBiomes).contains(player.getWorld().getBiome(pLoc.getBlockX(), pLoc.getBlockZ())) {
// Make sure the player is above the highest block at that coordinate.
if (location.getBlockY() > block.getY()) {
return true;
}
}
}
return false;
}