Advertisement
Exception_Prototype

Untitled

Mar 9th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. package секрет;
  2.  
  3. import секрет.Utils;
  4. import org.bukkit.Location;
  5. import org.bukkit.scheduler.BukkitTask;
  6.  
  7. public class SafeZone {
  8.  
  9.     private Location loc;
  10.     private final double radius;
  11.     private BukkitTask task;
  12.  
  13.     public SafeZone(Location loc, double radius) {
  14.         this.loc = loc;
  15.         this.radius = radius;
  16.     }
  17.  
  18.     public double getRadius() {
  19.         return this.radius;
  20.     }
  21.  
  22.     public void setLocation(Location loc) {
  23.         this.loc = loc;
  24.     }
  25.  
  26.     public Location getLocation() {
  27.         return this.loc;
  28.     }
  29.  
  30.     public boolean inRadius(SafeZone sz) {
  31.         return this.inRadius(sz.getLocation());
  32.     }
  33.  
  34.     public boolean inRadius(Location loc) {
  35.         return this.loc.getWorld().equals(loc.getWorld()) && (this.loc.distance(loc) <= this.radius);
  36.     }
  37.  
  38.     public void setTask(BukkitTask task) {
  39.         this.task = task;
  40.     }
  41.  
  42.     public BukkitTask getTask() {
  43.         return task;
  44.     }
  45.  
  46.     @Override
  47.     public String toString() {
  48.         return "SafeZone{" +
  49.                 ", loc=" + Utils.toMyString(this.loc, true) +
  50.                 ", radius=" + this.radius +
  51.                 '}';
  52.     }
  53.  
  54.     @Override
  55.     public boolean equals(Object o) {
  56.         if (this == o) return true;
  57.         if (o == null || getClass() != o.getClass()) return false;
  58.         SafeZone safeZone = (SafeZone) o;
  59.         return (Double.compare(safeZone.radius, radius) == 0) && (loc.equals(safeZone.loc));
  60.     }
  61.  
  62.     @Override
  63.     public int hashCode() {
  64.         int result;
  65.         long temp;
  66.         result = loc.hashCode();
  67.         temp = Double.doubleToLongBits(radius);
  68.         result = 31 * result + (int) (temp ^ (temp >>> 32));
  69.         return result;
  70.     }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement