Skip to content

Commit

Permalink
Merge branch '2022.2' into 2022.3
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNesto committed Mar 19, 2023
2 parents 3b75c9e + 67fd41d commit fed3d34
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 11 deletions.
6 changes: 4 additions & 2 deletions .github/ISSUE_TEMPLATE/project_wizard_outdated.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Project Wizard Outdated
description: The Minecraft project wizard is outdated
labels: ["status: unverified", "type: bug"]
labels: ["status: unverified", "type: bug", "feature: creator"]
body:
- type: markdown
attributes:
Expand Down Expand Up @@ -44,4 +44,6 @@ body:
id: description
attributes:
label: Additional description
description: If the issue isn't obvious, please be as detailed as you can.
description: Please be as detailed as you can, as we may not be experts for this platform.
validations:
required: true
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
mcdev
groovy
idea
id("org.jetbrains.intellij") version "1.13.0"
id("org.jetbrains.intellij") version "1.13.2"
id("org.cadixdev.licenser")
id("org.jlleitschuh.gradle.ktlint") version "10.3.0"
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ kotlin.code.style=official
ideaVersion = 2022.3
ideaVersionName = 2022.3

coreVersion = 1.6.1
coreVersion = 1.6.2
downloadIdeaSources = true

pluginTomlVersion = 223.7571.59
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Minecraft Development for IntelliJ
</tr>
</table>

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

<a href="https://discord.gg/j6UNcfr"><img src="https://i.imgur.com/JXu9C1G.png" height="48px"></img></a>
Expand Down
17 changes: 11 additions & 6 deletions src/main/kotlin/creator/ProjectSetupFinalizerWizardStep.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
package com.demonwav.mcdev.creator

import com.demonwav.mcdev.creator.ProjectSetupFinalizer.Factory
import com.demonwav.mcdev.creator.step.NewProjectWizardChainStep.Companion.nextStep
import com.demonwav.mcdev.util.mapFirstNotNull
import com.demonwav.mcdev.util.toTypedArray
import com.intellij.ide.wizard.AbstractNewProjectWizardStep
import com.intellij.ide.wizard.NewProjectWizardStep
import com.intellij.ide.wizard.stepSequence
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.observable.properties.GraphProperty
import com.intellij.openapi.project.Project
Expand Down Expand Up @@ -46,10 +45,16 @@ class ProjectSetupFinalizerWizardStep(parent: NewProjectWizardStep) : AbstractNe
result
}
private val step by lazy {
if (finalizers.isEmpty()) {
null
} else {
stepSequence(finalizers[0], *finalizers.asSequence().drop(1).toTypedArray())
when (finalizers.size) {
0 -> null
1 -> finalizers[0]
else -> {
var step = finalizers[0].nextStep { finalizers[1] }
for (i in 2 until finalizers.size) {
step = step.nextStep { finalizers[i] }
}
step
}
}
}

Expand Down
37 changes: 37 additions & 0 deletions src/main/kotlin/creator/buildsystem/maven-steps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.demonwav.mcdev.creator.step.WebsiteStep
import com.demonwav.mcdev.util.invokeAndWait
import com.demonwav.mcdev.util.runWriteAction
import com.demonwav.mcdev.util.runWriteTask
import com.intellij.execution.RunManager
import com.intellij.ide.wizard.NewProjectWizardStep
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.fileEditor.impl.NonProjectFileWritingAccessProvider
Expand All @@ -35,6 +36,8 @@ import java.nio.file.Path
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.runBlocking
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel
import org.jetbrains.idea.maven.execution.MavenRunConfiguration
import org.jetbrains.idea.maven.execution.MavenRunConfigurationType
import org.jetbrains.idea.maven.project.importing.MavenImportingManager

private val pluginVersions by lazy {
Expand Down Expand Up @@ -165,5 +168,39 @@ class MavenImportStep(parent: NewProjectWizardStep) : AbstractLongRunningStep(pa
} ?: return

promise.finishPromise.blockingGet(Int.MAX_VALUE, TimeUnit.SECONDS)

val buildSystemProps = findStep<BuildSystemPropertiesStep<*>>()
addRunTaskConfiguration(project, buildSystemProps, "package")
}

private fun addRunTaskConfiguration(
project: Project,
buildSystemProps: BuildSystemPropertiesStep<*>,
task: String,
) {
val mavenConfigFactory = MavenRunConfigurationType.getInstance().configurationFactories.first()

val runManager = RunManager.getInstance(project)
val runConfigName = buildSystemProps.artifactId + ' ' + task

val templateConfig = mavenConfigFactory.createTemplateConfiguration(project)
val runConfiguration = mavenConfigFactory.createConfiguration(runConfigName, templateConfig)
as MavenRunConfiguration
runConfiguration.runnerParameters.goals.add(task)

runConfiguration.isAllowRunningInParallel = false

val settings = runManager.createConfiguration(
runConfiguration,
mavenConfigFactory,
)

settings.isActivateToolWindowBeforeRun = true
settings.storeInLocalWorkspace()

runManager.addConfiguration(settings)
if (runManager.selectedConfiguration == null) {
runManager.selectedConfiguration = settings
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class MinecraftClassCreateAction :
builder.addKind("Block", icon, MinecraftTemplates.FABRIC_BLOCK_TEMPLATE)
builder.addKind("Enchantment", icon, MinecraftTemplates.FABRIC_ENCHANTMENT_TEMPLATE)
builder.addKind("Item", icon, MinecraftTemplates.FABRIC_ITEM_TEMPLATE)
builder.addKind("Status Effect", icon, MinecraftTemplates.FABRIC_STATUS_EFFECT_TEMPLATE)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Minecraft Dev for IntelliJ
*
* https://minecraftdev.org
*
* Copyright (c) 2023 minecraft-dev
*
* MIT License
*/

package com.demonwav.mcdev.platform.mixin.inspection

import com.demonwav.mcdev.platform.mixin.util.MixinConstants
import com.intellij.codeInspection.AbstractBaseUastLocalInspectionTool
import com.intellij.codeInspection.InspectionManager
import com.intellij.codeInspection.ProblemDescriptor
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.lang.java.JavaLanguage
import org.jetbrains.uast.UClass

class NonJavaMixinInspection : AbstractBaseUastLocalInspectionTool(UClass::class.java) {
override fun getDisplayName() = "Mixin is not written in Java"
override fun getStaticDescription() =
"<html>Mixins should be written in Java. See <a href=\"$RELEVANT_ISSUE\">this Mixin issue</a></html>"

override fun checkClass(
aClass: UClass,
manager: InspectionManager,
isOnTheFly: Boolean
): Array<ProblemDescriptor>? {
val sourcePsi = aClass.sourcePsi ?: return null
if (sourcePsi.language == JavaLanguage.INSTANCE) {
return null
}
val isMixin = aClass.uAnnotations.any { ann -> ann.qualifiedName == MixinConstants.Annotations.MIXIN }
if (!isMixin) {
return null
}
val problem = manager.createProblemDescriptor(
aClass.uastAnchor?.sourcePsi ?: sourcePsi,
this.staticDescription,
isOnTheFly,
null,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING
)
return arrayOf(problem)
}

companion object {
private const val RELEVANT_ISSUE = "https://github.com/SpongePowered/Mixin/issues/245"
}
}
2 changes: 2 additions & 0 deletions src/main/kotlin/util/MinecraftTemplates.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class MinecraftTemplates : FileTemplateGroupDescriptorFactory {
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_BLOCK_TEMPLATE))
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_ITEM_TEMPLATE))
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_ENCHANTMENT_TEMPLATE))
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_STATUS_EFFECT_TEMPLATE))
}
}

Expand Down Expand Up @@ -254,6 +255,7 @@ class MinecraftTemplates : FileTemplateGroupDescriptorFactory {
const val FABRIC_BLOCK_TEMPLATE = "FabricBlock.java"
const val FABRIC_ITEM_TEMPLATE = "FabricItem.java"
const val FABRIC_ENCHANTMENT_TEMPLATE = "FabricEnchantment.java"
const val FABRIC_STATUS_EFFECT_TEMPLATE = "FabricStatusEffect.java"
}

private fun template(fileName: String, displayName: String? = null) = CustomDescriptor(fileName, displayName)
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,14 @@
<!--endregion-->

<!--region MIXIN INSPECTIONS-->
<localInspection displayName="Mixin is not written in Java"
shortName="NonJavaMixin"
groupName="Mixin"
language="UAST"
enabledByDefault="true"
level="WARNING"
hasStaticDescription="true"
implementationClass="com.demonwav.mcdev.platform.mixin.inspection.NonJavaMixinInspection"/>
<localInspection displayName="Mixin not in a mixin config"
shortName="UnusedMixin"
groupName="Mixin"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")

import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectCategory;

public class ${NAME} extends StatusEffect {
public ${NAME}(StatusEffectCategory statusEffectCategory, int color) {
super(statusEffectCategory, color);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
Minecraft Dev for IntelliJ
https://minecraftdev.org
Copyright (c) 2023 minecraft-dev
MIT License
-->

<html>
<body>
An empty Fabric status effect class.
</body>
</html>

0 comments on commit fed3d34

Please sign in to comment.