_configuration.tpl 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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" "CATSERVER" "CRUCIBLE"
  58. "AUTO_CURSEFORGE" "CUSTOM" "FABRIC" "FTBA" "FORGE"
  59. "LOLISERVER" "LIMBO" "MAGMA" "MOHIST" "FABRIC" "PAPER"
  60. "PUFFERFISH" "PURPUR" "QUILT") -}}
  61. {{- if not (mustHas .Values.mcConfig.type $types) -}}
  62. {{- fail (printf "Minecraft - Expected [Type] to be one of [%s], but got [%s]" (join ", " $types) .Values.mcConfig.type) -}}
  63. {{- end -}}
  64. {{- $difficulties := (list "peaceful" "easy" "normal" "hard") -}}
  65. {{- if not (mustHas .Values.mcConfig.difficulty $difficulties) -}}
  66. {{- fail (printf "Minecraft - Expected [Difficulty] to be one of [%s], but got [%s]" (join ", " $difficulties) .Values.mcConfig.difficulty) -}}
  67. {{- end -}}
  68. {{- $modes := (list "creative" "survival" "adventure" "spectator") -}}
  69. {{- if not (mustHas .Values.mcConfig.mode $modes) -}}
  70. {{- fail (printf "Minecraft - Expected [Mode] to be one of [%s], but got [%s]" (join ", " $modes) .Values.mcConfig.mode) -}}
  71. {{- end -}}
  72. {{- $lvlTypes := (list "minecraft:default" "minecraft:flat" "minecraft:large_biomes"
  73. "minecraft:amplified" "minecraft:single_biome_surface" "buffet" "customized") -}}
  74. {{- if not (mustHas .Values.mcConfig.levelType $lvlTypes) -}}
  75. {{- fail (printf "Minecraft - Expected [Level Type] to be one of [%s], but got [%s]" (join ", " $lvlTypes) .Values.mcConfig.levelType) -}}
  76. {{- end -}}
  77. {{- end -}}