mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-28 03:09:14 +00:00
Add removepos command to integration
This commit is contained in:
@@ -50,8 +50,8 @@ public abstract class RPGRegionsRegion {
|
||||
return this.points.add(location);
|
||||
}
|
||||
|
||||
public void removePoint(final Location location) {
|
||||
this.points.remove(location);
|
||||
public boolean removePoint(final Location location) {
|
||||
return this.points.remove(location);
|
||||
}
|
||||
|
||||
public boolean isWithinBounds(final Player player) {
|
||||
|
||||
@@ -129,11 +129,41 @@ public class RPGRegionsIntegrationCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
region.addPoint(location);
|
||||
if (!region.addPoint(location)) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not add a point to that region because it exceeds the size for its type.");
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + "Added point to " + region.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@CommandDescription("Removes a position from a region.")
|
||||
@CommandMethod("rpgri|rpgrintegration removepos <region> [location]")
|
||||
public void onRemovePos(final CommandSender sender,
|
||||
@Argument("region") final RPGRegionsRegion region,
|
||||
@Argument("location") @Nullable Location location) {
|
||||
if (sender instanceof Player player && location == null) {
|
||||
for (Location point : region.getPoints()) {
|
||||
if (point.distanceSquared(player.getLocation()) <= 2) {
|
||||
player.sendMessage(ChatColor.GREEN + "Removed point from " + region.getName() + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.sendMessage(ChatColor.RED + "Could not remove that point from the region because it does not exist.");
|
||||
} else {
|
||||
if (location == null) {
|
||||
sender.sendMessage(ChatColor.RED + "You need to specify the world, x, y, z of the point.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!region.removePoint(location)) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not remove a point from the region because it does not exist.");
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + "Removed point from " + region.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@CommandDescription("Sets the priority of a region. Higher priority regions override lower priority ones in the same location.")
|
||||
@CommandMethod("rpgri|rpgrintegration setpriority <region> <priority>")
|
||||
public void onSetPriority(final Player player,
|
||||
|
||||
Reference in New Issue
Block a user