Validate and deduplicate custom difficulty presets
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 6m4s

This commit is contained in:
2026-10-16 13:29:32 +05:00
parent 1a34eb71c2
commit 0bd05d6e0b
10 changed files with 427 additions and 41 deletions

View File

@@ -0,0 +1,13 @@
import type { DifficultyPreset } from "./protocol";
// A list fetched before a save must not remove the newly saved preset.
export function mergeDifficultyPresets(
current: DifficultyPreset[],
incoming: DifficultyPreset[],
) {
return [
...new Map(
[...current, ...incoming].map((preset) => [preset.id, preset]),
).values(),
].sort((a, b) => a.name.localeCompare(b.name));
}