-
Notifications
You must be signed in to change notification settings - Fork 18
Developing
Looking to support Regionerator with your plugin? It's not too hard.
If you're looking to support Regionerator deleting area in which you have data stored, wipe data when the ChunkPopulateEvent is fired. Regionerator does not guarantee that chunks are deleted on first attempt, so there is no sense firing an unreliable event when an attempt is made.
If your plugin doesn't offer access to its API via a public Maven repository Regionerator can use (or if you're a real go-getter, good on you!) you'll need to implement your own PluginHook
to protect an area from deletion.
Regionerator is available via JitPack. For Maven, add JitPack as a repository and Regionerator as a dependency.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.Jikoo</groupId>
<artifactId>Regionerator</artifactId>
<version><!-- version goes here --></version>
</dependency>
<dependencies>
Your hook will extend PluginHook
. The only thing you need to do is implement isChunkProtected(World, int, int)
. Be careful not to load chunks! This will cause deletion to never work. If your protection plugin can be accessed from other threads safely, make sure to override isAsyncCapable
to improve performance!
Ex:
public class MyAwesomeHook extends PluginHook {
private final MyAwesomePlugin plugin;
public MyAwesomeHook(MyAwesomePlugin plugin) {
super(plugin.getName());
this.plugin = plugin;
}
@Override
public boolean isChunkProtected(World chunkWorld, int chunkX, int chunkZ) {
return plugin.isAwesome(chunkWorld.getName(), chunkX, chunkZ);
}
@Override
public boolean isAsyncCapable() {
return plugin.isDataFullyLoaded();
}
}
You're almost there! All you need to do is register the hook with Regionerator. Just add Regionerator to your softdepend list and then on enable pass your hook to Regionerator#addHook(PluginHook)
!
Ex:
public void hookRegionerator(MyAwesomePlugin plugin) {
try {
Class.forName("com.github.jikoo.regionerator.Regionerator");
} catch (ClassNotFoundException e) {
// Plugin not present.
return;
}
Regionerator regionerator = plugin.getPlugin(Regionerator.class)
PluginHook hook = new MyAwesomeHook(plugin);
regionerator.addHook(hook);
}
Home - FAQ - Configuration - Commands
Getting Started
Developer Resources