Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.firefly.BuildersPlot;
- import org.bukkit.Location;
- import org.bukkit.World;
- public class Zone {
- int x1;
- int x2;
- int y1;
- int y2;
- int z1;
- int z2;
- String world;
- String name;
- public Zone(String name, String world, int x1, int y1, int z1, int x2, int y2, int z2) {
- this.x1 = x1;
- this.y1 = y1;
- this.z1 = z1;
- this.x2 = x2;
- this.y2 = y2;
- this.z2 = z2;
- this.world = world;
- this.name = name;
- }
- public String getName() {
- return name;
- }
- public boolean isIn(Location location) {
- if (!location.getWorld().getName().equals(world)) {
- return false;
- }
- int posX = location.getBlockX();
- int posY = location.getBlockY();
- int posZ = location.getBlockZ();
- //Check if the given X-coordinate is within the two X-coordinates of the zone.
- if (x1 < x2) {
- if (posX < x1 || x2 < posX) {
- return false;
- }
- } else {
- if (posX < x2 || x1 < posX) {
- return false;
- }
- }
- //Check if the given Z-coordinate is within the two Z-coordinates of the zone.
- if (z1 < z2) {
- if (posZ < z1 || z2 < posZ) {
- return false;
- }
- } else {
- if (posZ < z2 || z1 < posZ) {
- return false;
- }
- }
- //Check if the given Y-coordinate is within the two Y-coordinates of the zone.
- if (y1 < y2) {
- if (posY < y1 || y2 < posY) {
- return false;
- }
- } else {
- if (posY < y2 || y1 < posY) {
- return false;
- }
- }
- return true;
- }
- }
Add Comment
Please, Sign In to add comment