# Solved Constructors

Discussion in 'Plugin Development' started by TerroDoor, Nov 18, 2019.

Not open for further replies.
1. Offline

### TerroDoor

@timtower
Code:
``` ArrayList<UUID> inspawn = new ArrayList<UUID>();

public boolean inSpawn(Location ploc) {
if (ploc == null) {
return false;
} else {
return ploc.getBlockX() >= pos1.getBlockX() && ploc.getBlockX() <= pos2.getBlockX()
&& ploc.getBlockY() >= pos1.getBlockY() && ploc.getBlockY() <= pos2.getBlockY()
&& ploc.getBlockZ() >= pos1.getBlockZ() && ploc.getBlockZ() <= pos2.getBlockZ();
}
}
public spawnregion() {
double minx = Math.min(pos1.getBlockX(), pos2.getBlockX());
double maxx = Math.max(pos1.getBlockX(), pos2.getBlockX());
double minz = Math.min(pos1.getBlockZ(), pos2.getBlockZ());
double maxz = Math.max(pos1.getBlockZ(), pos2.getBlockZ());
double miny = Math.min(pos1.getBlockY(), pos2.getBlockY());
double maxy = Math.max(pos1.getBlockY(), pos2.getBlockY());
this.pos1 = new Vector(minx, miny, minz);
this.pos2 = new Vector(maxx, maxy, maxz);
for (double x = minx; x <= maxx; x++) {
for (double y = miny; y <= maxy; y++) {
for (double z = minz; z <= maxz; z++) {
Location loc = new Location(w, x, y, z);
if (x == minx && x == maxx && z == minz && z == maxz) {
loc.getBlock().setType(Material.BLACK_WOOL);
} else {
loc.getBlock().setType(Material.AIR);
}
}
}
}
return;
}
@EventHandler
public void onMove(PlayerMoveEvent e) {
Player p = (Player)e.getPlayer();
Vector pvec = p.getLocation().toVector();

if (pvec.isInAABB(pos1, pos2)) {

p.sendMessage("in");
return;
} else {

p.sendMessage("out");
inspawn.remove(p.getUniqueId());
return;
}
}

```

#31
2. Online

### timtower Moderator Moderator

@TerroDoor You don't check the inspawn list for the message

#32
3. Offline

### TerroDoor

If inSpawn.contains?

Sent from my iPhone using Tapatalk

#33
4. Online

### timtower Moderator Moderator

#34
TerroDoor likes this.
5. Offline

### TerroDoor

@timtower
Thankyou so much, I’ve finally got it working! Marking thread as solved

Sent from my iPhone using Tapatalk

#35
timtower likes this.