Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. public class House {
  2.  
  3. private String id;
  4. private Player player;
  5. private Location MinimumPoint;
  6. private Location MaximumPoint;
  7.  
  8.  
  9.  
  10.  
  11. public House(Player player, Location l1, Location l2) {
  12. this.id = player.getUniqueId().toString();
  13. this.player = player;
  14. this.MinimumPoint = l1;
  15. this.MaximumPoint = l2;
  16. Manager.Houses.put(id, this);
  17. }
  18.  
  19.  
  20. public House(String id, Location l1, Location l2) {
  21. this.id = id;
  22. this.MinimumPoint = l1;
  23. this.MaximumPoint = l2;
  24. Manager.Houses.put(id, this);
  25. }
  26.  
  27.  
  28.  
  29.  
  30.  
  31. public String getId() {
  32. return id;
  33. }
  34.  
  35. public void setId(String id) {
  36. this.id = id;
  37. }
  38.  
  39.  
  40. public Player getPlayer() {
  41. return player;
  42. }
  43.  
  44.  
  45. public void setPlayer(Player player) {
  46. this.player = player;
  47. }
  48.  
  49.  
  50. public Location getMinimumPoint() {
  51. return MinimumPoint;
  52. }
  53.  
  54.  
  55. public void setMinimumPoint(Location minimumPoint) {
  56. MinimumPoint = minimumPoint;
  57. }
  58.  
  59.  
  60. public Location getMaximumPoint() {
  61. return MaximumPoint;
  62. }
  63.  
  64.  
  65. public void setMaximumPoint(Location maximumPoint) {
  66. MaximumPoint = maximumPoint;
  67. }
  68.  
  69.  
  70. public boolean isOwner(Player p) {
  71. return isOnline() && this.player.equals(p);
  72. }
  73.  
  74.  
  75. public boolean isOnline() {
  76. return this.player != null;
  77. }
  78. }
  79.  
  80.  
  81.  
  82. public class Manager {
  83.  
  84.  
  85.  
  86. public static HashMap<String, House> Houses = new HashMap<>();
  87.  
  88.  
  89. public static boolean hasHouse(Player player) {
  90. return Houses.containsKey(player.getUniqueId().toString());
  91. }
  92.  
  93.  
  94. public House getHouse(Player player) {
  95. return Houses.get(player.getUniqueId().toString());
  96. }
  97.  
  98.  
  99. public House getHouseLocation(Location loc) {
  100. if (!Houses.isEmpty()) {
  101. for (House house : Houses.values()) {
  102. if (house.getMaximumPoint().getWorld().equals(loc.getWorld())) {
  103. if (house.getMinimumPoint().getBlockX() <= loc.getBlockX() && loc.getBlockX() <= house.getMaximumPoint().getBlockX()) {
  104. if (house.getMinimumPoint().getBlockY() <= loc.getBlockY() && loc.getBlockY() <= house.getMaximumPoint().getBlockY()) {
  105. if (house.getMinimumPoint().getBlockZ() <= loc.getBlockZ() && loc.getBlockZ() <= house.getMaximumPoint().getBlockZ()) {
  106. return house;
  107. }
  108. }
  109. }
  110. }
  111. }
  112. } return null;
  113. }
  114.  
  115.  
  116. public boolean isHouseowner(Player player) {
  117. Location loc = player.getLocation();
  118. if (hasHouse(player)) {
  119. House house = getHouse(player);
  120. if (house.getMaximumPoint().getWorld().equals(loc.getWorld())) {
  121. if (house.getMinimumPoint().getBlockX() <= loc.getBlockX() && loc.getBlockX() <= house.getMaximumPoint().getBlockX()) {
  122. if (house.getMinimumPoint().getBlockY() <= loc.getBlockY() && loc.getBlockY() <= house.getMaximumPoint().getBlockY()) {
  123. if (house.getMinimumPoint().getBlockZ() <= loc.getBlockZ() && loc.getBlockZ() <= house.getMaximumPoint().getBlockZ()) {
  124. return true;
  125. }
  126. }
  127. }
  128. }
  129. } return false;
  130. }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement