minecraft-server-util
GitHubnpm
  • 🏠Home
  • 📰Changelog
  • ❓Frequently Asked Questions
  • API
    • Java Server Status
    • Bedrock Server Status
    • Query
    • RCON
    • Send Vote
    • Miscellaneous
Powered by GitBook
On this page
  • Methods
  • parseAddress()
Edit on GitHub
  1. API

Miscellaneous

Miscellaneous but useful methods and functions.

Methods

parseAddress()

This method will parse the host and port out of an address string. For example, parsing play.hypixel.net will return { host: 'play.hypixel.net', port: 25565 }. The default port is configurable by the second parameter, which may be adjusted if parsing the address for anything other than a Java Edition Minecraft server.

const util = require('minecraft-server-util');

const defaultPort = 25565;

// defaultPort is an optional parameter and defaults to 25565 for Java
// Edition Minecraft servers.
const result = util.parseAddress('play.hypixel.net', defaultPort);

console.log(result);
{
    "host": "play.hypixel.net",
    "port": 25565
}
PreviousSend Vote

Last updated 3 years ago