_configuration.tpl 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. {{- define "minecraft.configuration" -}}
  2. {{- include "minecraft.validation" $ }}
  3. configmap:
  4. minecraft-config:
  5. enabled: true
  6. data:
  7. {{/*
  8. There is no GUI in the container,
  9. but some old versions think that there is
  10. */}}
  11. GUI: "FALSE"
  12. EULA: {{ .Values.mcConfig.eula | quote | upper }}
  13. ENABLE_RCON: {{ .Values.mcConfig.enableRcon | quote | upper }}
  14. SERVER_PORT: {{ .Values.mcNetwork.serverPort | quote }}
  15. {{ if .Values.mcConfig.enableRcon }}
  16. RCON_PORT: {{ .Values.mcNetwork.rconPort | quote }}
  17. RCON_PASSWORD: {{ .Values.mcConfig.rconPassword | quote }}
  18. {{ end }}
  19. VERSION: {{ .Values.mcConfig.version | quote }}
  20. TYPE: {{ .Values.mcConfig.type | quote }}
  21. {{ with .Values.mcConfig.seed }}
  22. SEED: {{ . | quote }}
  23. {{ end }}
  24. MOTD: {{ .Values.mcConfig.motd | quote }}
  25. DIFFICULTY: {{ .Values.mcConfig.difficulty | quote }}
  26. SERVER_NAME: {{ .Values.mcConfig.serverName | quote }}
  27. MAX_PLAYERS: {{ .Values.mcConfig.maxPlayers | quote }}
  28. MAX_WORLD_SIZE: {{ .Values.mcConfig.maxWorldSize | quote }}
  29. ALLOW_NETHER: {{ .Values.mcConfig.allowNether | quote | upper }}
  30. ANNOUNCE_PLAYER_ACHIEVEMENTS: {{ .Values.mcConfig.announcePlayerAchievements | quote | upper }}
  31. ENABLE_COMMAND_BLOCK: {{ .Values.mcConfig.enableCommandBlock | quote | upper }}
  32. FORCE_GAMEMODE: {{ .Values.mcConfig.forceGameMode | quote | upper }}
  33. GENERATE_STRUCTURES: {{ .Values.mcConfig.generateStructures | quote | upper }}
  34. HARDCORE: {{ .Values.mcConfig.hardcore | quote | upper }}
  35. MAX_BUILD_HEIGHT: {{ .Values.mcConfig.maxBuildHeight | quote }}
  36. SPAWN_ANIMALS: {{ .Values.mcConfig.spawnAnimals | quote | upper }}
  37. SPAWN_MONSTERS: {{ .Values.mcConfig.spawnMonsters | quote | upper }}
  38. SPAWN_NPCS: {{ .Values.mcConfig.spawnNpcs | quote | upper }}
  39. SPAWN_PROTECTION: {{ .Values.mcConfig.spawnProtection | quote }}
  40. VIEW_DISTANCE: {{ .Values.mcConfig.viewDistance | quote }}
  41. PVP: {{ .Values.mcConfig.pvp | quote | upper }}
  42. LEVEL_TYPE: {{ .Values.mcConfig.levelType | quote }}
  43. ALLOW_FLIGHT: {{ .Values.mcConfig.allowFlight | quote | upper }}
  44. ONLINE_MODE: {{ .Values.mcConfig.onlineMode | quote | upper }}
  45. MAX_TICK_TIME: {{ .Values.mcConfig.maxTickTime | quote }}
  46. {{ with .Values.mcConfig.ops }}
  47. OPS: {{ join "," . | quote }}
  48. {{ end }}
  49. {{ with .Values.mcConfig.whitelist }}
  50. WHITELIST: {{ join "," . | quote }}
  51. {{ end }}
  52. {{- end -}}
  53. {{- define "minecraft.validation" -}}
  54. {{- if not .Values.mcConfig.eula -}}
  55. {{- fail "Minecraft - You have to accept EULA" -}}
  56. {{- end -}}
  57. {{- $types := (list "VANILLA" "SPIGOT" "BUKKIT" "PAPER" "FOLIA"
  58. "FABRIC" "FORGE" "NEOFORGE" "AUTO_CURSEFORGE" "MODRINTH"
  59. "FTBA" "PUFFERFISH" "PURPUR" "QUILT" "MAGMA"
  60. "MAGMA_MAINTAINED" "KETTING" "MOHIST" "CATSERVER" "SPONGEVANILLA"
  61. "LIMBO" "CRUCIBLE" "CUSTOM") -}}
  62. {{- if not (mustHas .Values.mcConfig.type $types) -}}
  63. {{- fail (printf "Minecraft - Expected [Type] to be one of [%s], but got [%s]" (join ", " $types) .Values.mcConfig.type) -}}
  64. {{- end -}}
  65. {{- $difficulties := (list "peaceful" "easy" "normal" "hard") -}}
  66. {{- if not (mustHas .Values.mcConfig.difficulty $difficulties) -}}
  67. {{- fail (printf "Minecraft - Expected [Difficulty] to be one of [%s], but got [%s]" (join ", " $difficulties) .Values.mcConfig.difficulty) -}}
  68. {{- end -}}
  69. {{- $modes := (list "creative" "survival" "adventure" "spectator") -}}
  70. {{- if not (mustHas .Values.mcConfig.mode $modes) -}}
  71. {{- fail (printf "Minecraft - Expected [Mode] to be one of [%s], but got [%s]" (join ", " $modes) .Values.mcConfig.mode) -}}
  72. {{- end -}}
  73. {{- $lvlTypes := (list "minecraft:default" "minecraft:flat" "minecraft:large_biomes"
  74. "minecraft:amplified" "minecraft:single_biome_surface" "buffet" "customized") -}}
  75. {{- if not (mustHas .Values.mcConfig.levelType $lvlTypes) -}}
  76. {{- fail (printf "Minecraft - Expected [Level Type] to be one of [%s], but got [%s]" (join ", " $lvlTypes) .Values.mcConfig.levelType) -}}
  77. {{- end -}}
  78. {{- end -}}