Skip to content

Commit 4204a2b

Browse files
committed
Touchup Canary Platform
- Don't refer to hooks as 'event's in parameter names - Add icon to Neptune.inf files (optional plugin descriptor in NeptuneMod) - Reinstate the MCP text format colouring (although for both canary + neptune this time)
1 parent 5ad3095 commit 4204a2b

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
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.getCanaryInf() || file == canaryModule.getNeptuneInf()) {
3535
return canaryModule.icon
3636
}
3737
return null

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ class CanaryModule<out T : AbstractModuleType<*>>(facet: MinecraftFacet, overrid
3232

3333
override val type: PlatformType = moduleType.platformType
3434
private var canaryInf: VirtualFile? = null
35+
private var neptuneInf: VirtualFile? = null
3536

3637
init {
3738
setup()
3839
}
3940

4041
private fun setup() {
4142
canaryInf = facet.findFile(CanaryConstants.CANARY_INF, SourceType.RESOURCE)
43+
neptuneInf = facet.findFile(CanaryConstants.NEPTUNE_INF, SourceType.RESOURCE)
4244
}
4345

4446
fun getCanaryInf(): VirtualFile? {
@@ -50,6 +52,15 @@ class CanaryModule<out T : AbstractModuleType<*>>(facet: MinecraftFacet, overrid
5052
return canaryInf
5153
}
5254

55+
fun getNeptuneInf(): VirtualFile? {
56+
if (neptuneInf == null) {
57+
// try and find the file again if it's not already present
58+
// when this object was first created it may not have been ready
59+
setup()
60+
}
61+
return neptuneInf
62+
}
63+
5364
override fun isEventClassValid(eventClass: PsiClass, method: PsiMethod?) =
5465
CanaryConstants.HOOK_CLASS == eventClass.qualifiedName
5566

@@ -89,6 +100,7 @@ class CanaryModule<out T : AbstractModuleType<*>>(facet: MinecraftFacet, overrid
89100
super.dispose()
90101

91102
canaryInf = null
103+
neptuneInf = null
92104
}
93105

94106
companion object {
@@ -102,7 +114,7 @@ class CanaryModule<out T : AbstractModuleType<*>>(facet: MinecraftFacet, overrid
102114
val list = newMethod.parameterList
103115
val parameter = JavaPsiFacade.getElementFactory(project)
104116
.createParameter(
105-
"event",
117+
"hook",
106118
PsiClassType.getTypeByName(chosenClass.qualifiedName, project, GlobalSearchScope.allScope(project))
107119
)
108120
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)