Skip to content

Commit

Permalink
chore: only show compatible java versions for the given mc version
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Song <theevansong@gmail.com>
  • Loading branch information
ferothefox committed Oct 16, 2024
1 parent a5adeb0 commit dc9638b
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions apps/frontend/src/pages/servers/manage/[id]/options/startup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@
</label>
<textarea
v-model="invocation"
class="min-h-[200px] w-full font-[family-name:var(--mono-font)]"
class="min-h-[270px] w-full font-[family-name:var(--mono-font)]"
/>
</div>

<div class="card flex flex-col gap-8">
<div class="flex flex-col gap-4">
<label for="username-field" class="flex flex-col gap-2">
<span class="text-lg font-bold text-contrast">Java Version</span>
<span> The version of Java that your server will run on. </span>
<span>
The version of Java that your server will run on. Your server is running Minecraft
{{ data.mc_version }}
</span>
</label>
<DropdownSelect
v-model="jdkVersion"
name="version"
:options="['Java 21', 'Java 17', 'Java 11', 'Java 8']"
:options="compatibleJavaVersions"
placeholder="Java Version"
/>
</div>
Expand Down Expand Up @@ -91,6 +94,24 @@ const jdkBuild = ref(
jdkBuildMap.find((v) => v.value === startupSettings.value?.jdk_build)?.label || "",
);
const isUpdating = ref(false);
const compatibleJavaVersions = computed(() => {
const mcVersion = data.value?.mc_version ?? "";
if (!mcVersion) return jdkVersionMap.map((v) => v.label);
const [major, minor] = mcVersion.split(".").map(Number);
if (major >= 1) {
if (minor >= 20) return ["Java 21"];
if (minor >= 18) return ["Java 17", "Java 21"];
if (minor >= 17) return ["Java 16", "Java 17", "Java 21"];
if (minor >= 12) return ["Java 8", "Java 11", "Java 17", "Java 21"];
if (minor >= 6) return ["Java 8", "Java 11"];
}
return ["Java 8"];
});
const hasUnsavedChanges = computed(
() =>
invocation.value !== startupSettings.value?.invocation ||
Expand Down

0 comments on commit dc9638b

Please sign in to comment.