-
Notifications
You must be signed in to change notification settings - Fork 2
Developer API The basics
Cosmos is a world template management system, which handles all the complicated logic behind the process of creating a template, choosing a location to paste it on, actually pasting it and handling any unloads, as well as storing the templates in a database.
A TemplatedArea is a fixed-size representation of a pre-defined area of blocks that can be pasted in any given location. Here's a basic example on how to paste a template.
Player player = ...;
TemplatedArea template = ...;
Location pasteLocation = player.getLocation();
template.paste(pasteLocation).thenRun(() -> {
player.sendMessage("The template has finished pasting!");
});
A PastedArea is an extension of a TemplatedArea, but contains information about where it is located.
A PastedArea is created when a template is pasted, and is returned on the Future provided by the paste
method.
Here's a basic example on how to unload a template.
Player player = ...;
template.paste(pasteLocation).thenAccept(pastedArea -> {
// store this somewhere, or just unload after a bit
player.sendMessage("The area has been pasted.");
pastedArea.unload().thenRun(() -> {
player.sendMessage("The area has been unloaded.");
});
});
Check the Development API - Serializers wiki for that
Check the Development API - Data Containers wiki for that