-
Notifications
You must be signed in to change notification settings - Fork 2
UniBan Extension
Leaves123 edited this page Feb 16, 2020
·
3 revisions
UniBan (1.2 or later) provides you with an efficient way to extend its function, e.g. importing banned players from your own ban managing plugin.
A UniBan Extension example is provided here: EusChatBridge - Build a Bridge Between Webhooks of IM Service and Your Minecraft Server
Heres the steps of making a simple UniBan Extension.
First of all, create a public class which extends UniBanExtension.
public class MyExtension extends UniBanExtension {
UniBanController controller;
MyPlugin plugin;
HttpService httpService;
public ChatReceiverExtension(MyPlugin instance) {
this.plugin = instance;
}
@Override
public void onExtensionLoad() {
this.controller = getUniBanController();
// Uncomment the code below in case you need the extension based on UniBan http server.
// this.httpService = new HttpService("/MyExtension", new HttpRequestHandler(plugin, controller));
}
@Override
public void onExtensionUnload() {
if (httpService != null && httpService.context != null)
controller.removeHttpContent(httpService.context);
}
@Override
public HttpService getHttpService() {
return this.httpService;
}
@Override
public String getName() {
return plugin.getDescription().getName();
}
@Override
public String getAuthor() {
return plugin.getDescription().getAuthors().toString();
}
@Override
public String getVersion() {
return plugin.getDescription().getVersion();
}
}
And then add the following code to the onEnable() section.
if (Bukkit.getPluginManager().getPlugin("UniBan") != null) {
new MyExtension(this).register();
getLogger().info("UniBan Extension registered.");
}