WorldTemplateAPI is a Java library for Bukkit plugins that makes it easy to create and manage world templates on your Minecraft server. It works with Multiverse-Core to help you copy and load worlds without the hassle.
- Create Templates: Make templates from any world on your server.
- Load New Worlds: Create fresh worlds from your saved templates.
- Delete Templates: Remove templates you don't need anymore.
- Custom Storage: Choose where you want to store your templates.
- Works with Multiverse-Core: Connects smoothly with Multiverse-Core for better world management.
- Java: Version 11 or newer.
- Server: Spigot or PaperMC server.
- Plugin: You need Multiverse-Core installed.
Replace "VERSION" with the latest release version and make sure to shade the library.
- Add to Your Project: Put this in your
build.gradlefile:
dependencies {
implementation 'com.github.ItsHarshXD:WorldTemplateAPI:VERSION'
}-
Build: Run your build to download everything.
-
Start Server: Make sure Multiverse-Core is running with your plugin.
First, tell the API where to save your templates:
Path templateDir = Paths.get(getDataFolder().getAbsolutePath(), "templates");
worldTemplateAPI.setTemplateDirectory(templateDir);
try {
if (!Files.exists(templateDir)) {
Files.createDirectories(templateDir);
}
} catch (IOException e) {
getLogger().severe("Could not create template directory: " + e.getMessage());
}directory: Where you want to store all your templates.
To make a template from a world that already exists:
CompletableFuture<Boolean> success = worldTemplateAPI.createTemplateFromWorld("worldName", "templateName");worldName: The world you want to copy.templateName: What you want to call the template.
To create a new world from a template:
CompletableFuture<World> newWorld = worldTemplateAPI.loadTemplate("templateName", "newWorldName");templateName: The template you want to use.newWorldName: What to name the new world.
To remove a template you don't need:
CompletableFuture<Boolean> deleted = worldTemplateAPI.deleteTemplate("templateName");templateName: The template you want to delete.
createTemplateFromWorld(String worldName, String templateName): Makes a template from a world.loadTemplate(String templateName, String targetWorldName): Creates a world from a template.deleteTemplate(String templateName): Removes a template.setTemplateDirectory(Path directory): Sets where templates are stored.
I'd love your help! If you have ideas or improvements, fork the repo and send a pull request. Feedback is always welcome!
This project uses the MIT License - check the LICENSE file for details.
Questions? Need help? Feel free to reach out. Happy coding with WorldTemplateAPI! 🌟