Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class House {
- private String id;
- private Player player;
- private Location MinimumPoint;
- private Location MaximumPoint;
- public House(Player player, Location l1, Location l2) {
- this.id = player.getUniqueId().toString();
- this.player = player;
- this.MinimumPoint = l1;
- this.MaximumPoint = l2;
- Manager.Houses.put(id, this);
- }
- public House(String id, Location l1, Location l2) {
- this.id = id;
- this.MinimumPoint = l1;
- this.MaximumPoint = l2;
- Manager.Houses.put(id, this);
- }
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public Player getPlayer() {
- return player;
- }
- public void setPlayer(Player player) {
- this.player = player;
- }
- public Location getMinimumPoint() {
- return MinimumPoint;
- }
- public void setMinimumPoint(Location minimumPoint) {
- MinimumPoint = minimumPoint;
- }
- public Location getMaximumPoint() {
- return MaximumPoint;
- }
- public void setMaximumPoint(Location maximumPoint) {
- MaximumPoint = maximumPoint;
- }
- public boolean isOwner(Player p) {
- return isOnline() && this.player.equals(p);
- }
- public boolean isOnline() {
- return this.player != null;
- }
- }
- public class Manager {
- public static HashMap<String, House> Houses = new HashMap<>();
- public static boolean hasHouse(Player player) {
- return Houses.containsKey(player.getUniqueId().toString());
- }
- public House getHouse(Player player) {
- return Houses.get(player.getUniqueId().toString());
- }
- public House getHouseLocation(Location loc) {
- if (!Houses.isEmpty()) {
- for (House house : Houses.values()) {
- if (house.getMaximumPoint().getWorld().equals(loc.getWorld())) {
- if (house.getMinimumPoint().getBlockX() <= loc.getBlockX() && loc.getBlockX() <= house.getMaximumPoint().getBlockX()) {
- if (house.getMinimumPoint().getBlockY() <= loc.getBlockY() && loc.getBlockY() <= house.getMaximumPoint().getBlockY()) {
- if (house.getMinimumPoint().getBlockZ() <= loc.getBlockZ() && loc.getBlockZ() <= house.getMaximumPoint().getBlockZ()) {
- return house;
- }
- }
- }
- }
- }
- } return null;
- }
- public boolean isHouseowner(Player player) {
- Location loc = player.getLocation();
- if (hasHouse(player)) {
- House house = getHouse(player);
- if (house.getMaximumPoint().getWorld().equals(loc.getWorld())) {
- if (house.getMinimumPoint().getBlockX() <= loc.getBlockX() && loc.getBlockX() <= house.getMaximumPoint().getBlockX()) {
- if (house.getMinimumPoint().getBlockY() <= loc.getBlockY() && loc.getBlockY() <= house.getMaximumPoint().getBlockY()) {
- if (house.getMinimumPoint().getBlockZ() <= loc.getBlockZ() && loc.getBlockZ() <= house.getMaximumPoint().getBlockZ()) {
- return true;
- }
- }
- }
- }
- } return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement