package io.github.xxyy.common.util;

import org.apache.commons.lang.math.RandomUtils;
import org.bukkit.Location;

/**
 * A class providing some static methods to deal with {@link Location}s.
 *
 * @author <a href="http://xxyy.github.io/">xxyy</a>
 */
public abstract class LocationHelper {
    /**
     * Determines if a location {@code toCheck} is between or
     * located on one of the boundaries specified.
     * There is no special order of the boundaries required,
     * they can even be equal.
     *
     * @see CommandHelper#isNumberBetween(int, int, int)
     */
    public static boolean isBlockBetween(Location toCheck, Location boundary1, Location boundary2) {
        return CommandHelper.isNumberBetween(toCheck.getBlockX(), boundary1.getBlockX(), boundary2.getBlockX()) &&
                CommandHelper.isNumberBetween(toCheck.getBlockY(), boundary1.getBlockY(), boundary2.getBlockY()) &&
                CommandHelper.isNumberBetween(toCheck.getBlockZ(), boundary1.getBlockZ(), boundary2.getBlockZ());
    }

    /**
     * Determines if a number {@code toCheck} is between or
     * equal to one the boundaries specified.
     * There is no special order of the boundaries required,
     *
     * @deprecated Use {@link CommandHelper#isNumberBetween(int, int, int)} instead
     */
    @Deprecated
    public static boolean isNumberBetween(int toCheck, int boundary1, int boundary2) {
        return CommandHelper.isNumberBetween(toCheck, boundary1, boundary2);
    }

    /**
     * Randomises x,y and z coordinates of a Location, in a radius.
     *
     * @param original Location to randomise
     * @param radius   Maximum distance from the original location
     */
    public static Location randomiseLocation(Location original, int radius) {
        int modX = RandomUtils.nextInt(radius);
        int modY = RandomUtils.nextInt(radius);
        int modZ = RandomUtils.nextInt(radius);
        if (RandomUtils.nextBoolean()) {
            modX = modX * -1;
        } // so that randomisation goes
        if (RandomUtils.nextBoolean()) {
            modY = modY * -1;
        } // in both directions!!
        if (RandomUtils.nextBoolean()) {
            modZ = modZ * -1;
        } // ^^^^^^^^^^^^^^^^
        return new Location(original.getWorld(),
                original.getBlockX() + modX, // create new object so that
                original.getBlockY() + modY, // original can be reused
                original.getBlockZ() + modZ);
    }
}

@@ -41,72 +41,216 @@
 ort 
-org.apache.commons.lang.math.RandomUtils;%0Aimport org.bukkit.Loca
+lombok.NonNull;%0Aimport org.apache.commons.lang.Validate;%0Aimport org.apache.commons.lang.math.RandomUtils;%0Aimport org.bukkit.Bukkit;%0Aimport org.bukkit.Location;%0Aimport org.bukkit.configuration.ConfigurationSec
 tion
@@ -2614,11 +2614,785 @@
 );%0A    %7D
+%0A%0A    /**%0A     * Gets a Location from a ConfigurationSection.%0A     * The section must contain %7B@code x%7D,%7B@code y%7D and %7B@code z%7D (int) and %7B@code world%7D (String).%0A     * @param section Configuration to read from%0A     * @return The read Location.%0A     * @throws java.lang.IllegalArgumentException If the section does not contain all values.%0A     */%0A    public static Location fromConfiguration(@NonNull ConfigurationSection section)%7B%0A        Validate.isTrue(section.contains(%22world%22) && section.contains(%22x%22) && section.contains(%22y%22) && section.contains(%22z%22),%0A                %22The given section does not contain all of x,y and z!%22);%0A%0A        return new Location(Bukkit.getWorld(section.getString(%22world%22)), section.getInt(%22x%22), section.getInt(%22y%22), section.getInt(%22z%22));%0A    %7D
 %0A%7D%0A

Add fromConfiguration() methode to LocationHelper