_configuration.tpl 4.2 KB

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