Skip to content

Commit 09bd94e

Browse files
committed
Merge branch '2021.1' into 2021.2
2 parents f92c2d6 + 802ae84 commit 09bd94e

File tree

50 files changed

+712
-81
lines changed

Some content is hidden

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

50 files changed

+712
-81
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ kotlin.code.style=official
1414
ideaVersion = 2021.2
1515
ideaVersionName = 2021.2
1616

17-
coreVersion = 1.5.13
17+
coreVersion = 1.5.14
1818
downloadIdeaSources = true
1919

2020
pluginTomlVersion = 0.2.151.3997-212

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Minecraft Development for IntelliJ
3232
</tr>
3333
</table>
3434

35-
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.5.13-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
35+
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.5.14-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
3636
----------------------
3737

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

src/main/kotlin/creator/BuildSystemWizardStep.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class BuildSystemWizardStep(private val creator: MinecraftProjectCreator) : Modu
3535
override fun getComponent() = panel
3636

3737
override fun updateStep() {
38+
val previousBuildSystem = buildSystemBox.selectedItem
3839
buildSystemBox.removeAllItems()
3940
buildSystemBox.isEnabled = true
4041

@@ -46,12 +47,18 @@ class BuildSystemWizardStep(private val creator: MinecraftProjectCreator) : Modu
4647
buildSystemBox.addItem(type)
4748
}
4849

49-
buildSystemBox.selectedIndex = 0
5050
if (buildSystemBox.itemCount == 1) {
5151
buildSystemBox.isEnabled = false
5252
return
5353
}
5454

55+
if (previousBuildSystem != null) {
56+
buildSystemBox.selectedItem = previousBuildSystem
57+
return
58+
}
59+
60+
buildSystemBox.selectedIndex = 0
61+
5562
// We prefer Gradle, so if it's included, choose it
5663
// If Gradle is not included, luck of the draw
5764
if (creator.configs.any { it.preferredBuildSystem == BuildSystemType.GRADLE }) {

src/main/kotlin/creator/MinecraftModuleBuilder.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import com.intellij.openapi.roots.ModifiableRootModel
3232
import com.intellij.openapi.roots.ui.configuration.ModulesProvider
3333
import com.intellij.openapi.startup.StartupManager
3434
import com.intellij.openapi.util.io.FileUtil
35+
import com.intellij.openapi.util.registry.Registry
3536
import com.intellij.openapi.vfs.LocalFileSystem
3637
import com.intellij.openapi.vfs.VirtualFile
3738
import java.nio.file.Files
@@ -103,7 +104,7 @@ class MinecraftModuleBuilder : JavaModuleBuilder() {
103104
wizardContext: WizardContext,
104105
modulesProvider: ModulesProvider
105106
): Array<ModuleWizardStep> {
106-
return arrayOf(
107+
val baseSteps = arrayOf(
107108
BuildSystemWizardStep(creator),
108109
BukkitProjectSettingsWizard(creator),
109110
SpongeProjectSettingsWizard(creator),
@@ -113,6 +114,10 @@ class MinecraftModuleBuilder : JavaModuleBuilder() {
113114
VelocityProjectSettingsWizard(creator),
114115
BungeeCordProjectSettingsWizard(creator)
115116
)
117+
if (Registry.`is`("mcdev.wizard.finalizer")) {
118+
return baseSteps + ProjectSetupFinalizerWizardStep(creator, wizardContext)
119+
}
120+
return baseSteps
116121
}
117122

118123
override fun getCustomOptionsStep(context: WizardContext?, parentDisposable: Disposable?) =

src/main/kotlin/creator/MinecraftProjectCreator.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import com.demonwav.mcdev.util.invokeAndWait
1616
import com.demonwav.mcdev.util.invokeLater
1717
import com.demonwav.mcdev.util.virtualFileOrError
1818
import com.intellij.openapi.module.Module
19+
import com.intellij.openapi.progress.ProcessCanceledException
1920
import com.intellij.openapi.progress.ProgressIndicator
2021
import com.intellij.openapi.progress.ProgressManager
2122
import com.intellij.openapi.progress.Task
@@ -159,6 +160,10 @@ class MinecraftProjectCreator {
159160
VfsUtil.markDirtyAndRefresh(false, true, true, root.virtualFileOrError)
160161
}
161162
} catch (e: Exception) {
163+
if (e is ProcessCanceledException || e.cause is ProcessCanceledException) {
164+
// Do not log PCE. The second condition is there because LaterInvocator wraps PCEs in RuntimeExceptions
165+
return
166+
}
162167
val workLogText = buildString {
163168
appendLine("Build steps completed:")
164169
for (workLogStep in workLog) {

src/main/kotlin/creator/PlatformVersion.kt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,46 @@ import com.demonwav.mcdev.platform.PlatformType
1414
import com.demonwav.mcdev.util.ProxyHttpConnectionFactory
1515
import com.demonwav.mcdev.util.fromJson
1616
import com.google.gson.Gson
17+
import com.intellij.openapi.diagnostic.Attachment
18+
import com.intellij.openapi.diagnostic.Logger
1719
import java.io.IOException
1820
import javax.swing.JComboBox
1921

2022
private const val cloudflareBaseUrl = "https://minecraftdev.org/versions/"
2123
private const val githubBaseUrl = "https://raw.githubusercontent.com/minecraft-dev/minecraftdev.org/master/versions/"
2224

25+
val PLATFORM_VERSION_LOGGER = Logger.getInstance("MDev.PlatformVersion")
26+
2327
fun getVersionSelector(type: PlatformType): PlatformVersion {
2428
val versionJson = type.versionJson ?: throw UnsupportedOperationException("Incorrect platform type: $type")
2529
return getVersionJson(versionJson)
2630
}
2731

2832
inline fun <reified T : Any> getVersionJson(path: String): T {
2933
val text = getText(path)
30-
return Gson().fromJson(text)
34+
try {
35+
return Gson().fromJson(text)
36+
} catch (e: Exception) {
37+
val attachment = Attachment("JSON Document", text)
38+
attachment.isIncluded = true
39+
PLATFORM_VERSION_LOGGER.error("Failed to parse JSON document from '$path'", e, attachment)
40+
throw e
41+
}
3142
}
3243

3344
fun getText(path: String): String {
3445
return try {
3546
// attempt cloudflare
3647
doCall(cloudflareBaseUrl + path)
3748
} catch (e: IOException) {
49+
PLATFORM_VERSION_LOGGER.warn("Failed to reach cloudflare URL ${cloudflareBaseUrl + path}", e)
3850
// if that fails, attempt github
39-
doCall(githubBaseUrl + path)
51+
try {
52+
doCall(githubBaseUrl + path)
53+
} catch (e: IOException) {
54+
PLATFORM_VERSION_LOGGER.warn("Failed to reach fallback GitHub URL ${githubBaseUrl + path}", e)
55+
throw e
56+
}
4057
}
4158
}
4259

src/main/kotlin/creator/ProjectConfig.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ package com.demonwav.mcdev.creator
1313
import com.demonwav.mcdev.creator.buildsystem.BuildSystemType
1414
import com.demonwav.mcdev.platform.PlatformType
1515
import com.intellij.util.containers.isNullOrEmpty
16+
import com.intellij.util.lang.JavaVersion
1617

1718
private val bracketRegex = Regex("[\\[\\]]")
1819
private val commaRegex = Regex("\\s*,\\s*")
@@ -37,6 +38,8 @@ abstract class ProjectConfig {
3738
var description: String? = null
3839
fun hasDescription() = description?.isNotBlank() == true
3940

41+
abstract val javaVersion: JavaVersion
42+
4043
protected fun commaSplit(string: String): List<String> {
4144
return if (!string.isBlank()) {
4245
string.trim().replace(bracketRegex, "").split(commaRegex).toList()

0 commit comments

Comments
 (0)