doctorray117 / minecraft-ondemand

Templates to deploy a serverless Minecraft Server on demand in AWS
Apache License 2.0
1.71k stars 118 forks source link

Allow watchdog to listen to bedrock port if using geyser #59

Open yurisasc opened 1 year ago

yurisasc commented 1 year ago

This should fix https://github.com/doctorray117/minecraft-ondemand/issues/58, where the watchdog closes the server if it's a Java server using Geyser plugin and the online players are connecting using the Bedrock edition.

I've published a watchdog container to test. You can replace doctorray/minecraft-ecsfargate-watchdog on minecraft-stack.ts with yurisasc/minecraft-ecsfargate-watchdog.

I'm currently still testing the container itself. Any help will be appreciated.

yurisasc commented 1 year ago

I keep getting this error whenever I try to use my updated watchdog. I don't get the error when running the watchdog container locally.

exec ./watchdog.sh: exec format error
yurisasc commented 1 year ago

I can confirm it was due to me building the docker image using arm64. The latest image should be working.

doctorray117 commented 1 year ago

@yurisasc I think I'm good to merge as is, however after reviewing I've got some thoughts. First, maybe the watchdog script shouldn't care what edition is in use and perform auto-detection based on listening ports, and decide how to check them at that point. This might be the next step.

Second, do you think the geyser plugin should be integrated to be run by default here? It sure seems like a good benefit but I wonder if it can integrate easily for vanilla minecraft or if it requires one of the popular mod platforms (spigot, paper, whatever). I had always thought giving these as options up front would be a great addition but a potential maintenance nightmare. LMK what you think.

yurisasc commented 1 year ago

To your first point, it didn't cross my mind because I thought the method to check connections for java and bedrock edition are essentially different. While implementing this feature, I treated them as a black box because I didn't know much about how they work. I think it would be good if the watchdog could receive ports as the input and use them to check player connections without knowing which editions (or even whether they use Geyser or not).

For your second point, Geyser requires a mod loader such as Paper, Fabric, etc. People looking to host vanilla servers won't need to care about it. I think a good approach would be to treat Geyser as a possible extension for those who want to host mod loader servers. In terms of maintenance, we can avoid it by only giving ways for people to use Geyser, instead of supporting it by default.

To add Geyser, people will need to:

  1. Choose the java edition
  2. Open a new UDP port, preferably 19132
  3. Add additional configurations in the Minecraft container environment variables, which is to choose a mod loader and download Geyser

The CDK already supports the first and the third steps, and this PR resolves the issue with the watchdog when using Geyser. I think just adding the second step won't require much maintenance. What I can think about is that we will only need to add docs.

In my fork, I have already added functionality to open extra TCP or UDP ports. I can open another PR if you like.

Rithmatist commented 1 year ago

Note that the current docker image is very advanced and you can just add agruments like TYPE=SPIGOT like the EULA=TRUE.