See

https://oscarnow.github.io/minecraft-server/1.4.0/classes/Server

Example

const server = new Server({

         serverList: ({ ip, connection: { host, port }, version, legacy }) => ({
description: `Hi there!\n${legacy ? "You've sent a legacy ping" : "You've sent a normal ping"}`,
players: {
online: server.clients.length,
max: 100, * hover: [ip, `${host}: ${port}`, version].join('\n')
},
version: {
wrongText: 'Please use version 1.16.3',
correct: '1.16.3' * },
favicon: fs.readFileSync('./favicon.png')
}),

wrongVersionConnect: ({ ip, connection: { host, port }, version, legacy }) =>
`You've connected with the wrong version!\nExtra info:\nip: ${ip}, host: ${host}, port: ${port}, version: $1.4.0, legacy: ${legacy ? 'yes' : 'no'}`,

defaultClientProperties: client => ({
clearSky: true,
difficulty: client.username === 'notch' ? 'hard' : 'normal',
food: 20,
foodSaturation: 5,
gamemode: 'survival',
health: 20,
reducedDebugInfo: false,
showRespawnScreen: true,
slot: 0
})

});

Hierarchy

  • Server

Properties

Methods

Constructors

Properties

clients: Client[]

Methods

  • Returns Promise<void>

  • Parameters

    • event: "listening"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns void

  • Parameters

    • event: "join" | "leave" | "connect"
    • callback: ((client: Client) => void)
        • (client: Client): void
        • Parameters

          Returns void

    Returns void

  • Parameters

    Returns void

  • Parameters

    • event: "listening"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns void

  • Parameters

    • event: "join" | "leave" | "connect"
    • callback: ((client: Client) => void)
        • (client: Client): void
        • Parameters

          Returns void

    Returns void

  • Parameters

    Returns void

Constructors

  • Parameters

    • serverOptions: {
          defaultClientProperties?(client: Client): defaultClientProperties;
          serverList?(info: {
              connection: {
                  host: null | string;
                  port: null | number;
              };
              ip: string;
              legacy: boolean;
              version: null | version;
          }): {
              description?: Text | optionalTextArray;
              favicon?: Buffer;
              players?: {
                  hover?: string | {
                      name: string;
                      uuid: string;
                  }[];
                  max?: number;
                  online?: number;
              };
              version?: {
                  correct?: version;
                  wrongText?: string | Text;
              };
          };
          wrongVersionConnect?(info: {
              connection: {
                  host: null | string;
                  port: null | number;
              };
              ip: string;
              legacy: boolean;
              version: newVersion | "legacy";
          }): null | string | Text;
      }
      • defaultClientProperties?:function
      • serverList?:function
        • Example

          serverList: ({ ip }) => ({

                   description: `A minecraft server\nYour ip is ${ip}`,
          players: {
          online: server.clients.length,
          max: 100
          },
          version: {
          wrongText: 'Please use 1.16.3'
          }

          })

          Example

          serverList: ({ ip, connection: { host, port }, version }) => ({

                   description: new Text([
          { text: 'Connected through: ', color: 'gray' },
          { text: `${host}:${port}`, color: 'white', modifiers: ['bold'] },
          { text: '\nYour ip: ', color: 'gray' },
          { text: ip, color: 'white', modifiers: ['bold'] }
          ]),

          players: {
          online: server.clients.length + 5,
          max: Math.floor(Math.random() * 100) + 5,
          hover: 'More\nthan\n1\nline!'
          },

          version: {
          wrongText: 'Wrong version!',

          / * Tell client that the correct version is their version, so they
          always think they have the correct version. Reported client
          version is null when the version of the client is unknown * /
          correct: version === null ? '1.16.3' : version
          },

          favicon: fs.readFileSync('./favicon.png')

          })

          Parameters

          • info: {
                connection: {
                    host: null | string;
                    port: null | number;
                };
                ip: string;
                legacy: boolean;
                version: null | version;
            }
            • connection: {
                  host: null | string;
                  port: null | number;
              }
              • host: null | string
              • port: null | number
            • ip: string
            • legacy: boolean
            • version: null | version

          Returns {
              description?: Text | optionalTextArray;
              favicon?: Buffer;
              players?: {
                  hover?: string | {
                      name: string;
                      uuid: string;
                  }[];
                  max?: number;
                  online?: number;
              };
              version?: {
                  correct?: version;
                  wrongText?: string | Text;
              };
          }

          • Optional description?: Text | optionalTextArray
          • Optional favicon?: Buffer
          • Optional players?: {
                hover?: string | {
                    name: string;
                    uuid: string;
                }[];
                max?: number;
                online?: number;
            }
            • Optional hover?: string | {
                  name: string;
                  uuid: string;
              }[]
            • Optional max?: number
            • Optional online?: number
          • Optional version?: {
                correct?: version;
                wrongText?: string | Text;
            }
            • Optional correct?: version
            • Optional wrongText?: string | Text
      • wrongVersionConnect?:function
        • Parameters

          • info: {
                connection: {
                    host: null | string;
                    port: null | number;
                };
                ip: string;
                legacy: boolean;
                version: newVersion | "legacy";
            }
            • connection: {
                  host: null | string;
                  port: null | number;
              }
              • host: null | string
              • port: null | number
            • ip: string
            • legacy: boolean
            • version: newVersion | "legacy"

          Returns null | string | Text

    Returns Server