{
  config,
  lib,
  pkgs,
  ...
}:
let
  inherit (config.machine.minecraft-server)
    enable
    port
    ;
in
with lib;
mkIf enable {
  services.minecraft-server = {
    inherit enable;
    dataDir = "/var/lib/minecraft";
    declarative = true;
    eula = true;
    jvmOpts = "-Xms2046M -Xmx2046M -XX:+UseZGC";
    package = pkgs.papermcServers.papermc-1_21;
    serverProperties = {
      server-port = port;
      query-port = port;
      allow-flight = false;
      broadcast-console-to-ops = false;
      broadcast-rcon-to-ops = false;
      difficulty = "hard";
      enable-query = true;
      enable-rcon = false;
      enable-status = true;
      enforce-whitelist = false;
      force-gamemode = true;
      gamemode = "survival";
      log-ips = false;
      max-players = 20;
      max-tick-time = -1;
      motd = "RuJect's Minecraft Server";
      online-mode = false;
      op-permission-level = 4;
      simulation-distance = 16;
      view-distance = 16;
      spawn-protection = 0;
      white-list = false;
    };
  };
}
