Please give me some tips on how to do it. I already know how to make a form and button with it, but i dont know how to put total player in it
from within a PluginBase class: PHP: $online = count($this->getServer()->getOnlinePlayers());//TODO: find total players available on your own :P//TODO: learn forms API on your own
i already know how to get online players but i dont know how to put it in a button XD its very complicated
The forms-api is still W.I.P. and it's still not stable enough to be used to develop plugins against it (not even if you aren't gonna release your plugin).
this will only count how many players online he's on, not the other server like what show in the image
Let me compare a few common methods. Scroll to the bottom of this post for my terminology here. Direct query (e.g. libpmquery) A direct connection is created between the querying server and the queried server. Only one network roundtrip is involved (send "request for status" and receive "respond with status") Advantages: Reliable with no dependencies. PocketMine servers listen to query by default, so no extra configuration is needed on the queried server. The querying plugin only needs socket functions, which are already used in PocketMine extensively (so no extra extensions required). Fast 1-to-1 query. This is true if the network latency between the querying server and the queried server is short. Disadvantages: Not efficient for 1-to-many queries. If you want to load the statuses of multiple servers, you need to execute each query asynchronously. The user needs to increase the number of async workers, or you need to implement your own async pool. Otherwise, the async pool is easily throttled by tasks waiting for queried servers to respond. A new connection has to be created every time. Therefore, it is not as fast as you think it is, probably even slower than a normal MySQL query. Online APIs (e.g. mcapi.us) A proxy for "Direct query" through the HTTP(S) layer. Advantages: Lazy: No need to write code or include libraries (which is not a legit reason at all). Tackle network constraints: May help you get over firewalls or improve the network speed (very unlikely). Disadvantages: Usually slower. It actually doubles the network route to reach the queried server. Unreliable. Online APIs may be down. You need to take care of more dependencies. CGI (Central Gateway Interface) Write your own software that acts as the middleman connecting all servers in your network. Advantages: Can be as fast as/faster than Direct Query. A CGI can forward signals from one server to any number of other servers without creating extra connections or requiring extra network roundtrips. While it doubles the network route, it does not make it any slower because the signals are sent to the CGI before you even requested them, so each query only takes one roundtrip, between the CGI and the querying server (although it still takes two roundtrips if you "ask for" some specific data on another server in addition to the data regularly sent to the CGI). Crafted for your specific needs because it is fully controlled by you, so you can easily optimize it for your network. Disadvantages: Users need to install and host an extra server. MySQL: A special form of CGI. MySQL was designed for storing data, not for transferring data, so it is not as optimal as a CGI crafted for your network's specific usage. However, if you don't want to spend extra work writing the CGI or don't want the user to install extra software (MySQL is also used by many other plugins, so it is common), MySQL is an alternative. For usual purposes, I think a CGI would be the best choice, because if you wan want to get the number of online players, you also want to know other data from that server sooner or later. Writing your own CGI (or using MySQL, which you can also create your own tables and functions on it) would allow you to extend the data you want to transfer easily. However, you need some knowledge regarding network protocols and security if you want to write your own CGI. For a simplistic solution, MySQL would be the best. Terms Querying server: The server that wants to know the status of other servers Queried server: The server where other servers want to know its own status. Querying plugin: The plugin on the querying server that wants to know the status of other servers