package com.publicuhc.scatter.zones;

import org.bukkit.Location;

public class CircularDeadZoneBuilder implements DeadZoneBuilder {

    private double m_radius;

    /**
     * Will build dead zones that are a circle of the radius given.
     * @param radius the radius of the circle
     */
    public CircularDeadZoneBuilder(double radius) {
        m_radius = radius;
    }

    /**
     * @return the radius of the circle
     */
    public double getRadius()
    {
        return m_radius;
    }

    /**
     * @param radius the radius of the circle
     * @return this
     */
    public CircularDeadZoneBuilder setRadius(double radius)
    {
        m_radius = radius;
        return this;
    }

    /**
     * @param location the location of the centre of the circle
     * @return the dead zone
     */
    @Override
    public DeadZone buildForLocation(Location location) {
        return new CircularDeadZone(location, m_radius);
    }

    private class CircularDeadZone implements DeadZone {

        private final Location m_centre;
        private final double m_radiusSquared;

        /**
         * Creates a dead zone based on a centre location and a radius around it
         * @param centre the centre of the circle
         * @param radius the radius of the circle
         */
        protected CircularDeadZone(Location centre, double radius) {
            m_centre = centre;
            m_radiusSquared = radius * radius;
        }

        @Override
        public boolean isLocationAllowed(Location location) {
            return !location.getWorld().equals(m_centre.getWorld()) || location.distanceSquared(m_centre) > m_radiusSquared;
        }
    }
}

@@ -1357,32 +1357,102 @@
 ouble radius) %7B%0A
+            //check all on the same plane%0A            centre.setY(0);%0A
             m_ce
@@ -1458,32 +1458,32 @@
 entre = centre;%0A
-
             m_ra
@@ -1616,23 +1616,19 @@
         
-return 
+if(
 !locatio
@@ -1671,13 +1671,171 @@
 d())
- %7C%7C l
+) %7B%0A                return true;%0A            %7D%0A%0A            Location checkLocation = location.clone();%0A            checkLocation.setY(0);%0A            return checkL
 ocat

check circular deadzones without the Y axis