BungeeSync
Support
  • 📍Important
    • Support
  • 📡Introduction
    • Plugin Description
    • Plugin Installation
  • 💡Plugin Usage
    • Commands & Permissions
  • 🛠️API Usage (For Developers)
    • Actions performable for Proxy
    • Actions performable for Player
Powered by GitBook
On this page
  1. API Usage (For Developers)

Actions performable for Proxy

How to use Shared Proxy Actions with API.

public static void proxyActions() {

    /*
    * Get wrapped proxy server
    * */
    WrappedProxiedServer proxy = BungeeSync.getWrappedProxiedServer();

    /*
    * Example for sending broadcasts
    * */
    proxy.broadcast("Your message");
    proxy.broadcast(TextComponent.fromLegacyText("Message can be also a BaseComponent[]"));

    /*
    * Getting players on all connected proxies
    * */
    Collection<SyncedPlayer> players = proxy.getPlayers();

    /*
    * Getting all player names for tab completer to your commands
    * */
    List<String> names = proxy.getPlayerNames();

    /*
    * Getting all players (Number)
    * */
    int totalPlayers = proxy.getPlayersCount();
   
    /*
     * Example for creating shared cache
     *
     * (If you want to cache your advanced
     * objects, create for them reader & writer
     * to compile objects to string...)
     *
     * NOTE: If you use 2 same ids, plugin will override data...
     *
     * */
    Set<String> mySharedSet = proxy.getOrCreateSetCache("test-set");
    List<String> mySharedList = proxy.getOrCreateListCache("test-list");
    Map<String, String> mySharedMap = proxy.getOrCreateMapCache("test-map");
   
    /*
    * Use your objects normally...
    * */
    boolean isThereSomeValue = mySharedSet.contains("some value");
    boolean isListEmpty = mySharedList.isEmpty();
    boolean isMapBiggerThanOne = mySharedMap.size() > 1;
   
    /*
    * After editing objects, you need to sync it...
    * Use this methods!
    * */
    proxy.updateSetCache("test-set");
    proxy.updateListCache("test-list");
    proxy.updateMapCache("test-map");
   
}
PreviousCommands & PermissionsNextActions performable for Player

Last updated 2 years ago

🛠️