From d36e7da673b5d5d34333d5cd4c60b88aaa4373fe Mon Sep 17 00:00:00 2001 From: ME1312 Date: Sun, 29 Mar 2020 14:06:21 -0400 Subject: [PATCH] Updated SubAPI (markdown) --- SubAPI.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/SubAPI.md b/SubAPI.md index 0d5bc46..fdb7b1b 100644 --- a/SubAPI.md +++ b/SubAPI.md @@ -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.

__SubAPI Status Listener:__
-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 } ``` +
__Bungee ServerInfo:__
-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.

+ +__Working with Cached Data:__
+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.

## SubServers.Host This will show how to use SubAPI for SubServers.Host. For more detailed information visit this page: