Informations transfert

Discussion in 'BungeeCord Plugin Development' started by OpperFx, Mar 13, 2018.

  1. Hello! This is my first message, and I am French, so I'm sorry if I'm not good at English ^. ^
    I want a method, in my bungeecord API, that can get the ram from a server (the server is in the arguments).
    Like this:
    public long getFreeRam(String serverName) {
    return <theFreeRamOfTheServer>;
    To get the free ram, I can do it, spigot side:
    Runtime.getRuntime().freeMemory() / 1024L / 1024L;
    But I want it in bungeecord! I tried the messaging channel, but if I use the messaging channel, I can not return the ram immediately ...
    So, I found a solution, is Socket4MC, every minute I update a class RamCache.
    I post this message to find out if there is a better solution. thank you in advance
  2. When getting data from another server, it will never return immediately. You have to wait for the reply, and apply it.
  3. Well if this is going to be shown in chat you can send a new message when you get the message, for start you need to create your own messaging system and then when you receive the info you have tha Player or ProxiedPlayer variable and if the values are equals to a long just send the free ram of the server as a message. If this is not going to be shown on chat you need to cache the value and make a scheduler for send an update every x seconds. Take in care if you dont want to send the message when you get the message with the messaging system you can use Future or just use wait(a few ticks) and then return the value (you need to cache it). but i think is better to use the messaging system.

Share This Page