Static methods for the Server API
Methods
-
staticServer.getAddress(
){string} -
Return the server IP address.
Returns:
Type Description string - the IP address
Example
// ? clientMessage(Server.getAddress()); // prints '84.45.129.7' -
staticServer.getAllPlayerNames(
){Array.<string>} -
Return the names of all players on the server.
Returns:
Type Description Array.<string> - the player names
Example
// announce all players online var players = Server.getAllPlayerNames(); for (var i = 0; i < players.length; i++) { clientMessage(players[i] + " is online!"); } -
staticServer.getAllPlayers(
){Array.<long>} -
Return the entity IDs of all players on the server.
Returns:
Type Description Array.<long> - the player IDs
Example
// announce all players online var players = Server.getAllPlayers(); for (var i = 0; i < players.length; i++) { clientMessage(Player.getName(players[i]) + " is online!"); } -
staticServer.getPort(
){int} -
Return the port number of the current remote connection.
Returns:
Type Description int - the port number
Example
// ? clientMessage("The current server port is: " + Server.getPort()); -
staticServer.joinServer(
address, port) -
Connect to a remote server.
Name Type Description addressstring the server's IP address
portint the port number
Example
// ? Server.joinServer("84.45.129.7", 19132); -
staticServer.sendChat(
text) -
Send a chat message.
Name Type Description textstring the message text
Example
// ? Server.sendChat("Herobrine is fake!!");