1 cask "minecraft-server" do
2 version "1.21.3,45810d238246d90e811d896f87b14695b7fb6839"
3 sha256 "e153b89b02c0839cdf5e8c1d57c80dd42a3fffb80c60817632080c041bf8afb5"
5 url "https://launcher.mojang.com/v#{version.major}/objects/#{version.csv.second}/server.jar",
6 verified: "launcher.mojang.com/"
7 name "Minecraft Server"
8 desc "Run a Minecraft multiplayer server"
9 homepage "https://www.minecraft.net/en-us/"
12 url "https://www.minecraft.net/en-us/download/server"
13 regex(%r{href=.*?/objects/(\h+)/server\.jar[^>]*>minecraft[_-]server[._-]v?(\d+(?:\.\d+)*)\.jar}i)
14 strategy :page_match do |page, regex|
15 page.scan(regex).map { |match| "#{match[1]},#{match[0]}" }
19 container type: :naked
21 # shim script (https://github.com/Homebrew/homebrew-cask/issues/18809)
22 shimscript = "#{staged_path}/minecraft-server.wrapper.sh"
23 binary shimscript, target: "minecraft-server"
25 config_dir = HOMEBREW_PREFIX.join("etc", "minecraft-server")
28 FileUtils.mkdir_p config_dir
30 File.write shimscript, <<~EOS
32 cd '#{config_dir}' && \
33 exec /usr/bin/java ${@:--Xms1024M -Xmx1024M} -jar '#{staged_path}/server.jar' nogui
37 eula_file = config_dir.join("eula.txt")
40 system_command shimscript
41 File.write(eula_file, File.read(eula_file).sub("eula=false", "eula=TRUE"))
44 uninstall_preflight do
45 FileUtils.rm(eula_file) if eula_file.exist?
53 Configuration files are located in