mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2026-01-04 15:31:38 +00:00
Prevent adding already configured regions
This commit is contained in:
@@ -11,6 +11,16 @@ public class CuboidRegion extends RPGRegionsRegion {
|
||||
@Override
|
||||
public boolean isWithinBounds(Location location) {
|
||||
if (getPoints().size() < 2) return false;
|
||||
Location min = getPoints().get(0);
|
||||
Location max = getPoints().get(1);
|
||||
if (min.getY() > max.getY()) { // todo improve this
|
||||
max = getPoints().get(0);
|
||||
min = getPoints().get(1);
|
||||
removePoint(max);
|
||||
removePoint(min);
|
||||
addPoint(min);
|
||||
addPoint(max);
|
||||
}
|
||||
return location.toVector().isInAABB(getPoints().get(0).toVector(), getPoints().get(1).toVector());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,11 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getManagers().getRegionsCache().getConfiguredRegion(region).isPresent()) {
|
||||
player.sendMessage(StringUtils.colour("&cThat region is already configured."));
|
||||
return;
|
||||
}
|
||||
|
||||
ConfiguredRegion configuredRegion = new ConfiguredRegion(player.getWorld(), region, region, new ArrayList<>(),
|
||||
new ArrayList<>());
|
||||
configuredRegion.setLocation(player.getLocation());
|
||||
|
||||
Reference in New Issue
Block a user