Add option to ignore water when saving blueprint

This commit is contained in:
tastybento 2025-01-21 19:58:13 -08:00
parent caf32dae02
commit 1735638e6a
3 changed files with 18 additions and 9 deletions

View File

@ -41,14 +41,15 @@ public class AdminBlueprintCopyCommand extends CompositeCommand
boolean copyAir = args.stream().anyMatch(key -> key.equalsIgnoreCase("air"));
boolean copyBiome = args.stream().anyMatch(key -> key.equalsIgnoreCase("biome"));
boolean noWater = args.stream().anyMatch(key -> key.equalsIgnoreCase("nowater"));
return clipboard.copy(user, copyAir, copyBiome);
return clipboard.copy(user, copyAir, copyBiome, noWater);
}
@Override
public Optional<List<String>> tabComplete(User user, String alias, List<String> args)
{
return Optional.of(List.of("air", "biome"));
return Optional.of(List.of("air", "biome", "nowater"));
}
}

View File

@ -102,7 +102,7 @@ public class BlueprintClipboard {
* @param user - user
* @return true if successful, false if pos1 or pos2 are undefined.
*/
public boolean copy(User user, boolean copyAir, boolean copyBiome) {
public boolean copy(User user, boolean copyAir, boolean copyBiome, boolean noWater) {
if (copying) {
user.sendMessage("commands.admin.blueprint.mid-copy");
return false;
@ -137,11 +137,13 @@ public class BlueprintClipboard {
int speed = plugin.getSettings().getPasteSpeed();
List<Vector> vectorsToCopy = getVectors(toCopy);
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> copyAsync(world, user, vectorsToCopy, speed, copyAir, copyBiome));
Bukkit.getScheduler().runTaskAsynchronously(plugin,
() -> copyAsync(world, user, vectorsToCopy, speed, copyAir, copyBiome, noWater));
return true;
}
private void copyAsync(World world, User user, List<Vector> vectorsToCopy, int speed, boolean copyAir, boolean copyBiome) {
private void copyAsync(World world, User user, List<Vector> vectorsToCopy, int speed, boolean copyAir,
boolean copyBiome, boolean noWater) {
copying = false;
// FancyNpcs
if (npc.isPresent()) {
@ -167,7 +169,7 @@ public class BlueprintClipboard {
.filter(e -> new Vector(e.getLocation().getBlockX(), e.getLocation().getBlockY(),
e.getLocation().getBlockZ()).equals(v))
.toList();
if (copyBlock(v.toLocation(world), copyAir, copyBiome, ents)) {
if (copyBlock(v.toLocation(world), copyAir, copyBiome, ents, noWater)) {
count++;
}
});
@ -208,11 +210,14 @@ public class BlueprintClipboard {
return r;
}
private boolean copyBlock(Location l, boolean copyAir, boolean copyBiome, List<Entity> ents) {
private boolean copyBlock(Location l, boolean copyAir, boolean copyBiome, List<Entity> ents, boolean noWater) {
Block block = l.getBlock();
if (!copyAir && block.getType().equals(Material.AIR) && ents.isEmpty()) {
return false;
}
if (noWater && block.getType() == Material.WATER && ents.isEmpty()) {
return false;
}
// Create position
Vector origin2 = origin == null ? new Vector(0,0,0) : origin;
int x = l.getBlockX() - origin2.getBlockX();
@ -231,6 +236,9 @@ public class BlueprintClipboard {
if (!copyAir && block.getType().equals(Material.AIR) && !ents.isEmpty()) {
return true;
}
if (noWater && block.getType().equals(Material.WATER) && !ents.isEmpty()) {
return true;
}
BlueprintBlock b = bluePrintBlock(pos, block, copyBiome);
if (b != null) {
this.bpBlocks.put(pos, b);

View File

@ -352,8 +352,8 @@ commands:
mid-copy: '&c You are mid-copy. Wait until the copy is done.'
copied-percent: '&6 Copied [number]%'
copy:
parameters: '[air]'
description: copy the clipboard set by pos1 and pos2 and optionally the air
parameters: '[air] [biome] [nowater]'
description: copy the clipboard set by pos1 and pos2 and optionally the air, biome, and water
blocks
delete:
parameters: <name>