StructureBlockLib
branch | status | version | download |
---|---|---|---|
master | Download latest release | ||
development | Download snapshots |
JavaDocs: https://shynixn.github.io/StructureBlockLib/apidocs/
Description
StructureBlockLib is a bukkit API and implementation for handling structures on spigot server.
Features
- Full blown Bukkit Api for the StructureBlock.
- API to save or load structures without an actual structure block.
- Asynchronous implementation and API.
- Fluent API.
- Version support 1.9.R1 - 1.16.R3
Installation
- Include the dependency to StructureBlockLib
Maven
<dependency>
<groupId>com.github.shynixn.structureblocklib</groupId>
<artifactId>structureblocklib-bukkit-api</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
</dependency>
Gradle
dependencies {
compileOnly("com.github.shynixn.structureblocklib:structureblocklib-bukkit-api:2.1.0")
}
Jar File
StructureBlockLibBukkitApi.jar
Code Examples
- If you need more information, check out the sample implementation of a plugin using StructureBlockLib in the
structureblocklib-bukkit-sample
folder. - All calls are not blocking and complete in the future.
Store a structure on your server to a target file
// Minimal configuration
Plugin plugin;
Path path = plugin.getDataFolder().toPath().resolve("mystructure.nbt");
StructureBlockLibApi.INSTANCE
.saveStructure(plugin)
.at(new Location(Bukkit.getWorld("world"), 100, 100, 100))
.sizeX(32)
.sizeY(5)
.sizeZ(32)
.saveToPath(path)
.onException(e -> plugin.getLogger().log(Level.SEVERE, "Failed to save structure.", e))
.onResult(e -> plugin.getLogger().log(Level.INFO, ChatColor.GREEN + "Saved structure 'mystructure'."));
// Maximal configuration
Plugin plugin;
Path path = plugin.getDataFolder().toPath().resolve("mystructure.nbt");
StructureBlockLibApi.INSTANCE
.saveStructure(plugin)
.at(new Location(Bukkit.getWorld("world"), 100, 100, 100))
.sizeX(32)
.sizeY(5)
.sizeZ(32)
.includeEntities(false) // See JavaDoc for default values.
.restriction(StructureRestriction.UNLIMITED) // See JavaDoc for default values.
.author("me")
.saveToPath(path)
.onProgress(c -> plugin.getLogger().log(Level.INFO, String.format("Percentage %.2f", c)))
.onException(e -> plugin.getLogger().log(Level.SEVERE, "Failed to save structure.", e))
.onResult(e -> plugin.getLogger().log(Level.INFO, ChatColor.GREEN + "Saved structure 'mystructure'."));
Store a structure on your server to the default structure storage, so it can be used by ordinary StructureBlocks
// Minimal configuration
Plugin plugin;
StructureBlockLibApi.INSTANCE
.saveStructure(plugin)
.at(new Location(Bukkit.getWorld("world"), 100, 100, 100))
.sizeX(32)
.sizeY(5)
.sizeZ(32)
.saveToWorld("world", "me", "mystructure")
.onException(e -> plugin.getLogger().log(Level.SEVERE, "Failed to save structure.", e))
.onResult(e -> plugin.getLogger().log(Level.INFO, ChatColor.GREEN + "Saved structure 'mystructure'."));
Load a structure on your server from a source file
// Minimal configuration
Plugin plugin;
Path path = plugin.getDataFolder().toPath().resolve("mystructure.nbt");
StructureBlockLibApi.INSTANCE
.loadStructure(plugin)
.at(new Location(Bukkit.getWorld("world"), 100, 100, 100))
.loadFromPath(path)
.onException(e -> plugin.getLogger().log(Level.SEVERE, "Failed to load structure.", e))
.onResult(e -> plugin.getLogger().log(Level.INFO, ChatColor.GREEN + "Loaded structure 'mystructure'."));
// Maximal configuration
Plugin plugin;
Path path = plugin.getDataFolder().toPath().resolve("mystructure.nbt");
StructureBlockLibApi.INSTANCE
.loadStructure(plugin)
.at(new Location(Bukkit.getWorld("world"), 100, 100, 100))
.includeEntities(true) // See JavaDoc for default values.
.seed(50L) // See JavaDoc for default values.
.integrity(0.2F) // See JavaDoc for default values.
.mirror(StructureMirror.FRONT_BACK) // See JavaDoc for default values.
.rotation(StructureRotation.ROTATION_90) // See JavaDoc for default values.
.loadFromPath(path)
.onException(e -> plugin.getLogger().log(Level.SEVERE, "Failed to load structure.", e))
.onResult(e -> plugin.getLogger().log(Level.INFO, ChatColor.GREEN + "Loaded structure 'mystructure'."));
Load a structure on your server from the default structure storage, so you can use structures from ordinary StructureBlocks
// Minimal configuration
Plugin plugin;
StructureBlockLibApi.INSTANCE
.loadStructure(plugin)
.at(new Location(Bukkit.getWorld("world"), 100, 100, 100))
.loadFromWorld("world", "me", "mystructure")
.onException(e -> plugin.getLogger().log(Level.SEVERE, "Failed to load structure.", e))
.onResult(e -> plugin.getLogger().log(Level.INFO, ChatColor.GREEN + "Loaded structure 'mystructure'."));
Modify and use an existing structure block
Plugin plugin;
Location location = new Location(Bukkit.getWorld("world"), 100, 100, 100);
location.getBlock().setType(Material.STRUCTURE_BLOCK);
StructureBlockSave structureBlock = StructureBlockLibApi.INSTANCE.getStructureBlockAt(location, plugin);
structureBlock.setStructureMode(StructureMode.SAVE);
structureBlock.setSaveName("sample_save");
structureBlock.setSizeX(31);
structureBlock.setSizeY(15);
structureBlock.setSizeZ(12);
structureBlock.update();
Shipping and Running
- In order to use the StructureBlockLib Api on your server, you need to put the implementation of the Api on your server. This can be achieved by either installing the standalone plugin
StructureBlockLib.jar
or shipping the implementation with your plugin.
Installing the StructureBlockLib.jar
- Just go to the releases page and download the plugin.
Shipping the implementation with your plugin
- Include both dependencies and shade them in your plugin jar file. If you do not know how to do that, you should go with the option above instead. There are several tutorials on spigotmc.org.
Maven
<dependency>
<groupId>com.github.shynixn.structureblocklib</groupId>
<artifactId>structureblocklib-bukkit-api</artifactId>
<version>2.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.shynixn.structureblocklib</groupId>
<artifactId>structureblocklib-bukkit-core</artifactId>
<version>2.1.0</version>
<scope>compile</scope>
</dependency>
Gradle
dependencies {
implementation("com.github.shynixn.structureblocklib:structureblocklib-bukkit-api:2.1.0")
implementation("com.github.shynixn.structureblocklib:structureblocklib-bukkit-core:2.1.0")
}
Contributing
- Fork the StructureBlockLib project on github and clone it to your local environment.
- Install Java 8 (later versions are not supported by the
downloadDependencies
task) - Install Apache Maven
- Make sure
java
points to a Java 8 installation (java -version
) - Make sure
$JAVA_HOME
points to a Java 8 installation - Make sure
mvn
points to a Maven installation (mvn --version
) - Execute gradle sync for dependencies
- Install the additional spigot dependencies by executing the following gradle task (this task can take a very long time)
[./gradlew|gradlew.bat] downloadDependencies
(If the downloadDependencies task fails for some reason, you can manually download BuildTools.jar and execute the commands on this page.)
- Build the module files by executing the following gradle task.
[./gradlew|gradlew.bat] shadowJar
Licence
The source code is licensed under the MIT license.