Skip to content

Commit 0516217

Browse files
committed
Fix empty template repo list issues
Prevents template repos list from being set to empty, and automatically handles when the list ends up empty anyways. Fixes: 2517
1 parent 52b2f0b commit 0516217

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/main/kotlin/MinecraftSettings.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* https://mcdev.io/
55
*
6-
* Copyright (C) 2025 minecraft-dev
6+
* Copyright (C) 2026 minecraft-dev
77
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Lesser General Public License as published
@@ -90,7 +90,7 @@ class MinecraftSettings : PersistentStateComponent<MinecraftSettings.State> {
9090
override fun loadState(state: State) {
9191
this.state = state
9292
if (state.creatorTemplateRepos.isEmpty()) {
93-
state.creatorTemplateRepos = listOf()
93+
state.creatorTemplateRepos = listOf(TemplateRepo.makeBuiltinRepo())
9494
}
9595
}
9696

@@ -140,7 +140,8 @@ class MinecraftSettings : PersistentStateComponent<MinecraftSettings.State> {
140140
var creatorTemplateRepos: List<TemplateRepo>
141141
get() = state.creatorTemplateRepos.map { it.copy() }
142142
set(creatorTemplateRepos) {
143-
state.creatorTemplateRepos = creatorTemplateRepos.map { it.copy() }
143+
state.creatorTemplateRepos = creatorTemplateRepos.ifEmpty { listOf(TemplateRepo.makeBuiltinRepo()) }
144+
.map { it.copy() }
144145
}
145146

146147
var creatorMavenRepos: List<MavenRepo>

src/main/kotlin/creator/custom/CustomPlatformStep.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class CustomPlatformStep(
215215
private fun initTemplates() {
216216
selectedTemplate = EmptyLoadedTemplate
217217

218-
templateRepoProperty.set(templateRepos.first())
218+
templateRepoProperty.set(templateRepos.firstOrNull() ?: MinecraftSettings.TemplateRepo.makeBuiltinRepo())
219219

220220
val indicator = CreatorProgressIndicator(
221221
templateProvidersLoadingProperty,

src/main/kotlin/creator/custom/TemplateRepoTable.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ fun Row.templateRepoTable(
9797

9898
val decoratedTable = ToolbarDecorator.createDecorator(table)
9999
.setPreferredSize(Dimension(JBUI.scale(300), JBUI.scale(200)))
100+
.setRemoveActionUpdater { table.rowCount > 1 }
100101
.setEditActionUpdater {
101102
val selectedRepo = table.selection.firstOrNull()
102103
?: return@setEditActionUpdater false

0 commit comments

Comments
 (0)