Updated SubAPI (markdown)

ME1312 2020-02-19 19:33:42 -05:00
parent e231f991fa
commit a3f9793710

@ -2,7 +2,7 @@ SubAPI is the way to access the server manager through custom plugins. This page
### SubAPI via Maven ### SubAPI via Maven
You may want to use Maven to handle the SubAPI dependency for you. If so, here's the code you need to make it happen. You may want to use Maven to handle the SubAPI dependency for you. If so, here's the code you need to make it happen.
``` ```xml
<repositories> <repositories>
<repository> <repository>
<id>ME1312.net</id> <id>ME1312.net</id>
@ -26,7 +26,7 @@ You may want to use Maven to handle the SubAPI dependency for you. If so, here's
A "Soft Dependancy" is where your plugin will use SubServers, but it is not required for your plugin to function properly. A "Soft Dependancy" is where your plugin will use SubServers, but it is not required for your plugin to function properly.
First, Make a method to see if SubServers v2.11.2a+ is available using reflection: First, Make a method to see if SubServers v2.11.2a+ is available using reflection:
``` ```java
public boolean isSubServers2() { public boolean isSubServers2() {
try { try {
net.ME1312.SubServers.Bungee.SubAPI api = net.ME1312.SubServers.Bungee.SubAPI.class.cast(net.ME1312.SubServers.Bungee.SubAPI.class.getMethod("getInstance").invoke(null)); net.ME1312.SubServers.Bungee.SubAPI api = net.ME1312.SubServers.Bungee.SubAPI.class.cast(net.ME1312.SubServers.Bungee.SubAPI.class.getMethod("getInstance").invoke(null));
@ -58,7 +58,7 @@ Most of SubAPI can be accessed using this simple method `SubAPI.getInstance()`,
__SubAPI Status Listener:__<br> __SubAPI Status Listener:__<br>
If you need to listen to the status of SubAPI, you can do so like this: If you need to listen to the status of SubAPI, you can do so like this:
``` ```java
@Override @Override
public void onEnable() { public void onEnable() {
SubAPI.getInstance().addListener(this::subEnable, this::subDisable); SubAPI.getInstance().addListener(this::subEnable, this::subDisable);
@ -73,7 +73,7 @@ public void subDisable() {
__Bungee ServerInfo:__<br> __Bungee ServerInfo:__<br>
Just about any time you get a ServerInfo variable you can parse it to the SubServers equivalent if it exists. Just about any time you get a ServerInfo variable you can parse it to the SubServers equivalent if it exists.
``` ```java
Server server = (serverinfo instanceof Server)?(Server)serverinfo:null; Server server = (serverinfo instanceof Server)?(Server)serverinfo:null;
// This will get you the SubServers wrapped version of a server if that server has been registered within SubServers // This will get you the SubServers wrapped version of a server if that server has been registered within SubServers
@ -105,7 +105,7 @@ So, you're going to have to import GalaxiAPI to have SubServers.Host load your p
### Creating your plugin ### Creating your plugin
Plugin structure is pretty simple, all you need is a main class annotated with `@Plugin`: Plugin structure is pretty simple, all you need is a main class annotated with `@Plugin`:
``` ```java
import net.ME1312.Galaxi.Event.GalaxiStartEvent; import net.ME1312.Galaxi.Event.GalaxiStartEvent;
import net.ME1312.Galaxi.Event.GalaxiStopEvent; import net.ME1312.Galaxi.Event.GalaxiStopEvent;
import net.ME1312.Galaxi.Plugin.Plugin; import net.ME1312.Galaxi.Plugin.Plugin;