Guest User

Untitled

a guest
May 27th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. package me.firefly.BuildersPlot;
  2.  
  3. import org.bukkit.Location;
  4. import org.bukkit.World;
  5.  
  6. public class Zone {
  7. int x1;
  8. int x2;
  9. int y1;
  10. int y2;
  11. int z1;
  12. int z2;
  13. String world;
  14. String name;
  15.  
  16. public Zone(String name, String world, int x1, int y1, int z1, int x2, int y2, int z2) {
  17. this.x1 = x1;
  18. this.y1 = y1;
  19. this.z1 = z1;
  20. this.x2 = x2;
  21. this.y2 = y2;
  22. this.z2 = z2;
  23. this.world = world;
  24. this.name = name;
  25. }
  26.  
  27. public String getName() {
  28. return name;
  29. }
  30.  
  31.  
  32. public boolean isIn(Location location) {
  33. if (!location.getWorld().getName().equals(world)) {
  34. return false;
  35. }
  36.  
  37. int posX = location.getBlockX();
  38. int posY = location.getBlockY();
  39. int posZ = location.getBlockZ();
  40.  
  41. //Check if the given X-coordinate is within the two X-coordinates of the zone.
  42. if (x1 < x2) {
  43. if (posX < x1 || x2 < posX) {
  44. return false;
  45. }
  46. } else {
  47. if (posX < x2 || x1 < posX) {
  48. return false;
  49. }
  50. }
  51.  
  52. //Check if the given Z-coordinate is within the two Z-coordinates of the zone.
  53. if (z1 < z2) {
  54. if (posZ < z1 || z2 < posZ) {
  55. return false;
  56. }
  57. } else {
  58. if (posZ < z2 || z1 < posZ) {
  59. return false;
  60. }
  61. }
  62.  
  63. //Check if the given Y-coordinate is within the two Y-coordinates of the zone.
  64. if (y1 < y2) {
  65. if (posY < y1 || y2 < posY) {
  66. return false;
  67. }
  68. } else {
  69. if (posY < y2 || y1 < posY) {
  70. return false;
  71. }
  72. }
  73. return true;
  74. }
  75. }
Add Comment
Please, Sign In to add comment