Added a getCenter() method to all Border classes.
This commit is contained in:
parent
c3ca060ef0
commit
4ec7f0f7ab
@ -79,6 +79,8 @@ public abstract class Border
|
|||||||
*/
|
*/
|
||||||
public abstract Location[] getSurroundingRect();
|
public abstract Location[] getSurroundingRect();
|
||||||
|
|
||||||
|
public abstract Location getCenter();
|
||||||
|
|
||||||
public Boolean isActive()
|
public Boolean isActive()
|
||||||
{
|
{
|
||||||
return isActive;
|
return isActive;
|
||||||
|
@ -129,4 +129,10 @@ public class CircBorder extends Border implements ConfigurationSerializable
|
|||||||
|
|
||||||
return new Location[]{ l1, l2 };
|
return new Location[]{ l1, l2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location getCenter()
|
||||||
|
{
|
||||||
|
return center;
|
||||||
|
}
|
||||||
}
|
}
|
@ -21,6 +21,7 @@ import de.craftinc.borderprotection.Plugin;
|
|||||||
import de.craftinc.borderprotection.util.PlayerMovementUtil;
|
import de.craftinc.borderprotection.util.PlayerMovementUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -186,4 +187,15 @@ public class RectBorder extends Border implements ConfigurationSerializable
|
|||||||
{
|
{
|
||||||
return new Location[]{ rectPoint1, rectPoint2 };
|
return new Location[]{ rectPoint1, rectPoint2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location getCenter()
|
||||||
|
{
|
||||||
|
World w = rectPoint1.getWorld();
|
||||||
|
double x = Math.abs(rectPoint1.getX() - rectPoint2.getX()) / 2.0 + Math.min(rectPoint1.getX(), rectPoint2.getX());
|
||||||
|
double y = rectPoint1.getY();
|
||||||
|
double z = Math.abs(rectPoint1.getZ() - rectPoint2.getZ()) / 2.0 + Math.min(rectPoint1.getZ(), rectPoint2.getZ());
|
||||||
|
|
||||||
|
return new Location(w, x, y, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user