Skip to content

Commit 4b4ad00

Browse files
authored
Merge pull request #308 from jamierocks/canary-improv
Touchup Canary Platform
2 parents 7d30bcb + 30371f1 commit 4b4ad00

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

src/main/kotlin/com/demonwav/mcdev/platform/canary/CanaryFileIconProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CanaryFileIconProvider : FileIconProvider {
3131
val module = ModuleUtilCore.findModuleForFile(file, project) ?: return null
3232
val canaryModule = MinecraftFacet.getInstance(module, CanaryModuleType, NeptuneModuleType) ?: return null
3333

34-
if (file == canaryModule.getCanaryInf()) {
34+
if (file == canaryModule.canaryInf || file == canaryModule.neptuneInf) {
3535
return canaryModule.icon
3636
}
3737
return null

src/main/kotlin/com/demonwav/mcdev/platform/canary/CanaryModule.kt

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,22 @@ import com.intellij.psi.search.GlobalSearchScope
3131
class CanaryModule<out T : AbstractModuleType<*>>(facet: MinecraftFacet, override val moduleType: T) : AbstractModule(facet) {
3232

3333
override val type: PlatformType = moduleType.platformType
34-
private var canaryInf: VirtualFile? = null
35-
36-
init {
37-
setup()
38-
}
39-
40-
private fun setup() {
41-
canaryInf = facet.findFile(CanaryConstants.CANARY_INF, SourceType.RESOURCE)
42-
}
43-
44-
fun getCanaryInf(): VirtualFile? {
45-
if (canaryInf == null) {
46-
// try and find the file again if it's not already present
47-
// when this object was first created it may not have been ready
48-
setup()
34+
var canaryInf: VirtualFile? = null
35+
get() {
36+
if (field == null) {
37+
field = facet.findFile(CanaryConstants.CANARY_INF, SourceType.RESOURCE)
38+
}
39+
return field
4940
}
50-
return canaryInf
51-
}
41+
private set
42+
var neptuneInf: VirtualFile? = null
43+
get() {
44+
if (field == null) {
45+
field = facet.findFile(CanaryConstants.NEPTUNE_INF, SourceType.RESOURCE)
46+
}
47+
return field
48+
}
49+
private set
5250

5351
override fun isEventClassValid(eventClass: PsiClass, method: PsiMethod?) =
5452
CanaryConstants.HOOK_CLASS == eventClass.qualifiedName
@@ -89,6 +87,7 @@ class CanaryModule<out T : AbstractModuleType<*>>(facet: MinecraftFacet, overrid
8987
super.dispose()
9088

9189
canaryInf = null
90+
neptuneInf = null
9291
}
9392

9493
companion object {
@@ -102,7 +101,7 @@ class CanaryModule<out T : AbstractModuleType<*>>(facet: MinecraftFacet, overrid
102101
val list = newMethod.parameterList
103102
val parameter = JavaPsiFacade.getElementFactory(project)
104103
.createParameter(
105-
"event",
104+
"hook",
106105
PsiClassType.getTypeByName(chosenClass.qualifiedName, project, GlobalSearchScope.allScope(project))
107106
)
108107
list.add(parameter)

src/main/kotlin/com/demonwav/mcdev/platform/canary/CanaryModuleType.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ object CanaryModuleType : AbstractModuleType<CanaryModule<CanaryModuleType>>("ne
3434

3535
init {
3636
CommonColors.applyStandardColors(colorMap, CanaryConstants.CHAT_FORMAT_CLASS)
37+
CommonColors.applyStandardColors(colorMap, CanaryConstants.MCP_CHAT_FORMATTING)
3738
CanaryLegacyColors.applyLegacyColors(colorMap, CanaryConstants.LEGACY_COLORS_CLASS)
3839
CanaryLegacyColors.applyLegacyColors(colorMap, CanaryConstants.LEGACY_TEXT_FORMAT_CLASS)
3940
}

src/main/kotlin/com/demonwav/mcdev/platform/canary/NeptuneModuleType.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ object NeptuneModuleType : AbstractModuleType<CanaryModule<NeptuneModuleType>>("
2626

2727
init {
2828
CommonColors.applyStandardColors(colorMap, CanaryConstants.CHAT_FORMAT_CLASS)
29+
CommonColors.applyStandardColors(colorMap, CanaryConstants.MCP_CHAT_FORMATTING)
2930
CanaryLegacyColors.applyLegacyColors(colorMap, CanaryConstants.LEGACY_COLORS_CLASS)
3031
CanaryLegacyColors.applyLegacyColors(colorMap, CanaryConstants.LEGACY_TEXT_FORMAT_CLASS)
3132
}

src/main/kotlin/com/demonwav/mcdev/platform/canary/util/CanaryConstants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ package com.demonwav.mcdev.platform.canary.util
1313
object CanaryConstants {
1414

1515
const val CANARY_INF = "Canary.inf"
16+
const val NEPTUNE_INF = "Neptune.inf"
1617

1718
/* Hooks */
1819
const val HOOK_HANDLER_ANNOTATION = "net.canarymod.hook.HookHandler"

0 commit comments

Comments
 (0)