Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package секрет;
- import секрет.Utils;
- import org.bukkit.Location;
- import org.bukkit.scheduler.BukkitTask;
- public class SafeZone {
- private Location loc;
- private final double radius;
- private BukkitTask task;
- public SafeZone(Location loc, double radius) {
- this.loc = loc;
- this.radius = radius;
- }
- public double getRadius() {
- return this.radius;
- }
- public void setLocation(Location loc) {
- this.loc = loc;
- }
- public Location getLocation() {
- return this.loc;
- }
- public boolean inRadius(SafeZone sz) {
- return this.inRadius(sz.getLocation());
- }
- public boolean inRadius(Location loc) {
- return this.loc.getWorld().equals(loc.getWorld()) && (this.loc.distance(loc) <= this.radius);
- }
- public void setTask(BukkitTask task) {
- this.task = task;
- }
- public BukkitTask getTask() {
- return task;
- }
- @Override
- public String toString() {
- return "SafeZone{" +
- ", loc=" + Utils.toMyString(this.loc, true) +
- ", radius=" + this.radius +
- '}';
- }
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- SafeZone safeZone = (SafeZone) o;
- return (Double.compare(safeZone.radius, radius) == 0) && (loc.equals(safeZone.loc));
- }
- @Override
- public int hashCode() {
- int result;
- long temp;
- result = loc.hashCode();
- temp = Double.doubleToLongBits(radius);
- result = 31 * result + (int) (temp ^ (temp >>> 32));
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement