Class BungeeCordHelper

java.lang.Object
eu.cloudnetservice.modules.bridge.impl.platform.bungeecord.BungeeCordHelper

@Singleton final class BungeeCordHelper extends Object
Helper utilities for bungeecord-related functionalities.
Since:
4.0
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • PLAYER_INITIAL_CONNECT_TESTER

      private static final CheckedPredicate<net.md_5.bungee.api.connection.ProxiedPlayer> PLAYER_INITIAL_CONNECT_TESTER
    • proxyServer

      private final net.md_5.bungee.api.ProxyServer proxyServer
    • serverRegisterHandler

      private final CheckedConsumer<eu.cloudnetservice.driver.service.ServiceInfoSnapshot> serverRegisterHandler
    • serverUnregisterHandler

      private final CheckedConsumer<eu.cloudnetservice.driver.service.ServiceInfoSnapshot> serverUnregisterHandler
  • Constructor Details

    • BungeeCordHelper

      @Inject public BungeeCordHelper(@NonNull @NonNull net.md_5.bungee.api.ProxyServer proxyServer, @NonNull @NonNull net.md_5.bungee.api.ProxyConfig proxyConfig)
  • Method Details

    • isInitialConnect

      public static boolean isInitialConnect(@NonNull @NonNull net.md_5.bungee.api.connection.ProxiedPlayer player)
      Tests if the connection of the given player is initial, returning false if the player did successfully connect to a backend service before. The last point in the login sequence where this check returns a valid result is in ServerConnectedEvent.
      Parameters:
      player - the player to test.
      Returns:
      true if the player was not connected to any service before, false otherwise.
      Throws:
      NullPointerException - if the given player is null.
      IllegalStateException - if the test failed for some reason.
    • registerServer

      public void registerServer(@NonNull @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot serviceInfoSnapshot)
      Register the given service to the proxy. An existing service with the same name will be replaced.
      Parameters:
      serviceInfoSnapshot - the snapshot of the service to register.
      Throws:
      NullPointerException - if the given service info snapshot is null.
    • unregisterServer

      public void unregisterServer(@NonNull @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot serviceInfoSnapshot)
      Unregisters the given service from the proxy.
      Parameters:
      serviceInfoSnapshot - the snapshot of the service to unregister.
      Throws:
      NullPointerException - if the given service info snapshot is null.
    • constructServerInfo

      @NonNull private @NonNull net.md_5.bungee.api.config.ServerInfo constructServerInfo(@NonNull @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot serviceInfo)
      Constructs a proxy server info from the given service info snapshot.
      Parameters:
      serviceInfo - the service info to construct a server info from.
      Returns:
      a server info constructed from the given service info snapshot.
      Throws:
      NullPointerException - if the given service info snapshot is null.