Updated SubAPI (markdown)

ME1312 2020-03-29 14:06:21 -04:00
parent 56ea907a1f
commit d36e7da673

@ -60,10 +60,10 @@ This will show how to use SubAPI for SubServers.Bungee. For more detailed inform
[https://dev.me1312.net/jenkins/job/SubServers Platform/javadoc/SubServers.Bungee/](https://dev.me1312.net/jenkins/job/SubServers%20Platform/javadoc/SubServers.Bungee/)
### Using SubAPI for Bungee
Most of SubAPI can be accessed using this simple method `SubAPI.getInstance()`, however there's a bit more to it than just that. SubServers.Bungee works by extending BungeeCord classes to add more functionality, and overriding the methods to serve the extended classes. Knowing this, you can use it to your advantage.
Most of SubAPI can be accessed using this simple method `SubAPI.getInstance()`, however there's a bit more to it than just that. SubServers.Bungee works by extending BungeeCord classes to add more functionality, and overriding the methods to serve the extended classes. Knowing this, you can use it to your advantage.<br><br>
__SubAPI Status Listener:__<br>
If you need to listen to the status of SubAPI, you can do so like this:
SubAPI isn't exactly ready for most calls when typical BungeeCord plugins are enabled. This is because SubServers allows you to add things like drivers before it finishes loading. So, if you need to start using SubAPI as soon as possible, then you should add a SubAPI listener:
```java
@Override
public void onEnable() {
@ -76,9 +76,10 @@ public void subDisable() {
// SubAPI is about to be disabled
}
```
<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;
// This will get you the SubServers wrapped version of a server if that server has been registered within SubServers
@ -94,7 +95,10 @@ This will show how to use SubAPI for SubServers.Sync and SubServers.Client since
[https://dev.me1312.net/jenkins/job/SubServers Platform/javadoc/SubServers.Client.Sponge/](https://dev.me1312.net/jenkins/job/SubServers%20Platform/javadoc/SubServers.Client.Sponge/)
### Using SubAPI for SubServers.Sync/SubServers.Client
Like SubServers.Bungee, SubAPI methods can be accessed using the method `SubAPI.getInstance()`, however here most of the API is SubData packet based. This means you will have to create your own packets, or use the ones provided to you in the `Network.Packet` package. For more info on SubData [click here](https://github.com/ME1312/SubServers-2/wiki/SubData), to see what the JSON responses are for packets, [click here](https://github.com/ME1312/SubServers-2/tree/master/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet).
Like SubServers.Bungee, SubAPI methods can be accessed using the method `SubAPI.getInstance()`, however here most of the API is SubData packet based. This means that the emulated API, although similar, now heavily uses callbacks to achieve it's goals.<br><br>
__Working with Cached Data:__<br>
Something you have to watch out for is that when you call to something like `SubAPI.getServer()`, you are downloading a snapshot of the data that has been frozen in time since the moment you requested it. To get an updated version of the data, you can just request it again using the same method, or use the resulting object's `.refresh()` method.<br><br>
## SubServers.Host
This will show how to use SubAPI for SubServers.Host. For more detailed information visit this page:<br>