Skip to content

Hosting

Lunar Starstrum edited this page Nov 20, 2021 · 2 revisions

This wiki page goes over hosting and setting up a Moonlight server. A few things should be noted off the bat:

  • Moonlight is not a drop in replacement for any of the Java Minecraft servers. Moonlight makes no attempt to load jar files, or even replicate the API. There may be similarities, but it's not the same.
  • All configs should be found in the automatically generated res folder, with the plugin configs being in their related folders. An example of this is the server config being in res/config.json, but the config(s) for an example plugin being in res/ExamplePlugin/config.json.
  • Moonlight uses JSON as it's default (and very much preferred) storage format; however YML is (begrudgingly) supported. If you have trouble understanding JSON, you can either use YML or a JSON to YML converter.
  • The performance gains you receive from using Moonlight will be huge. The most notable difference will be the memory usage. However, since this is a lesser known server software, this means less plugins will be available. If there's any specific plugin you want to see in Moonlight, just make a plugin request.

With these in mind, let's get to setting up Moonlight.

To download Moonlight, either go to the releases page or download a nightly (unstable) build from the actions (choose the one with your OS name on it). Unzip it and run the executable.

The Moonlight.pdb contain debugging symbols, and should only be downloaded if you plan on bug reporting. Otherwise, they can be safely ignored.

It should be noted that Moonlight is a console app, meaning there is no clean user interface. Instead, you'll be met with the terminal/console. There's no purpose to it yet, however you need to keep this open in order to keep Moonlight running.

The Server Config

In the same folder/directory that you extracted Moonlight in, you'll notice a res folder being created on first run. By standard C convention, res means resources. This is where you'll find your server configs and plugin related files. The first thing you'll want to do is to edit/create either config.json or config.yml in the res folder. JSON is a more modern and compact text format which Moonlight prefers. However, Moonlight expects you to be coming from a Java Minecraft server background, and thus supports YML files as well. As it stands, Moonlight has the current settings:

{
    "server": {
        "name": "Moonlight 1.17.1",
        "description": "&#7b84d1Moonlight: A C# implementation of the &#26d891Minecraft Server &#7b84d1Protocol.",
        "ip": "127.0.0.1",
        "port": 25565,
        "online_mode": true,
        "compress_packets": false,
        "max_players": 100,
        "invalid_protocol_message": "&cYou must be on version 1.17.1!"
    },
    "logging": {
        "level": "Verbose",
        "overrides": {
            "Moonlight.Network.ServerListener": "Verbose",
            "Moonlight.Network.MinecraftClient": "Debug"
        }
    }
}

Let's break this into sections:

Server

This is the actual server settings, which Moonlight uses. It is the equivalent to Mojang's server.properties. If a setting is missing from the above shown config, then the default value is applied. This means that you can have a completely missing config.yml, and the default values will allow the server to run fine. When changes are made to the config, the changes are automatically applied the next time the config setting is requested. This means no more restarting your server when configuring the MOTD. Yay, hot reloading!

Name Type Description
Name String The software that the server is running on. Usually this is "Spigot", "Paper" or just a generic "Vanilla", however this can be overriden for whatever reason you desire.
Description String See Configuring the MOTD. All Minecraft Server Pings are supported.
Ip String Which ip address to listen on. 0.0.0.0 for all available IPv4 interfaces, localhost or 127.0.0.1 for access to only the host computer, or whatever other value you desire.
Port Positive Number Which port to listen on. Max: 65565
Online Mode True or False True or False. Attempts to validate the player's session, and prevents logging in on hacked accounts. At the current moment, this setting does nothing.
Compress Packets True or False Attempt to compress packets for faster network transferring. At the current moment, this does nothing.
Max Players Positive Number How many players total can join. Max: 2_147_483_647
Invalid Protocol Message String When an outdated client tries to join the server.

While the description tries to be as precise and informative as possible, there will always be room for confusion. If you happened to be confused, that's okay! You can join our Discord server for support, and we'll be happy to help!

Logging

This handles logging for all of Moonlight, plugins included. You're able to set the default log level, while also being able to override others.

Name Type Description
Level Serilog.LogEventLevel The default logging level. Applies to everything.
Overrides Array of Key:Value objects Allows for log level overrides on certain classes or namespaces.

The allowed values of the Serilog.LogEventLevel object is:

  • Verbose
  • Debug
  • Information
  • Warning
  • Error
  • Fatal

Configuring the MOTD

In your config.json, you can edit the description setting. This setting supports all formatting codes. Just like in Essentials, the & character is translated to §. If you want to use either, without formatting, just enter it twice: && translates to &, or §§ translates to §. In Minecraft 1.16+, you can use hex color codes (&#<6 digit code here>) and font codes (&$<1 through 3>). It should be noted that font codes are a Moonlight exclusive feature.

To use font codes, prepend your text with &@ and add the following number based on which code you want:

Font Name Font Code
Default 1
Unicode 2
Alt/Enchanting Table 3

When using the Enchanting table font, only letters and numbers (alphanumeric characters) can be used. Characters like ! or ? are translated to a plain old box.

To use a Hex color code, prepending your text with &#, and add six alphanumeric characters after it.

To configure a server icon, simply drop an image into the res folder, and name the image server_icon.png. It should be noted that the server icon does not need to be a png, but it should be one by convention. If the image is not 64 by 64 pixels in size, the server will automatically resize it when sending it to the client, with no modification to the file made. Finally, no more resizing images by hand!

Examples

Easy formatting text:

"description": "&1Moonlight: &9A C# implementation of the &aMinecraft Server &9protocol."

MOTD - Formatting Codes 1.png

Using hex color codes:

"description": "&#7b84d1Moonlight: a C# implementation of the &#26d891Minecraft Server &#7b84d1Protocol."

MOTD - Formatting Codes 2.png

Using font codes:

"description": "&@1Default Font, &@2Unicode Font, &@3Enchanting Table Font"

MOTD - Formatting Codes 3.png

A mix of all 3:

"description": "&1Moonlight: &#7b84d1A C# implementation of the &#26d891Minecraft Server &#7b84d1Protocol. &4&@3Hello World"

MOTD - Formatting Codes 4.png

The resource pack being used in the screenshots is Faithless, which aims to help all types of colorblindness' including full monochromacy.

Restrictions

  • Font codes can only be used in 1.16+
  • Hex color codes can only be used in 1.16+
  • Custom fonts cannot be uploaded. Only the default, unicode and enchanting table fonts are available.
  • The Alt/Enchanting table font only supports letters and numbers (alphanumeric characters). Characters like ! or ? are translated to a rectangular box.
  • If the MOTD has hex color codes, and the Minecraft client is playing on a pre-1.16 version, the hex color code will be translated to it's closest formatting color code. This may not always be correct.
  • If the MOTD has a font code, and the Minecraft client is playing on a pre-1.16 version, the font code will convert to the default font.
Clone this wiki locally