-
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.
Regionerator does not provide an event for deletion because there is no guarantee that attempts are successful. Instead, you should clean up data when the ChunkPopulateEvent is fired.
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 = JavaPlugin.getPlugin(Regionerator.class)
PluginHook hook = new MyAwesomeHook(plugin);
regionerator.addHook(hook);
}
Home - FAQ - Configuration - Commands
Getting Started
Developer Resources