bentobox/src/main/java/world/bentobox/bentobox/blueprints/BlueprintClipboard.java

444 lines
15 KiB
Java
Raw Normal View History

package world.bentobox.bentobox.blueprints;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
2018-06-30 19:08:16 +02:00
import org.bukkit.World;
import org.bukkit.block.Banner;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
2018-08-03 05:39:57 +02:00
import org.bukkit.block.CreatureSpawner;
import org.bukkit.block.Sign;
import org.bukkit.block.sign.Side;
import org.bukkit.entity.AbstractHorse;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.Horse;
2018-06-30 19:08:16 +02:00
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Villager;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Attachable;
import org.bukkit.material.Colorable;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.Vector;
2019-04-28 13:55:54 +02:00
import org.eclipse.jdt.annotation.NonNull;
2019-04-28 13:50:15 +02:00
import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintCreatureSpawner;
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintEntity;
import world.bentobox.bentobox.hooks.MythicMobsHook;
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
2018-08-12 11:28:36 +02:00
/**
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
* The clipboard provides the holding spot for an active blueprint that is being
* manipulated by a user. It supports copying from the world and setting of coordinates
* such as the bounding box around the cuboid copy area.
* Pasting is done by the {@link BlueprintPaster} class.
2018-08-12 11:28:36 +02:00
* @author tastybento
2019-04-28 13:50:15 +02:00
* @since 1.5.0
2018-08-12 11:28:36 +02:00
*/
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
public class BlueprintClipboard {
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
private @Nullable Blueprint blueprint;
2019-04-28 13:50:15 +02:00
private @Nullable Location pos1;
private @Nullable Location pos2;
private @Nullable Vector origin;
private BukkitTask copyTask;
private int count;
private boolean copying;
private int index;
private int lastPercentage;
private final Map<Vector, List<BlueprintEntity>> bpEntities = new LinkedHashMap<>();
private final Map<Vector, BlueprintBlock> bpAttachable = new LinkedHashMap<>();
private final Map<Vector, BlueprintBlock> bpBlocks = new LinkedHashMap<>();
private final BentoBox plugin = BentoBox.getInstance();
private Optional<MythicMobsHook> mmh;
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
/**
* Create a clipboard for blueprint
* @param blueprint - the blueprint to load into the clipboard
*/
public BlueprintClipboard(@NonNull Blueprint blueprint) {
this.blueprint = blueprint;
// MythicMobs
2024-03-11 06:36:42 +01:00
mmh = plugin.getHooks().getHook("MythicMobs").filter(MythicMobsHook.class::isInstance)
.map(MythicMobsHook.class::cast);
}
public BlueprintClipboard() {
// MythicMobs
2024-03-11 06:36:42 +01:00
mmh = plugin.getHooks().getHook("MythicMobs").filter(MythicMobsHook.class::isInstance)
.map(MythicMobsHook.class::cast);
}
/**
* Copy the blocks between pos1 and pos2 into the clipboard for a user.
2019-04-28 13:55:54 +02:00
* This will erase any previously registered data from the clipboard.
* Copying is done async.
* @param user - user
2019-04-28 13:50:15 +02:00
* @return true if successful, false if pos1 or pos2 are undefined.
*/
public boolean copy(User user, boolean copyAir, boolean copyBiome) {
if (copying) {
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
user.sendMessage("commands.admin.blueprint.mid-copy");
return false;
}
if (pos1 == null || pos2 == null) {
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
user.sendMessage("commands.admin.blueprint.need-pos1-pos2");
return false;
}
if (origin == null) {
setOrigin(user.getLocation().toVector());
}
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
user.sendMessage("commands.admin.blueprint.copying");
2018-06-30 19:08:16 +02:00
// World
World world = pos1.getWorld();
if (world == null) {
return false;
}
// Clear the clipboard
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
blueprint = new Blueprint();
bpEntities.clear();
bpAttachable.clear();
bpBlocks.clear();
2018-06-30 19:08:16 +02:00
count = 0;
index = 0;
lastPercentage = 0;
BoundingBox toCopy = BoundingBox.of(pos1, pos2);
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
blueprint.setxSize((int)toCopy.getWidthX());
blueprint.setySize((int)toCopy.getHeight());
blueprint.setzSize((int)toCopy.getWidthZ());
2019-07-28 02:19:04 +02:00
int speed = plugin.getSettings().getPasteSpeed();
List<Vector> vectorsToCopy = getVectors(toCopy);
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> copyAsync(world, user, vectorsToCopy, speed, copyAir, copyBiome));
2019-07-28 02:19:04 +02:00
return true;
}
2018-06-30 19:08:16 +02:00
private void copyAsync(World world, User user, List<Vector> vectorsToCopy, int speed, boolean copyAir, boolean copyBiome) {
2019-07-28 02:19:04 +02:00
copying = false;
copyTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
if (copying) {
return;
}
copying = true;
vectorsToCopy.stream().skip(index).limit(speed).forEach(v -> {
List<LivingEntity> ents = world.getLivingEntities().stream()
.filter(Objects::nonNull)
.filter(e -> !(e instanceof Player))
.filter(e -> new Vector(Math.rint(e.getLocation().getX()),
Math.rint(e.getLocation().getY()),
Math.rint(e.getLocation().getZ())).equals(v))
.toList();
if (copyBlock(v.toLocation(world), copyAir, copyBiome, ents)) {
2019-07-28 02:19:04 +02:00
count++;
}
2019-07-28 02:19:04 +02:00
});
index += speed;
int percent = (int)(index * 100 / (double)vectorsToCopy.size());
if (percent != lastPercentage && percent % 10 == 0) {
user.sendMessage("commands.admin.blueprint.copied-percent", TextVariables.NUMBER, String.valueOf(percent));
lastPercentage = percent;
}
if (index > vectorsToCopy.size()) {
copyTask.cancel();
assert blueprint != null;
2019-07-28 02:19:04 +02:00
blueprint.setAttached(bpAttachable);
blueprint.setBlocks(bpBlocks);
blueprint.setEntities(bpEntities);
user.sendMessage("general.success");
user.sendMessage("commands.admin.blueprint.copied-blocks", TextVariables.NUMBER, String.valueOf(count));
}
copying = false;
}, 0L, 1L);
}
/**
* Get all the x,y,z coords that must be copied
* @param b - bounding box
* @return - list of vectors
*/
protected List<Vector> getVectors(BoundingBox b) {
List<Vector> r = new ArrayList<>();
for (int y = (int) Math.floor(b.getMinY()); y <= b.getMaxY(); y++) {
for (int x = (int) Math.floor(b.getMinX()); x <= b.getMaxX(); x++) {
for (int z = (int) Math.floor(b.getMinZ()); z <= b.getMaxZ(); z++) {
r.add(new Vector(x,y,z));
}
}
}
return r;
}
private boolean copyBlock(Location l, boolean copyAir, boolean copyBiome, Collection<LivingEntity> entities) {
Block block = l.getBlock();
2018-06-30 19:08:16 +02:00
if (!copyAir && block.getType().equals(Material.AIR) && entities.isEmpty()) {
return false;
}
// Create position
2021-10-12 02:27:24 +02:00
Vector origin2 = origin == null ? new Vector(0,0,0) : origin;
int x = l.getBlockX() - origin2.getBlockX();
int y = l.getBlockY() - origin2.getBlockY();
int z = l.getBlockZ() - origin2.getBlockZ();
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
Vector pos = new Vector(x, y, z);
2018-06-30 19:08:16 +02:00
// Set entities
List<BlueprintEntity> bpEnts = setEntities(entities);
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
// Store
if (!bpEnts.isEmpty()) {
bpEntities.put(pos, bpEnts);
2018-06-30 19:08:16 +02:00
}
// Return if this is just air block
if (!copyAir && block.getType().equals(Material.AIR) && !entities.isEmpty()) {
return true;
}
BlueprintBlock b = bluePrintBlock(pos, block, copyBiome);
if (b != null) {
this.bpBlocks.put(pos, b);
}
return true;
}
private BlueprintBlock bluePrintBlock(Vector pos, Block block, boolean copyBiome) {
// Block state
2019-04-28 13:50:15 +02:00
BlockState blockState = block.getState();
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
BlueprintBlock b = new BlueprintBlock(block.getBlockData().getAsString());
if (copyBiome) {
// Biome
b.setBiome(block.getBiome());
}
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
// Signs
if (blockState instanceof Sign sign) {
for (Side side : Side.values()) {
b.setSignLines(side, Arrays.asList(sign.getSide(side).getLines()));
b.setGlowingText(side, sign.getSide(side).isGlowingText());
}
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
}
2018-08-02 07:02:53 +02:00
// Set block data
if (blockState.getData() instanceof Attachable) {
// Placeholder for attachment
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
bpBlocks.put(pos, new BlueprintBlock("minecraft:air"));
bpAttachable.put(pos, b);
return null;
}
2018-07-03 07:01:37 +02:00
if (block.getType().equals(Material.BEDROCK)) {
// Find highest bedrock
if(blueprint.getBedrock() == null) {
blueprint.setBedrock(pos);
} else {
if (pos.getBlockY() > blueprint.getBedrock().getBlockY()) {
blueprint.setBedrock(pos);
}
}
2018-07-03 07:01:37 +02:00
}
2018-08-02 07:02:53 +02:00
// Chests
if (blockState instanceof InventoryHolder ih) {
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
b.setInventory(new HashMap<>());
for (int i = 0; i < ih.getInventory().getSize(); i++) {
ItemStack item = ih.getInventory().getItem(i);
if (item != null) {
b.getInventory().put(i, item);
}
}
}
if (blockState instanceof CreatureSpawner spawner) {
b.setCreatureSpawner(getSpawner(spawner));
2018-08-03 05:39:57 +02:00
}
// Banners
2022-03-31 23:12:47 +02:00
if (blockState instanceof Banner banner) {
b.setBannerPatterns(banner.getPatterns());
}
return b;
}
private BlueprintCreatureSpawner getSpawner(CreatureSpawner spawner) {
BlueprintCreatureSpawner cs = new BlueprintCreatureSpawner();
cs.setSpawnedType(spawner.getSpawnedType());
cs.setDelay(spawner.getDelay());
cs.setMaxNearbyEntities(spawner.getMaxNearbyEntities());
cs.setMaxSpawnDelay(spawner.getMaxSpawnDelay());
cs.setMinSpawnDelay(spawner.getMinSpawnDelay());
cs.setRequiredPlayerRange(spawner.getRequiredPlayerRange());
cs.setSpawnRange(spawner.getSpawnRange());
return cs;
}
private List<BlueprintEntity> setEntities(Collection<LivingEntity> entities) {
List<BlueprintEntity> bpEnts = new ArrayList<>();
for (LivingEntity entity: entities) {
BlueprintEntity bpe = new BlueprintEntity();
bpe.setType(entity.getType());
bpe.setCustomName(entity.getCustomName());
2022-03-31 23:12:47 +02:00
if (entity instanceof Villager villager) {
setVillager(villager, bpe);
}
Code clean up from Sonar Cloud analysis (#2068) * Code clean up from Sonar Cloud analysis * Fix tests * Remove code smell * Rename "island" which hides the field declared at line 25. * Removed code smells. * Rename variable record to rec Renamed "record" variable to not match a restricted identifier. Restricted Identifiers should not be used as identifiers. "record" is using in Java 16. * Added private constructor to prevent instantiation of static class Changed variable name to rec instead of restricted "record". * Remove Blueprint code smells. * Use a record for database settings constructor Code smell: Methods should not have too many parameters. I'm not sure what methods are using this class though. * Update MyWorlds version The POM for MyWorlds is invalid and causes a warning, but this still persists with this version. * Extracted nested try block into a separate method. Makes it clear when reading the code what might be caught * Extracted nested try block into a separate method. * Fixed JavaDoc /** instead of just /* * Extracted nested try block into a separate method. * Refactored to not assign loop counter from within the loop body. * Better delete option. With results. That said, this is legacy code to handle an issue that occurred a long time ago and this whole set of code can probably be removed. * Catch Exceptions not Throwable * Log error with BentoBox logError * Use computeIfAbsent Using these instead leads to cleaner and more readable code. * User can no longer be null * Added the missing @Deprecated annotation and @since ref * Added @since reference * Merge if statements * Use BentoBox error logging. * Added JavaDoc @since * Remove deprecated class and move used class * Remove deprecated WoodType and use Type. * Remove unused import * Extracted nested try block into a separate method. * Comment empty default statement * Clean up logic; avoid switch * Use Java instead of Guava * private constructor to hide the implicit public one. * Private constructor to hide the implicit public one. Merged if statement. * Add comment * if merge * Make variable constant * Remove unused imports * Remove deprecated and unused method * Remove unused import * Typo * Remove instanceof and cast * Remove superfluous null check * Put constant at bottom of file because @BONNe likes it there. * Simplify particle validation code
2023-01-01 01:41:17 +01:00
if (entity instanceof Colorable c && c.getColor() != null) {
bpe.setColor(c.getColor());
}
if (entity instanceof Tameable tameable) {
bpe.setTamed(tameable.isTamed());
}
if (entity instanceof ChestedHorse chestedHorse) {
bpe.setChest(chestedHorse.isCarryingChest());
}
// Only set if child. Most animals are adults
if (entity instanceof Ageable ageable && !ageable.isAdult()) {
bpe.setAdult(false);
}
if (entity instanceof AbstractHorse horse) {
bpe.setDomestication(horse.getDomestication());
bpe.setInventory(new HashMap<>());
for (int i = 0; i < horse.getInventory().getSize(); i++) {
ItemStack item = horse.getInventory().getItem(i);
if (item != null) {
bpe.getInventory().put(i, item);
}
}
}
if (entity instanceof Horse horse) {
bpe.setStyle(horse.getStyle());
}
mmh.filter(mm -> mm.isMythicMob(entity)).map(mm -> mm.getMythicMob(entity))
2024-03-16 02:47:14 +01:00
.ifPresent(bpe::setMythicMobsRecord);
bpEnts.add(bpe);
}
return bpEnts;
}
/**
* Set the villager stats
2022-03-31 23:12:47 +02:00
* @param v - villager
* @param bpe - Blueprint Entity
*/
2022-03-31 23:12:47 +02:00
private void setVillager(Villager v, BlueprintEntity bpe) {
bpe.setExperience(v.getVillagerExperience());
bpe.setLevel(v.getVillagerLevel());
bpe.setProfession(v.getProfession());
bpe.setVillagerType(v.getVillagerType());
}
/**
* @return the origin
*/
2019-04-28 13:50:15 +02:00
@Nullable
public Vector getOrigin() {
return origin;
}
/**
* @return the pos1
*/
2019-04-28 13:50:15 +02:00
@Nullable
public Location getPos1() {
return pos1;
}
/**
* @return the pos2
*/
2019-04-28 13:50:15 +02:00
@Nullable
public Location getPos2() {
return pos2;
}
2018-06-03 04:54:41 +02:00
public boolean isFull() {
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
return blueprint != null;
}
/**
* @param origin the origin to set
*/
public void setOrigin(@Nullable Vector origin) {
this.origin = origin;
}
/**
* @param pos1 the pos1 to set
*/
2019-04-28 13:50:15 +02:00
public void setPos1(@Nullable Location pos1) {
origin = null;
2019-05-19 01:02:12 +02:00
if (pos1 != null) {
final int minHeight = pos1.getWorld() == null ? 0 : pos1.getWorld().getMinHeight();
final int maxHeight = pos1.getWorld() == null ? 255 : pos1.getWorld().getMaxHeight();
Code clean up from Sonar Cloud analysis (#2068) * Code clean up from Sonar Cloud analysis * Fix tests * Remove code smell * Rename "island" which hides the field declared at line 25. * Removed code smells. * Rename variable record to rec Renamed "record" variable to not match a restricted identifier. Restricted Identifiers should not be used as identifiers. "record" is using in Java 16. * Added private constructor to prevent instantiation of static class Changed variable name to rec instead of restricted "record". * Remove Blueprint code smells. * Use a record for database settings constructor Code smell: Methods should not have too many parameters. I'm not sure what methods are using this class though. * Update MyWorlds version The POM for MyWorlds is invalid and causes a warning, but this still persists with this version. * Extracted nested try block into a separate method. Makes it clear when reading the code what might be caught * Extracted nested try block into a separate method. * Fixed JavaDoc /** instead of just /* * Extracted nested try block into a separate method. * Refactored to not assign loop counter from within the loop body. * Better delete option. With results. That said, this is legacy code to handle an issue that occurred a long time ago and this whole set of code can probably be removed. * Catch Exceptions not Throwable * Log error with BentoBox logError * Use computeIfAbsent Using these instead leads to cleaner and more readable code. * User can no longer be null * Added the missing @Deprecated annotation and @since ref * Added @since reference * Merge if statements * Use BentoBox error logging. * Added JavaDoc @since * Remove deprecated class and move used class * Remove deprecated WoodType and use Type. * Remove unused import * Extracted nested try block into a separate method. * Comment empty default statement * Clean up logic; avoid switch * Use Java instead of Guava * private constructor to hide the implicit public one. * Private constructor to hide the implicit public one. Merged if statement. * Add comment * if merge * Make variable constant * Remove unused imports * Remove deprecated and unused method * Remove unused import * Typo * Remove instanceof and cast * Remove superfluous null check * Put constant at bottom of file because @BONNe likes it there. * Simplify particle validation code
2023-01-01 01:41:17 +01:00
if (pos1.getBlockY() < minHeight)
{
pos1.setY(minHeight);
2019-05-19 01:02:12 +02:00
}
if (pos1.getBlockY() > maxHeight)
{
pos1.setY(maxHeight);
2019-05-19 01:02:12 +02:00
}
}
this.pos1 = pos1;
}
/**
* @param pos2 the pos2 to set
*/
2019-04-28 13:50:15 +02:00
public void setPos2(@Nullable Location pos2) {
origin = null;
2019-05-19 01:02:12 +02:00
if (pos2 != null) {
final int minHeight = pos2.getWorld() == null ? 0 : pos2.getWorld().getMinHeight();
final int maxHeight = pos2.getWorld() == null ? 255 : pos2.getWorld().getMaxHeight();
if (pos2.getBlockY() < minHeight)
{
pos2.setY(minHeight);
2019-05-19 01:02:12 +02:00
}
if (pos2.getBlockY() > maxHeight)
{
pos2.setY(maxHeight);
2019-05-19 01:02:12 +02:00
}
}
this.pos2 = pos2;
}
/**
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
* @return the blueprint
*/
2021-09-18 17:15:15 +02:00
public @Nullable Blueprint getBlueprint() {
Implemeted Blueprint bundles and blueprints (#672) * A prototype for Blueprint bundles and blueprints This stores blueprints inside bundles. Each bundle can have up to 3 blueprints defines by the World.Environment. This is not a finished manager. It just handles all the saving and loading side of things. I thought this would help you so you can then concentrate on the UI. * WIP: Copy blocks to Blueprint done. * WIP Pasting done. * WIP: Added BlueprintsManager to ultimately replace SchemsManager. * Moved blueprint suffix and changed to .blu * Fixed unit test. * Now tested and working. Integrated with new island and resetting island. If there are no blueprint bundles or blueprints then a default bedrock set will be made and put in the game mode addon's blueprints folder. Still to do: enable schems to be loaded and pasted for legacy support. Add blueprints and a bundle to GameModeAddons like BSkyBlock. * Renamed most of the classes * Cleaned up clipboard and paster. * Further cleanup on blueprint clipboard and paster. * Merged blueprint classes into one package. * Put Blueprint data objects in their own package. Isolated schems classes for later removal. * Renamed admin command classes and changed locale files. * More clean up to remove schems * Schem to blueprints converter done. Converts schems to blueprint bundles and sets up a default set. Tested the happy-path. Need to do more testing on edge cases. * Added basic UI for development. Fixed bug with schem conversion. * Adds permissions into the blueprints. Fixes tests, cleans up some naming * Added IslandCreationPanel and created BlueprintManagementPanel * Fixed JSONDatabaseHandler's constructor being public * Made the Blueprints button in ManagementPanel open the Blueprint management panel * Fixed tests and ignored one (NPE)
2019-05-15 20:16:41 +02:00
return blueprint;
}
/**
* @param blueprint the blueprint to set
*/
public BlueprintClipboard setBlueprint(Blueprint blueprint) {
this.blueprint = blueprint;
return this;
}
}