9
0
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:
SamB440
2021-10-10 15:16:27 +01:00
parent 6f93f3174a
commit 4b9a1679ef
2 changed files with 15 additions and 0 deletions

View File

@@ -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());
}
}

View File

@@ -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());