Interface RemoteServer


public interface RemoteServer
Represents a server in the network, including ours.
  • Method Details

    • getArenas

      Collection<? extends RemoteArena> getArenas()
      Gets all the arena that the server holds.
      Returns:
      The server that are being managed by the server
    • isLocal

      boolean isLocal()
      Gets whether this instance represents the server on which you are accessing the API with-
      Returns:
      true when it is local
    • isOnline

      boolean isOnline()
      Gets whether the arena is still online.
      Returns:
      true in case it is online
    • getBungeeChannelName

      @Nullable @Nullable String getBungeeChannelName()
      Gets the name of this server that has been configured in Bungeecord's config.

      The default implementation (the one without the ProxySync) addon, might return null. Reason being, that it has to fetch the info manually. And it's possible that the server is not running in bungee mode.

      Returns:
      The channel name of the arena. May be null
    • isHub

      boolean isHub()
      Whether this server represents a location to which the player gets teleported when he leaves the arena (or when the match ends).
      Returns:
      true when it's a hub server
    • getMinecraftVersion

      int getMinecraftVersion()
      Returns the minor version of the running server software.

      Example: If it's running 1.8.6, then this method returns 8

      Returns:
      The minor version of the running server software
      See Also:
    • getMinecraftPatchVersion

      int getMinecraftPatchVersion()
      Returns the patch version of the running server software.

      Example: If it's running 1.8.6, then this method returns 6

      Returns:
      The patch version of the running server software
      See Also:
    • getPlayersCount

      int getPlayersCount()
      Gets the total amount of players that are currently on this server.

      This includes ALL players, not only spectating and playing players.

      Returns:
      The amount of players on the server
    • getMaxPlayersCount

      int getMaxPlayersCount()
      Gets the maximum amount of players that the server is able to hold.
      Returns:
      The max amount of players
    • getAPIVersion

      int getAPIVersion()
      Gets the version of the API of the Bedwars plugin that is running on the server.

      Obtains the info from BedwarsAPI.getAPIVersion().

      Returns:
      The version of the API on the server
    • getPluginVersion

      String getPluginVersion()
      Gets the version of the Bedwars plugin that is running on the server.
      Returns:
      The version of the Bedwars plugin on the server
    • executeBedwarsCommand

      void executeBedwarsCommand(RemotePlayer sender, String label, String[] args)
      Executes a command on the server, as if a player would run it.

      Keep in mind that not all commands support that. The handler must be implemented using CommandHandlerWrappedSender.

      Parameters:
      sender - The player who run it
      label - The lable of the command. May be e.g. "mbedwars"
      args - The arguments that he has passed
    • executeBedwarsCommandAsConsole

      void executeBedwarsCommandAsConsole(String label, String[] args)
      Executes a command on the server, as if a console would run it.

      Keep in mind that not all commands support that. The handler must be implemented using CommandHandlerWrappedSender.

      Parameters:
      label - The lable of the command. May be e.g. "mbedwars"
      args - The arguments that he has passed
    • sendConsoleMessage

      void sendConsoleMessage(String... messages)
      Sends a message to the console of the given server using CommandSender.sendMessage(String))
      Parameters:
      messages - The messages that shall be printed into the console
    • sendCustomMessage

      void sendCustomMessage(String channel, byte[] payload)
      Sends a custom message to this server.

      This method is useful when you want to communicate between servers. Use RemoteCustomMessageReceiveEvent to listen to the message.

      The channel parameter is useful as it allows you to be distant from other plugins that make use of the messaging system as well. You may e.g. insert the name of your plugin. Note that encoded as UTF-8. You may later use RemoteCustomMessageReceiveEvent.getChannel() to identify the channel again.

      Parameters:
      channel - The channel in which you want to communicate
      payload - The actual message that you want to send. Use e.g. String.getBytes() to pass a String.
      Throws:
      IllegalStateException - When trying to send it to a local server (isLocal() returns true)
      IllegalArgumentException - When channel name is larger than 255 bytes or when payload is larger than 10MB (not a typo)
      See Also:
    • getArenaByExactRealName

      @Nullable @Nullable RemoteArena getArenaByExactRealName(String name)
      Looks for an arena from this server whose real name is identical to the given parameter.
      Parameters:
      name - The name of the arena we are looking
      Returns:
      The arena whose RemoteArena.getRealName() on this server matches with the parameter. null if there is none