Skip to content

Commit 4f50727

Browse files
committed
Merge branch '2023.1' into 2023.2
2 parents 51bf6c5 + d350450 commit 4f50727

File tree

53 files changed

+496
-148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+496
-148
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ jobs:
1313
- uses: actions/setup-java@v3
1414
with:
1515
distribution: 'zulu'
16-
java-version: 17
16+
java-version: |
17+
11
18+
17
1719
- uses: actions/cache@v3
1820
with:
1921
path: |

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ jobs:
2020
- uses: actions/setup-java@v3
2121
with:
2222
distribution: 'zulu'
23-
java-version: 17
23+
java-version: |
24+
11
25+
17
2426
- uses: actions/cache@v3
2527
with:
2628
path: |

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ kotlin.code.style=official
2424
ideaVersion = 232.8453.116-EAP-SNAPSHOT
2525
ideaVersionName = 2023.2
2626

27-
coreVersion = 1.6.7
27+
coreVersion = 1.6.8
2828
downloadIdeaSources = true
2929

3030
pluginTomlVersion = 232.8453.111

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Minecraft Development for IntelliJ
3535
</tr>
3636
</table>
3737

38-
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.6.7-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
38+
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.6.8-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
3939
----------------------
4040

4141
<a href="https://discord.gg/j6UNcfr"><img src="https://i.imgur.com/JXu9C1G.png" height="48px"></img></a>

src/main/kotlin/creator/buildsystem/gradle-steps.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package com.demonwav.mcdev.creator.buildsystem
2222

2323
import com.demonwav.mcdev.creator.addTemplates
2424
import com.demonwav.mcdev.creator.findStep
25+
import com.demonwav.mcdev.creator.notifyCreatedProjectNotOpened
2526
import com.demonwav.mcdev.creator.step.AbstractLongRunningStep
2627
import com.demonwav.mcdev.creator.step.AbstractReformatFilesStep
2728
import com.demonwav.mcdev.creator.step.FixedAssetsNewProjectWizardStep
@@ -123,7 +124,8 @@ abstract class AbstractPatchGradleFilesStep(parent: NewProjectWizardStep) : Abst
123124

124125
override fun perform(project: Project) {
125126
invokeAndWait {
126-
if (project.isDisposed) {
127+
if (project.isDisposed || !project.isInitialized) {
128+
notifyCreatedProjectNotOpened()
127129
return@invokeAndWait
128130
}
129131

@@ -195,6 +197,11 @@ open class GradleImportStep(parent: NewProjectWizardStep) : AbstractLongRunningS
195197
open val additionalRunTasks = emptyList<String>()
196198

197199
override fun perform(project: Project) {
200+
if (!project.isInitialized) {
201+
notifyCreatedProjectNotOpened()
202+
return
203+
}
204+
198205
val rootDirectory = Path.of(context.projectFileDirectory)
199206
val buildSystemProps = findStep<BuildSystemPropertiesStep<*>>()
200207

src/main/kotlin/creator/buildsystem/maven-steps.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package com.demonwav.mcdev.creator.buildsystem
2222

2323
import com.demonwav.mcdev.creator.findStep
2424
import com.demonwav.mcdev.creator.getVersionJson
25+
import com.demonwav.mcdev.creator.notifyCreatedProjectNotOpened
2526
import com.demonwav.mcdev.creator.step.AbstractLongRunningStep
2627
import com.demonwav.mcdev.creator.step.AbstractModNameStep
2728
import com.demonwav.mcdev.creator.step.AbstractReformatFilesStep
@@ -126,7 +127,8 @@ abstract class AbstractPatchPomStep(parent: NewProjectWizardStep) : AbstractLong
126127

127128
override fun perform(project: Project) {
128129
invokeAndWait {
129-
if (project.isDisposed) {
130+
if (project.isDisposed || !project.isInitialized) {
131+
notifyCreatedProjectNotOpened()
130132
return@invokeAndWait
131133
}
132134

@@ -173,7 +175,8 @@ class MavenImportStep(parent: NewProjectWizardStep) : AbstractLongRunningStep(pa
173175
val pomFile = VfsUtil.findFile(Path.of(context.projectFileDirectory).resolve("pom.xml"), true)
174176
?: return
175177
val promise = invokeAndWait {
176-
if (project.isDisposed) {
178+
if (project.isDisposed || !project.isInitialized) {
179+
notifyCreatedProjectNotOpened()
177180
return@invokeAndWait null
178181
}
179182
MavenImportingManager.getInstance(project).linkAndImportFile(pomFile)

src/main/kotlin/creator/creator-utils.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import com.intellij.ide.starters.local.GeneratorTemplateFile
2929
import com.intellij.ide.wizard.AbstractNewProjectWizardStep
3030
import com.intellij.ide.wizard.GitNewProjectWizardData
3131
import com.intellij.ide.wizard.NewProjectWizardStep
32+
import com.intellij.notification.Notification
33+
import com.intellij.notification.NotificationType
3234
import com.intellij.openapi.observable.properties.ObservableMutableProperty
3335
import com.intellij.openapi.observable.properties.ObservableProperty
3436
import com.intellij.openapi.project.Project
@@ -149,3 +151,12 @@ fun <T> ObservableMutableProperty<T>.updateWhenChanged(dependency: ObservablePro
149151
}
150152

151153
class EmptyStep(parent: NewProjectWizardStep) : AbstractNewProjectWizardStep(parent)
154+
155+
fun notifyCreatedProjectNotOpened() {
156+
Notification(
157+
"Minecraft project creator",
158+
"Created project must be opened",
159+
"Generated files might be incomplete and the project might be broken.",
160+
NotificationType.ERROR,
161+
).notify(null)
162+
}

src/main/kotlin/creator/step/AbstractReformatFilesStep.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package com.demonwav.mcdev.creator.step
2222

23+
import com.demonwav.mcdev.creator.notifyCreatedProjectNotOpened
2324
import com.intellij.codeInsight.actions.ReformatCodeProcessor
2425
import com.intellij.ide.wizard.NewProjectWizardStep
2526
import com.intellij.openapi.application.ReadAction
@@ -56,6 +57,11 @@ abstract class AbstractReformatFilesStep(parent: NewProjectWizardStep) : Abstrac
5657

5758
NonProjectFileWritingAccessProvider.disableChecksDuring {
5859
WriteCommandAction.writeCommandAction(project, *files).withGlobalUndo().run<Throwable> {
60+
if (project.isDisposed || !project.isInitialized) {
61+
notifyCreatedProjectNotOpened()
62+
return@run
63+
}
64+
5965
ReformatCodeProcessor(project, files, null, false).run()
6066
}
6167
}

src/main/kotlin/creator/step/MainClassStep.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ class MainClassStep(parent: NewProjectWizardStep) : AbstractNewProjectWizardStep
6464
whenStepAvailable<BuildSystemPropertiesStep<*>> { buildSystemStep ->
6565
classNameProperty.updateWhenChanged(buildSystemStep.groupIdProperty, ::suggestMainClassName)
6666
classNameProperty.updateWhenChanged(buildSystemStep.artifactIdProperty, ::suggestMainClassName)
67-
68-
buildSystemStep.groupIdProperty.updateWhenChanged(classNameProperty, ::suggestGroupId)
6967
}
7068
whenStepAvailable<AbstractModNameStep> { modNameStep ->
7169
classNameProperty.updateWhenChanged(modNameStep.nameProperty, ::suggestMainClassName)
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* Minecraft Development for IntelliJ
3+
*
4+
* https://mcdev.io/
5+
*
6+
* Copyright (C) 2023 minecraft-dev
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Lesser General Public License as published
10+
* by the Free Software Foundation, version 3.0 only.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
package com.demonwav.mcdev.creator.step
22+
23+
import com.demonwav.mcdev.creator.storeToData
24+
import com.intellij.ide.wizard.AbstractNewProjectWizardStep
25+
import com.intellij.ide.wizard.NewProjectWizardBaseData
26+
import com.intellij.ide.wizard.NewProjectWizardStep
27+
import com.intellij.openapi.project.Project
28+
import com.intellij.openapi.ui.validation.AFTER_GRAPH_PROPAGATION
29+
import com.intellij.openapi.ui.validation.CHECK_NON_EMPTY
30+
import com.intellij.openapi.ui.validation.and
31+
import com.intellij.openapi.ui.validation.validationErrorIf
32+
import com.intellij.openapi.util.Key
33+
import com.intellij.ui.dsl.builder.COLUMNS_MEDIUM
34+
import com.intellij.ui.dsl.builder.Panel
35+
import com.intellij.ui.dsl.builder.bindText
36+
import com.intellij.ui.dsl.builder.columns
37+
import com.intellij.ui.dsl.builder.textValidation
38+
39+
private val validModIdRegex = "[a-z][a-z0-9-_]{1,63}".toRegex()
40+
private val invalidModIdRegex = "[^a-z0-9-_]+".toRegex()
41+
42+
private val validForgeModIdRegex = "[a-z][a-z0-9_]{1,63}".toRegex()
43+
private val invalidForgeModIdRegex = "[^a-z0-9_]+".toRegex()
44+
45+
abstract class AbstractModIdStep(
46+
parent: NewProjectWizardStep,
47+
private val validRegex: Regex = validModIdRegex,
48+
private val invalidRegex: Regex = invalidModIdRegex
49+
) : AbstractNewProjectWizardStep(parent) {
50+
private val baseData = data.getUserData(NewProjectWizardBaseData.KEY)
51+
?: throw IllegalStateException("Mod id step created without base step")
52+
val idProperty = propertyGraph.lazyProperty(::suggestId)
53+
var id by idProperty
54+
55+
private val idValidation = validationErrorIf<String>("Id must match $validRegex") { !it.matches(validRegex) }
56+
57+
init {
58+
idProperty.dependsOn(baseData.nameProperty, ::suggestId)
59+
storeToData()
60+
}
61+
62+
fun suggestId(): String {
63+
val sanitized = baseData.name.lowercase().replace(invalidRegex, "_")
64+
if (sanitized.length > 64) {
65+
return sanitized.substring(0, 64)
66+
}
67+
return sanitized
68+
}
69+
70+
abstract val label: String
71+
72+
override fun setupUI(builder: Panel) {
73+
with(builder) {
74+
row(label) {
75+
textField()
76+
.bindText(idProperty)
77+
.columns(COLUMNS_MEDIUM)
78+
.validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph))
79+
.textValidation(CHECK_NON_EMPTY and idValidation)
80+
}
81+
}
82+
}
83+
84+
override fun setupProject(project: Project) {
85+
data.putUserData(KEY, id)
86+
}
87+
88+
companion object {
89+
val KEY = Key.create<String>("${AbstractModIdStep::class.java.name}.id")
90+
}
91+
}
92+
93+
class ModIdStep(parent: NewProjectWizardStep) : AbstractModIdStep(parent) {
94+
override val label = "Mod Id:"
95+
}
96+
97+
class ForgeStyleModIdStep(parent: NewProjectWizardStep) :
98+
AbstractModIdStep(parent, validForgeModIdRegex, invalidForgeModIdRegex) {
99+
override val label = "Mod Id:"
100+
}
101+
102+
class PluginIdStep(parent: NewProjectWizardStep) : AbstractModIdStep(parent) {
103+
override val label = "Plugin Id:"
104+
}

0 commit comments

Comments
 (0)