User: kyle wood Date: 14 Aug 23 01:49 Revision: b3d07a201b96ee310cdcbee0246521a9206968e8 Summary: Migrate additional packages up to NBT to message bundles TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=8708&personal=false Index: src/main/kotlin/asset/MCDevBundle.kt =================================================================== --- src/main/kotlin/asset/MCDevBundle.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/asset/MCDevBundle.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -29,11 +29,11 @@ object MCDevBundle : DynamicBundle(BUNDLE) { - fun message(@PropertyKey(resourceBundle = BUNDLE) key: String): String { + operator fun invoke(@PropertyKey(resourceBundle = BUNDLE) key: String): String { return getMessage(key) } - fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String { + operator fun invoke(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any?): String { return getMessage(key, *params) } } Index: src/main/kotlin/creator/MinecraftModuleBuilder.kt =================================================================== --- src/main/kotlin/creator/MinecraftModuleBuilder.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/MinecraftModuleBuilder.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -41,7 +41,7 @@ override fun getNodeIcon() = PlatformAssets.MINECRAFT_ICON override fun getGroupName() = MinecraftModuleType.NAME override fun getBuilderId() = "MINECRAFT_MODULE" - override fun getDescription() = MCDevBundle.message("creator.ui.create_minecraft_project") + override fun getDescription() = MCDevBundle("creator.ui.create_minecraft_project") override fun setupRootModel(modifiableRootModel: ModifiableRootModel) { if (moduleJdk != null) { Index: src/main/kotlin/creator/ProjectSetupFinalizerWizardStep.kt =================================================================== --- src/main/kotlin/creator/ProjectSetupFinalizerWizardStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/ProjectSetupFinalizerWizardStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -120,7 +120,7 @@ private var sdk by sdkProperty private var sdkComboBox: JdkComboBoxWithPreference? = null private var preferredJdkLabel: Placeholder? = null - private var preferredJdkReason = MCDevBundle.message("creator.validation.jdk_preferred_default_reason") + private var preferredJdkReason = MCDevBundle("creator.validation.jdk_preferred_default_reason") var preferredJdk: JavaSdkVersion = JavaSdkVersion.JDK_17 private set @@ -147,7 +147,7 @@ preferredJdkLabel?.component = null } else { preferredJdkLabel?.component = - JLabel(MCDevBundle.message("creator.validation.jdk_preferred", preferredJdk.description, preferredJdkReason)) + JLabel(MCDevBundle("creator.validation.jdk_preferred", preferredJdk.description, preferredJdkReason)) .also { it.foreground = JBColor.YELLOW } } } Index: src/main/kotlin/creator/buildsystem/AbstractBuildSystemStep.kt =================================================================== --- src/main/kotlin/creator/buildsystem/AbstractBuildSystemStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/buildsystem/AbstractBuildSystemStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -49,7 +49,7 @@ override val self get() = this override val label - get() = MCDevBundle.message("creator.ui.build_system.label.generic") + get() = MCDevBundle("creator.ui.build_system.label.generic") override fun initSteps(): LinkedHashMap { context.putUserData(PLATFORM_NAME_KEY, platformName) @@ -97,12 +97,12 @@ class GradleBuildSystem : AbstractBuildSystemStep.Factory { override val name - get() = MCDevBundle.message("creator.ui.build_system.label.gradle") + get() = MCDevBundle("creator.ui.build_system.label.gradle") } class MavenBuildSystem : AbstractBuildSystemStep.Factory { override val name - get() = MCDevBundle.message("creator.ui.build_system.label.maven") + get() = MCDevBundle("creator.ui.build_system.label.maven") } abstract class AbstractRunBuildSystemStep( Index: src/main/kotlin/creator/buildsystem/BuildSystemPropertiesStep.kt =================================================================== --- src/main/kotlin/creator/buildsystem/BuildSystemPropertiesStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/buildsystem/BuildSystemPropertiesStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -38,11 +38,11 @@ import com.intellij.ui.dsl.builder.columns import com.intellij.ui.dsl.builder.textValidation -private val nonExampleValidation = validationErrorIf(MCDevBundle.message("creator.validation.group_id_non_example")) { +private val nonExampleValidation = validationErrorIf(MCDevBundle("creator.validation.group_id_non_example")) { it == "org.example" } -private val versionValidation = validationErrorIf(MCDevBundle.message("creator.validation.semantic_version")) { +private val versionValidation = validationErrorIf(MCDevBundle("creator.validation.semantic_version")) { SemanticVersion.tryParse(it) == null } @@ -67,22 +67,22 @@ private fun suggestArtifactId() = parent.name override fun setupUI(builder: Panel) { - builder.collapsibleGroup(MCDevBundle.message("creator.ui.group.title")) { - row(MCDevBundle.message("creator.ui.group.group_id")) { + builder.collapsibleGroup(MCDevBundle("creator.ui.group.title")) { + row(MCDevBundle("creator.ui.group.group_id")) { textField() .bindText(groupIdProperty) .columns(COLUMNS_MEDIUM) .validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph)) .textValidation(CHECK_NON_EMPTY, CHECK_GROUP_ID, nonExampleValidation) } - row(MCDevBundle.message("creator.ui.group.artifact_id")) { + row(MCDevBundle("creator.ui.group.artifact_id")) { textField() .bindText(artifactIdProperty) .columns(COLUMNS_MEDIUM) .validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph)) .textValidation(CHECK_NON_EMPTY, CHECK_ARTIFACT_ID) } - row(MCDevBundle.message("creator.ui.group.version")) { + row(MCDevBundle("creator.ui.group.version")) { textField() .bindText(versionProperty) .columns(COLUMNS_MEDIUM) Index: src/main/kotlin/creator/buildsystem/gradle-steps.kt =================================================================== --- src/main/kotlin/creator/buildsystem/gradle-steps.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/buildsystem/gradle-steps.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -90,7 +90,7 @@ abstract class AbstractPatchGradleFilesStep(parent: NewProjectWizardStep) : AbstractLongRunningStep(parent) { override val description - get() = MCDevBundle.message("creator.step.gradle.patch_gradle.description") + get() = MCDevBundle("creator.step.gradle.patch_gradle.description") abstract fun patch(project: Project, gradleFiles: GradleFiles) @@ -195,7 +195,7 @@ open class GradleImportStep(parent: NewProjectWizardStep) : AbstractLongRunningStep(parent) { override val description - get() = MCDevBundle.message("creator.step.gradle.import_gradle.description") + get() = MCDevBundle("creator.step.gradle.import_gradle.description") open val additionalRunTasks = emptyList() Index: src/main/kotlin/creator/buildsystem/maven-steps.kt =================================================================== --- src/main/kotlin/creator/buildsystem/maven-steps.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/buildsystem/maven-steps.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -64,7 +64,7 @@ abstract class AbstractPatchPomStep(parent: NewProjectWizardStep) : AbstractLongRunningStep(parent) { override val description - get() = MCDevBundle.message("creator.step.maven.patch_pom.description") + get() = MCDevBundle("creator.step.maven.patch_pom.description") open fun patchPom(model: MavenDomProjectModel, root: XmlTag) { setupCore(model) @@ -171,7 +171,7 @@ class MavenImportStep(parent: NewProjectWizardStep) : AbstractLongRunningStep(parent) { override val description - get() = MCDevBundle.message("creator.step.maven.import_maven.description") + get() = MCDevBundle("creator.step.maven.import_maven.description") override fun perform(project: Project) { val pomFile = VfsUtil.findFile(Path.of(context.projectFileDirectory).resolve("pom.xml"), true) Index: src/main/kotlin/creator/platformtype/ModPlatformStep.kt =================================================================== --- src/main/kotlin/creator/platformtype/ModPlatformStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/platformtype/ModPlatformStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -41,11 +41,11 @@ override val self = this override val label - get() = MCDevBundle.message("creator.ui.platform.label") + get() = MCDevBundle("creator.ui.platform.label") class TypeFactory : PlatformTypeStep.Factory { override val name - get() = MCDevBundle.message("creator.ui.platform.mod.name") + get() = MCDevBundle("creator.ui.platform.mod.name") override fun createStep(parent: PlatformTypeStep) = ModPlatformStep(parent) } Index: src/main/kotlin/creator/platformtype/PlatformTypeStep.kt =================================================================== --- src/main/kotlin/creator/platformtype/PlatformTypeStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/platformtype/PlatformTypeStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -47,7 +47,7 @@ override val self = this override val label - get() = MCDevBundle.message("creator.ui.platform.type.label") + get() = MCDevBundle("creator.ui.platform.type.label") interface Factory : NewProjectWizardMultiStepFactory } Index: src/main/kotlin/creator/platformtype/PluginPlatformStep.kt =================================================================== --- src/main/kotlin/creator/platformtype/PluginPlatformStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/platformtype/PluginPlatformStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -41,11 +41,11 @@ override val self = this override val label - get() = MCDevBundle.message("creator.ui.platform.label") + get() = MCDevBundle("creator.ui.platform.label") class TypeFactory : PlatformTypeStep.Factory { override val name - get() = MCDevBundle.message("creator.ui.platform.plugin.name") + get() = MCDevBundle("creator.ui.platform.plugin.name") override fun createStep(parent: PlatformTypeStep) = PluginPlatformStep(parent) } Index: src/main/kotlin/creator/step/AbstractLatentStep.kt =================================================================== --- src/main/kotlin/creator/step/AbstractLatentStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/step/AbstractLatentStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -105,9 +105,17 @@ if (result == null) { placeholder.component = panel { row { - val label = label(MCDevBundle.message("creator.ui.generic_validation_failure.message", description)) + val label = label(MCDevBundle("creator.ui.generic_validation_failure.message", description)) .validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph)) - .validation(DialogValidation { ValidationInfo(MCDevBundle.message("creator.ui.generic_validation_failure.message", description)) }) + .validation( + DialogValidation { + val labelValidationText = MCDevBundle( + "creator.ui.generic_validation_failure.message", + description + ) + ValidationInfo(labelValidationText) + } + ) label.component.foreground = JBColor.RED } } @@ -153,10 +161,14 @@ }, ) .validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph)) - .validation(DialogValidation { ValidationInfo(MCDevBundle.message("creator.ui.generic_unfinished.message", description)) }) + .validation( + DialogValidation { + ValidationInfo(MCDevBundle("creator.ui.generic_unfinished.message", description)) - } + } + ) - } - } + } + } + } override fun setupProject(project: Project) { step?.setupProject(project) Index: src/main/kotlin/creator/step/AbstractLongRunningStep.kt =================================================================== --- src/main/kotlin/creator/step/AbstractLongRunningStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/step/AbstractLongRunningStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -58,13 +58,16 @@ } private fun startTaskQueue(project: Project, queue: TaskQueue) { - ProgressManager.getInstance().run(object : Task.Backgroundable(project, MCDevBundle.message("creator.step.generic.project_created.message")) { + val task = object : Task.Backgroundable( + project, + MCDevBundle("creator.step.generic.project_created.message") + ) { override fun run(indicator: ProgressIndicator) { if (project.isDisposed) { return } - indicator.text = MCDevBundle.message("creator.step.generic.project_created.message") + indicator.text = MCDevBundle("creator.step.generic.project_created.message") var currentQueue = queue while (true) { while (true) { @@ -85,10 +88,11 @@ } indicator.text2 = null } - }, - ) - } + } + ProgressManager.getInstance().run(task) + } + companion object { private val TASK_QUEUE_KEY = Key.create("${AbstractLongRunningStep::class.java.name}.queue") } Index: src/main/kotlin/creator/step/AbstractReformatFilesStep.kt =================================================================== --- src/main/kotlin/creator/step/AbstractReformatFilesStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/step/AbstractReformatFilesStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -35,7 +35,7 @@ abstract class AbstractReformatFilesStep(parent: NewProjectWizardStep) : AbstractLongRunningStep(parent) { override val description - get() = MCDevBundle.message("creator.step.reformat.description") + get() = MCDevBundle("creator.step.reformat.description") private val filesToReformat = mutableListOf() Index: src/main/kotlin/creator/step/LicenseStep.kt =================================================================== --- src/main/kotlin/creator/step/LicenseStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/step/LicenseStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -38,7 +38,7 @@ override fun setupUI(builder: Panel) { with(builder) { - row(MCDevBundle.message("creator.ui.license.label")) { + row(MCDevBundle("creator.ui.license.label")) { comboBox(License.values().toList()) .bindItem(licenseProperty.transform({ License.byId(it) ?: License.ALL_RIGHTS_RESERVED }) { it.id }) } Index: src/main/kotlin/creator/step/MainClassStep.kt =================================================================== --- src/main/kotlin/creator/step/MainClassStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/step/MainClassStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -74,7 +74,7 @@ override fun setupUI(builder: Panel) { with(builder) { - row(MCDevBundle.message("creator.ui.main_class.label")) { + row(MCDevBundle("creator.ui.main_class.label")) { textField() .columns(COLUMNS_LARGE) .bindText(classNameProperty) Index: src/main/kotlin/creator/step/McVersionStep.kt =================================================================== --- src/main/kotlin/creator/step/McVersionStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/step/McVersionStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -36,7 +36,7 @@ versions: List, ) : AbstractSelectVersionStep(parent, versions) { override val label - get() = MCDevBundle.message("creator.ui.mc_version.label") + get() = MCDevBundle("creator.ui.mc_version.label") override fun setupUI(builder: Panel) { super.setupUI(builder) Index: src/main/kotlin/creator/step/ModNameStep.kt =================================================================== --- src/main/kotlin/creator/step/ModNameStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/step/ModNameStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -70,10 +70,10 @@ class ModNameStep(parent: NewProjectWizardStep) : AbstractModNameStep(parent) { override val label - get() = MCDevBundle.message("creator.ui.mod_name.label") + get() = MCDevBundle("creator.ui.mod_name.label") } class PluginNameStep(parent: NewProjectWizardStep) : AbstractModNameStep(parent) { override val label - get() = MCDevBundle.message("creator.ui.plugin_name.label") + get() = MCDevBundle("creator.ui.plugin_name.label") } Index: src/main/kotlin/creator/step/OptionalSteps.kt =================================================================== --- src/main/kotlin/creator/step/OptionalSteps.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/step/OptionalSteps.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -92,7 +92,7 @@ class DescriptionStep(parent: NewProjectWizardStep) : AbstractOptionalStringStep(parent) { override val label - get() = MCDevBundle.message("creator.ui.description.label") + get() = MCDevBundle("creator.ui.description.label") override fun setupProject(project: Project) { data.putUserData(KEY, value) @@ -105,7 +105,7 @@ class AuthorsStep(parent: NewProjectWizardStep) : AbstractOptionalStringStep(parent) { override val label - get() = MCDevBundle.message("creator.ui.authors.label") + get() = MCDevBundle("creator.ui.authors.label") override val bindToStorage = true override fun setupProject(project: Project) { @@ -130,7 +130,7 @@ class WebsiteStep(parent: NewProjectWizardStep) : AbstractOptionalStringStep(parent) { override val label - get() = MCDevBundle.message("creator.ui.website.label") + get() = MCDevBundle("creator.ui.website.label") override val bindToStorage = true override fun setupProject(project: Project) { @@ -144,7 +144,7 @@ class RepositoryStep(parent: NewProjectWizardStep) : AbstractOptionalStringBasedOnProjectNameStep(parent) { override val label - get() = MCDevBundle.message("creator.ui.repository.label") + get() = MCDevBundle("creator.ui.repository.label") init { if (format.isEmpty()) { @@ -163,7 +163,7 @@ class IssueTrackerStep(parent: NewProjectWizardStep) : AbstractOptionalStringBasedOnProjectNameStep(parent) { override val label: String - get() = MCDevBundle.message("creator.ui.issue_tracker.label") + get() = MCDevBundle("creator.ui.issue_tracker.label") init { if (format.isEmpty()) { @@ -182,7 +182,7 @@ class UpdateUrlStep(parent: NewProjectWizardStep) : AbstractOptionalStringStep(parent) { override val label - get() = MCDevBundle.message("creator.ui.update_url.label") + get() = MCDevBundle("creator.ui.update_url.label") override fun setupProject(project: Project) { data.putUserData(KEY, value) @@ -195,7 +195,7 @@ class DependStep(parent: NewProjectWizardStep) : AbstractOptionalStringStep(parent) { override val label - get() = MCDevBundle.message("creator.ui.depend.label") + get() = MCDevBundle("creator.ui.depend.label") override fun setupProject(project: Project) { data.putUserData(KEY, AuthorsStep.parseAuthors(value)) @@ -208,7 +208,7 @@ class SoftDependStep(parent: NewProjectWizardStep) : AbstractOptionalStringStep(parent) { override val label - get() = MCDevBundle.message("creator.ui.soft_depend.label") + get() = MCDevBundle("creator.ui.soft_depend.label") override fun setupProject(project: Project) { data.putUserData(KEY, AuthorsStep.parseAuthors(value)) Index: src/main/kotlin/creator/step/TemplateOutdatedStep.kt =================================================================== --- src/main/kotlin/creator/step/TemplateOutdatedStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/step/TemplateOutdatedStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -40,7 +40,7 @@ "&plugin-version=${PluginUtil.pluginVersion.urlEncode()}" + "&intellij-version=${ApplicationInfo.getInstance().build.asString().urlEncode()}" + "&operating-system=${SystemInfoRt.OS_NAME.urlEncode()}" - text(MCDevBundle.message("creator.ui.outdated.message", issueUrl)) + text(MCDevBundle("creator.ui.outdated.message", issueUrl)) } } } Index: src/main/kotlin/creator/step/UseMixinsStep.kt =================================================================== --- src/main/kotlin/creator/step/UseMixinsStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/step/UseMixinsStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -36,7 +36,7 @@ override fun setupUI(builder: Panel) { with(builder) { - row(MCDevBundle.message("creator.ui.mixins.label")) { + row(MCDevBundle("creator.ui.mixins.label")) { checkBox("") .bindSelected(useMixinsProperty) } Index: src/main/kotlin/creator/step/WaitForSmartModeStep.kt =================================================================== --- src/main/kotlin/creator/step/WaitForSmartModeStep.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/creator/step/WaitForSmartModeStep.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -32,7 +32,7 @@ */ class WaitForSmartModeStep(parent: NewProjectWizardStep) : AbstractLongRunningStep(parent) { override val description - get() = MCDevBundle.message("creator.step.wait_for_smart.description") + get() = MCDevBundle("creator.step.wait_for_smart.description") override fun perform(project: Project) { DumbService.getInstance(project).waitForSmartMode() Index: src/main/kotlin/errorreporter/AnonymousFeedback.kt =================================================================== --- src/main/kotlin/errorreporter/AnonymousFeedback.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/errorreporter/AnonymousFeedback.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.errorreporter +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.update.PluginUtil import com.demonwav.mcdev.util.HttpConnectionFactory import com.demonwav.mcdev.util.fromJson @@ -39,8 +40,8 @@ data class FeedbackData(val url: String, val token: Int, val isDuplicate: Boolean) - private const val authedUrl = "https://www.denwav.dev/errorReport" - private const val baseUrl = "https://api.github.com/repos/minecraft-dev/mcdev-error-report/issues" + private const val AUTHED_URL = "https://www.denwav.dev/errorReport" + private const val BASE_URL = "https://api.github.com/repos/minecraft-dev/mcdev-error-report/issues" fun sendFeedback( factory: HttpConnectionFactory, @@ -142,7 +143,7 @@ } private fun sendFeedback(factory: HttpConnectionFactory, payload: ByteArray): Pair { - val connection = getConnection(factory, authedUrl) + val connection = getConnection(factory, AUTHED_URL) connection.connect() val json = executeCall(connection, payload) return json["html_url"] as String to (json["number"] as Double).toInt() @@ -155,8 +156,8 @@ return connection } - private const val openIssueUrl = "$baseUrl?state=open&creator=minecraft-dev-autoreporter&per_page=100" - private const val closedIssueUrl = "$baseUrl?state=closed&creator=minecraft-dev-autoreporter&per_page=100" + private const val openIssueUrl = "$BASE_URL?state=open&creator=minecraft-dev-autoreporter&per_page=100" + private const val closedIssueUrl = "$BASE_URL?state=closed&creator=minecraft-dev-autoreporter&per_page=100" private const val packagePrefix = "\tat com.demonwav.mcdev" @@ -298,11 +299,11 @@ if (index == -1) { return null } - return authedUrl + url.substring(index) + return AUTHED_URL + url.substring(index) } private fun sendCommentOnDuplicateIssue(id: Int, factory: HttpConnectionFactory, payload: ByteArray): String { - val commentUrl = "$authedUrl/$id/comments" + val commentUrl = "$AUTHED_URL/$id/comments" val connection = getConnection(factory, commentUrl) val json = executeCall(connection, payload) return json["html_url"] as String @@ -315,7 +316,7 @@ val responseCode = connection.responseCode if (responseCode != HttpStatus.SC_CREATED) { - throw RuntimeException("Expected HTTP_CREATED (201), obtained $responseCode instead.") + throw RuntimeException(MCDevBundle("error_reporter.submit.failure", responseCode)) } val contentEncoding = connection.contentEncoding ?: "UTF-8" Index: src/main/kotlin/errorreporter/ErrorData.kt =================================================================== --- src/main/kotlin/errorreporter/ErrorData.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/errorreporter/ErrorData.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -28,7 +28,7 @@ // It's easier to just re-use the code that we already were using, rather than changing to a map like // Jetbrains said to do in the deprecation message -class ErrorData(var throwable: Throwable?, val lastAction: String?) { +class ErrorData(var throwable: Throwable?, private val lastAction: String?) { var message: String? = null get() = field ?: throwable?.message Index: src/main/kotlin/errorreporter/ErrorReporter.kt =================================================================== --- src/main/kotlin/errorreporter/ErrorReporter.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/errorreporter/ErrorReporter.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,8 +20,8 @@ package com.demonwav.mcdev.errorreporter +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.update.PluginUtil -import com.intellij.diagnostic.DiagnosticBundle import com.intellij.diagnostic.LogMessage import com.intellij.ide.DataManager import com.intellij.ide.plugins.PluginManagerCore @@ -45,7 +45,7 @@ "Key com.demonwav.mcdev.translations.TranslationFoldingSettings duplicated", "Inspection #EntityConstructor has no description", ) - override fun getReportActionText() = "Report to Minecraft Dev GitHub Issue Tracker" + override fun getReportActionText() = MCDevBundle("error_reporter.submit.action") override fun submit( events: Array, @@ -59,7 +59,7 @@ val event = events[0] val errorMessage = event.throwableText if (errorMessage.isNotBlank() && ignoredErrorMessages.any(errorMessage::contains)) { - val task = object : Task.Backgroundable(project, "Ignored error") { + val task = object : Task.Backgroundable(project, MCDevBundle("error_reporter.submit.ignored")) { override fun run(indicator: ProgressIndicator) { consumer.consume(SubmittedReportInfo(null, null, SubmittedReportInfo.SubmissionStatus.DUPLICATE)) } @@ -105,18 +105,18 @@ } val message = if (!isDuplicate) { - "Created Issue #$token successfully." + "${MCDevBundle("error_reporter.report.created", token)}" } else { - "Commented on existing Issue #$token successfully." + "${MCDevBundle("error_reporter.report.commented", token)}" } val actionText = if (!isDuplicate) { - "View issue" + MCDevBundle("error_reporter.report.created.action") } else { - "View comment" + MCDevBundle("error_reporter.report.commented.action") } NotificationGroupManager.getInstance().getNotificationGroup("Error Report").createNotification( - DiagnosticBundle.message("error.report.title"), + MCDevBundle("error_reporter.report.title"), message, NotificationType.INFORMATION, ).addAction(BrowseNotificationAction(actionText, htmlUrl)).setImportant(false).notify(project) @@ -125,11 +125,11 @@ consumer.consume(reportInfo) }, { e -> - val message = "Error Submitting Issue: ${e.message}." - val actionText = "Open an issue on the GitHub issue tracker" + val message = "${MCDevBundle("error_reporter.report.error", e.message)}" + val actionText = MCDevBundle("error_reporter.report.error.action") val userUrl = "https://github.com/minecraft-dev/MinecraftDev/issues" NotificationGroupManager.getInstance().getNotificationGroup("Error Report").createNotification( - DiagnosticBundle.message("error.report.title"), + MCDevBundle("error_reporter.report.title"), message, NotificationType.ERROR, ).addAction(BrowseNotificationAction(actionText, userUrl)).setImportant(false).notify(project) Index: src/main/kotlin/facet/MinecraftFacetEditorTab.kt =================================================================== --- src/main/kotlin/facet/MinecraftFacetEditorTab.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/facet/MinecraftFacetEditorTab.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.facet +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.asset.PlatformAssets import com.demonwav.mcdev.platform.PlatformType import com.intellij.facet.ui.FacetEditorTab @@ -197,7 +198,7 @@ return panel } - override fun getDisplayName() = "Minecraft Module Settings" + override fun getDisplayName() = MCDevBundle("facet.editor.name") override fun isModified(): Boolean { var modified = false Index: src/main/kotlin/facet/MinecraftFacetEditorTabV2.kt =================================================================== --- src/main/kotlin/facet/MinecraftFacetEditorTabV2.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/facet/MinecraftFacetEditorTabV2.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.facet +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.asset.PlatformAssets import com.demonwav.mcdev.platform.PlatformType import com.intellij.facet.ui.FacetEditorTab @@ -153,7 +154,7 @@ } } - override fun getDisplayName() = "Minecraft Module Settings" + override fun getDisplayName() = MCDevBundle("facet.editor.name") override fun isModified(): Boolean { var modified = false Index: src/main/kotlin/insight/ColorLineMarkerProvider.kt =================================================================== --- src/main/kotlin/insight/ColorLineMarkerProvider.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/insight/ColorLineMarkerProvider.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -21,6 +21,7 @@ package com.demonwav.mcdev.insight import com.demonwav.mcdev.MinecraftSettings +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.util.runCatchingKtIdeaExceptions import com.intellij.codeInsight.daemon.GutterIconNavigationHandler import com.intellij.codeInsight.daemon.LineMarkerInfo @@ -57,7 +58,7 @@ identifier.findColor { map, chosen -> ColorInfo(element, chosen.value, map, chosen.key, identifier) } } if (info != null) { - NavigateAction.setNavigateAction(info, "Change Color", null) + NavigateAction.setNavigateAction(info, MCDevBundle("generate.color.change_action"), null) } return info @@ -143,11 +144,12 @@ // implement it yet. It is better to not display the color chooser at all than deceiving users after // after they chose a color HintManager.getInstance() - .showErrorHint(editor, "Can't change colors in " + psiElement.language.displayName) + .showErrorHint(editor, MCDevBundle("generate.color.change_error", psiElement.language.displayName)) return@handler } - val c = ColorChooser.chooseColor(psiElement.project, editor.component, "Choose Color", color, false) + val actionText = MCDevBundle("generate.color.choose_action") + val c = ColorChooser.chooseColor(psiElement.project, editor.component, actionText, color, false) ?: return@handler when (workElement) { is ULiteralExpression -> { @@ -185,7 +187,7 @@ val pair = findColor(element) ?: return null val info = CommonColorInfo(element, pair.first, pair.second) - NavigateAction.setNavigateAction(info, "Change color", null) + NavigateAction.setNavigateAction(info, MCDevBundle("generate.color.change_action"), null) return info } Index: src/main/kotlin/insight/ColorPicker.kt =================================================================== --- src/main/kotlin/insight/ColorPicker.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/insight/ColorPicker.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,12 +20,13 @@ package com.demonwav.mcdev.insight +import com.demonwav.mcdev.asset.MCDevBundle import com.intellij.openapi.ui.DialogWrapper import com.intellij.util.ui.ColorIcon +import com.intellij.util.ui.JBUI import java.awt.Color import java.awt.GridBagConstraints import java.awt.GridBagLayout -import java.awt.Insets import java.awt.event.MouseAdapter import java.awt.event.MouseEvent import javax.swing.JComponent @@ -79,7 +80,7 @@ val constraints = GridBagConstraints() constraints.gridy = row constraints.fill = GridBagConstraints.NONE - constraints.insets = Insets(10, 10, 10, 10) + constraints.insets = JBUI.insets(10) panel.add(label, constraints) } @@ -89,7 +90,7 @@ DialogWrapper(parent, false) { init { - title = "Choose Color" + title = MCDevBundle("generate.color.choose_action") isResizable = true init() Index: src/main/kotlin/insight/ListenerLineMarkerProvider.kt =================================================================== --- src/main/kotlin/insight/ListenerLineMarkerProvider.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/insight/ListenerLineMarkerProvider.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -22,6 +22,7 @@ import com.demonwav.mcdev.MinecraftSettings import com.demonwav.mcdev.asset.GeneralAssets +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.util.runCatchingKtIdeaExceptions import com.intellij.codeInsight.daemon.GutterIconNavigationHandler import com.intellij.codeInsight.daemon.LineMarkerInfo @@ -82,7 +83,7 @@ } } - override fun getName() = "Event Listener line marker" + override fun getName() = MCDevBundle("insight.event_listener.marker") override fun getIcon() = GeneralAssets.LISTENER private class EventLineMarkerInfo( @@ -94,10 +95,10 @@ element, range, icon, - Function { "Go to Event declaration" }, + Function { MCDevBundle("insight.event_listener.marker.goto") }, handler, GutterIconRenderer.Alignment.RIGHT, - { "event listener indicator" }, + { MCDevBundle("insight.event_listener.marker.accessible_name") }, ) { override fun canMergeWith(info: MergeableLineMarkerInfo<*>): Boolean { @@ -113,7 +114,7 @@ override fun getCommonIcon(infos: List>) = myIcon!! override fun getCommonTooltip(infos: List>): Function = - Function { "Multiple method overrides" } + Function { MCDevBundle("insight.event_listener.marker.multiple") } override fun getElementPresentation(element: PsiElement): String { val parent = element.parent Index: src/main/kotlin/insight/PluginLineMarkerProvider.kt =================================================================== --- src/main/kotlin/insight/PluginLineMarkerProvider.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/insight/PluginLineMarkerProvider.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -21,17 +21,21 @@ package com.demonwav.mcdev.insight import com.demonwav.mcdev.asset.GeneralAssets +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.facet.MinecraftFacet +import com.demonwav.mcdev.platform.PlatformType import com.intellij.codeInsight.daemon.LineMarkerInfo import com.intellij.codeInsight.daemon.LineMarkerProviderDescriptor import com.intellij.openapi.editor.markup.GutterIconRenderer import com.intellij.openapi.module.ModuleUtilCore import com.intellij.psi.PsiElement import com.intellij.util.FunctionUtil +import com.intellij.util.ThreeState +import com.intellij.util.ui.accessibility.ScreenReader class PluginLineMarkerProvider : LineMarkerProviderDescriptor() { - override fun getName() = "Minecraft Plugin line marker" + override fun getName() = MCDevBundle("insight.plugin.marker") override fun getLineMarkerInfo(element: PsiElement): LineMarkerInfo<*>? { if (!element.isValid) { @@ -46,6 +50,43 @@ return null } + val a11yText = if (!ScreenReader.isActive()) { + // if screenreader isn't active, don't need to spend the extra time building the string + val name = MCDevBundle("insight.plugin.marker.accessible_name_plugin") + MCDevBundle("insight.plugin.marker.accessible_name", name) + } else { + val isMod = instance.modules.asSequence() + .filter { it.shouldShowPluginIcon(element) } + .map { + when (it.type) { + PlatformType.BUKKIT -> ThreeState.NO + PlatformType.SPIGOT -> ThreeState.NO + PlatformType.PAPER -> ThreeState.NO + PlatformType.ARCHITECTURY -> ThreeState.YES + PlatformType.FORGE -> ThreeState.YES + PlatformType.FABRIC -> ThreeState.YES + PlatformType.SPONGE -> ThreeState.NO + PlatformType.BUNGEECORD -> ThreeState.NO + PlatformType.WATERFALL -> ThreeState.NO + PlatformType.VELOCITY -> ThreeState.NO + PlatformType.MIXIN -> ThreeState.YES + PlatformType.MCP -> ThreeState.YES + PlatformType.ADVENTURE -> ThreeState.UNSURE + } + } + .filterNot { it == ThreeState.UNSURE } + .distinct() + .let { ThreeState.mostPositive(it.toList()) } + + val name = when (isMod) { + ThreeState.YES -> MCDevBundle("insight.plugin.marker.accessible_name_mod") + ThreeState.NO -> MCDevBundle("insight.plugin.marker.accessible_name_plugin") + ThreeState.UNSURE -> MCDevBundle("insight.plugin.marker.accessible_name_unsure") + } + + MCDevBundle("insight.plugin.marker.accessible_name", name) + } + @Suppress("MoveLambdaOutsideParentheses") return LineMarkerInfo( element, @@ -54,7 +95,7 @@ FunctionUtil.nullConstant(), null, GutterIconRenderer.Alignment.RIGHT, - { "minecraft plugin entry point indicator" }, + { a11yText }, ) } } Index: src/main/kotlin/insight/generation/GenerateEventListenerHandler.kt =================================================================== --- src/main/kotlin/insight/generation/GenerateEventListenerHandler.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/insight/generation/GenerateEventListenerHandler.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -48,7 +48,7 @@ * Note that this is a psuedo generator as it relies on a wizard and the * [.cleanup] to complete */ -class GenerateEventListenerHandler : GenerateMembersHandlerBase(MCDevBundle.message("generate.event_listener.title")) { +class GenerateEventListenerHandler : GenerateMembersHandlerBase(MCDevBundle("generate.event_listener.title")) { private data class GenerateData( var editor: Editor, Index: src/main/kotlin/insight/generation/MinecraftClassCreateAction.kt =================================================================== --- src/main/kotlin/insight/generation/MinecraftClassCreateAction.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/insight/generation/MinecraftClassCreateAction.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -21,6 +21,7 @@ package com.demonwav.mcdev.insight.generation import com.demonwav.mcdev.asset.GeneralAssets +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.asset.PlatformAssets import com.demonwav.mcdev.facet.MinecraftFacet import com.demonwav.mcdev.platform.fabric.FabricModuleType @@ -51,7 +52,7 @@ class MinecraftClassCreateAction : CreateTemplateInPackageAction( CAPTION, - "Class generation for modders", + MCDevBundle("generate.class.description"), GeneralAssets.MC_TEMPLATE, JavaModuleSourceRootTypes.SOURCES, ), @@ -152,6 +153,7 @@ } private companion object { - private const val CAPTION = "Minecraft Class" + private val CAPTION + get() = MCDevBundle("generate.class.caption") } } Index: src/main/kotlin/insight/generation/ui/EventGenerationDialog.kt =================================================================== --- src/main/kotlin/insight/generation/ui/EventGenerationDialog.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/insight/generation/ui/EventGenerationDialog.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -39,7 +39,7 @@ private set init { - title = MCDevBundle.message("generate.event_listener.settings") + title = MCDevBundle("generate.event_listener.settings") isOKActionEnabled = true setValidationDelay(0) Index: src/main/kotlin/inspection/IsCancelled.kt =================================================================== --- src/main/kotlin/inspection/IsCancelled.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/inspection/IsCancelled.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.inspection +import com.demonwav.mcdev.asset.MCDevBundle import com.intellij.codeInspection.ProblemDescriptor import com.intellij.openapi.project.Project import com.siyeh.ig.InspectionGadgetsFix @@ -34,7 +35,7 @@ this.buildFix = object : InspectionGadgetsFix() { override fun doFix(project: Project, descriptor: ProblemDescriptor) = fix(descriptor) override fun getName() = "Simplify" - override fun getFamilyName() = "Useless isCancelled check" + override fun getFamilyName() = MCDevBundle("inspection.is_cancelled.name") } } } Index: src/main/kotlin/inspection/IsCancelledInspection.kt =================================================================== --- src/main/kotlin/inspection/IsCancelledInspection.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/inspection/IsCancelledInspection.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.inspection +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.facet.MinecraftFacet import com.demonwav.mcdev.util.mapFirstNotNull import com.intellij.openapi.module.ModuleUtilCore @@ -31,9 +32,9 @@ class IsCancelledInspection : BaseInspection() { @Nls - override fun getDisplayName() = "Useless event isCancelled check" + override fun getDisplayName() = MCDevBundle("inspection.is_cancelled.name") - override fun getStaticDescription(): String = "Reports useless event cancellation checks" + override fun getStaticDescription(): String = MCDevBundle("inspection.is_cancelled.description") override fun buildErrorString(vararg infos: Any): String { val useless = infos[0] as IsCancelled Index: src/main/kotlin/inspection/PlatformAnnotationEntryPoint.kt =================================================================== --- src/main/kotlin/inspection/PlatformAnnotationEntryPoint.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/inspection/PlatformAnnotationEntryPoint.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.inspection +import com.demonwav.mcdev.asset.MCDevBundle import com.intellij.codeInspection.reference.EntryPoint import com.intellij.codeInspection.reference.RefElement import com.intellij.openapi.util.InvalidDataException @@ -28,7 +29,7 @@ import org.jdom.Element class PlatformAnnotationEntryPoint : EntryPoint() { - override fun getDisplayName() = "Minecraft Entry Point" + override fun getDisplayName() = MCDevBundle("inspection.entry_point.name") override fun isEntryPoint(refElement: RefElement, psiElement: PsiElement) = false override fun isEntryPoint(psiElement: PsiElement) = false override fun isSelected() = false Index: src/main/kotlin/inspection/WrongEntityDataParameterClassInspection.kt =================================================================== --- src/main/kotlin/inspection/WrongEntityDataParameterClassInspection.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/inspection/WrongEntityDataParameterClassInspection.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.inspection +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.util.findContainingClass import com.demonwav.mcdev.util.fullQualifiedName import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool @@ -39,9 +40,7 @@ class WrongEntityDataParameterClassInspection : AbstractBaseJavaLocalInspectionTool() { - override fun getStaticDescription() = "Reports when the class passed to an entity data parameter definition is " + - "not the same as the containing entity class" - + override fun getStaticDescription() = MCDevBundle("inspection.entity_data_param.description") override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor = Visitor(holder) class Visitor(private val holder: ProblemsHolder) : JavaElementVisitor() { @@ -66,7 +65,7 @@ if (!containingClass.manager.areElementsEquivalent(containingClass, firstParameterGenericsClass)) { holder.registerProblem( expression, - "Entity class does not match this entity class", + MCDevBundle("inspection.entity_data_param.message"), QuickFix(firstParameter), ) } @@ -74,7 +73,7 @@ } private class QuickFix(firstParameter: PsiExpression) : LocalQuickFixOnPsiElement(firstParameter) { - override fun getText() = "Replace other entity class with this entity class" + override fun getText() = MCDevBundle("inspection.entity_data_param.fix") override fun invoke(project: Project, file: PsiFile, startElement: PsiElement, endElement: PsiElement) { val factory = JavaPsiFacade.getElementFactory(project) Index: src/main/kotlin/nbt/MalformedNbtFileException.kt =================================================================== --- src/main/kotlin/nbt/MalformedNbtFileException.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/MalformedNbtFileException.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,9 +20,14 @@ package com.demonwav.mcdev.nbt +import org.jetbrains.annotations.Nls +import org.jetbrains.annotations.Nls.Capitalization.Sentence + open class MalformedNbtFileException : Exception { - constructor(message: String) : super(message) - constructor(message: String, cause: Throwable) : super(message, cause) + constructor(@Nls(capitalization = Sentence) message: String) : super(message) + constructor(@Nls(capitalization = Sentence) message: String, cause: Throwable) : super(message, cause) } -class NbtFileParseTimeoutException(message: String) : MalformedNbtFileException(message) +class NbtFileParseTimeoutException( + @Nls(capitalization = Sentence) message: String +) : MalformedNbtFileException(message) Index: src/main/kotlin/nbt/Nbt.kt =================================================================== --- src/main/kotlin/nbt/Nbt.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/Nbt.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.nbt +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.nbt.tags.NbtTag import com.demonwav.mcdev.nbt.tags.NbtTypeId import com.demonwav.mcdev.nbt.tags.RootCompound @@ -64,10 +65,10 @@ stream.use { val tagIdByte = stream.readByte() val tagId = NbtTypeId.getById(tagIdByte) - ?: throw MalformedNbtFileException("Unexpected tag id found: $tagIdByte") + ?: throw MalformedNbtFileException(MCDevBundle("nbt.lang.errors.wrong_tag_id", tagIdByte)) if (tagId != NbtTypeId.COMPOUND) { - throw MalformedNbtFileException("Root tag in NBT file is not a compound.") + throw MalformedNbtFileException(MCDevBundle("nbt.lang.errors.invalid_root")) } val start = System.currentTimeMillis() @@ -78,7 +79,7 @@ if (e is MalformedNbtFileException) { throw e } else { - throw MalformedNbtFileException("Error reading file", e) + throw MalformedNbtFileException(MCDevBundle("nbt.lang.errors.reading"), e) } } } @@ -88,7 +89,9 @@ var tagIdByte = this.readByte() var tagId = - NbtTypeId.getById(tagIdByte) ?: throw MalformedNbtFileException("Unexpected tag id found: $tagIdByte") + NbtTypeId.getById(tagIdByte) ?: run { + throw MalformedNbtFileException(MCDevBundle("nbt.lang.errors.wrong_tag_id", tagIdByte)) + } while (tagId != NbtTypeId.END) { val name = this.readUTF() @@ -96,8 +99,10 @@ tagIdByte = this.readByte() tagId = - NbtTypeId.getById(tagIdByte) ?: throw MalformedNbtFileException("Unexpected tag id found: $tagIdByte") + NbtTypeId.getById(tagIdByte) ?: run { + throw MalformedNbtFileException(MCDevBundle("nbt.lang.errors.wrong_tag_id", tagIdByte)) - } + } + } return@checkTimeout TagCompound(tagMap) } @@ -126,7 +131,9 @@ private fun DataInputStream.readListTag(start: Long, timeout: Long) = checkTimeout(start, timeout) { val tagIdByte = this.readByte() val tagId = - NbtTypeId.getById(tagIdByte) ?: throw MalformedNbtFileException("Unexpected tag id found: $tagIdByte") + NbtTypeId.getById(tagIdByte) ?: run { + throw MalformedNbtFileException(MCDevBundle("nbt.lang.errors.wrong_tag_id", tagIdByte)) + } val length = this.readInt() if (length <= 0) { @@ -190,7 +197,7 @@ val took = now - start if (took > timeout) { - throw NbtFileParseTimeoutException("NBT parse timeout exceeded - Parse time: $took, Timeout: $timeout.") + throw NbtFileParseTimeoutException(MCDevBundle("nbt.lang.errors.parse_timeout", took, timeout)) } return action() Index: src/main/kotlin/nbt/NbtVirtualFile.kt =================================================================== --- src/main/kotlin/nbt/NbtVirtualFile.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/NbtVirtualFile.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.nbt +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.nbt.editor.CompressionSelection import com.demonwav.mcdev.nbt.editor.NbtToolbar import com.demonwav.mcdev.nbt.lang.NbttFile @@ -62,7 +63,7 @@ tempCompressed = isCompressed tempParseSuccessful = true } catch (e: MalformedNbtFileException) { - text = "Malformed NBT file:\n${e.message}" + text = MCDevBundle("nbt.lang.errors.wrapped_error_message", e.message) tempCompressed = false tempParseSuccessful = false } @@ -92,9 +93,8 @@ if (nbttFile == null) { Notification( "NBT Save Error", - "Error saving NBT file", - "The file is not recognised as a NBTT file. This might be caused by wrong file type associations," + - " or the file could be too large.", + MCDevBundle("nbt.file.save_notify.file_type_error.title"), + MCDevBundle("nbt.file.save_notify.file_type_error.content"), NotificationType.WARNING, ).notify(project) return@runReadActionAsync @@ -105,8 +105,8 @@ if (rootTag == null) { Notification( "NBT Save Error", - "Error saving NBT file", - "Due to errors in the text representation, ${backingFile.name} could not be saved.", + MCDevBundle("nbt.file.save_notify.parse_error.title"), + MCDevBundle("nbt.file.save_notify.parse_error.content", backingFile.name), NotificationType.WARNING, ).notify(project) return@runReadActionAsync @@ -126,8 +126,8 @@ Notification( "NBT Save Success", - "Saved NBT file successfully", - "${backingFile.name} was saved successfully.", + MCDevBundle("nbt.file.save_notify.success.title"), + MCDevBundle("nbt.file.save_notify.success.content", backingFile.name), NotificationType.INFORMATION, ).notify(project) } Index: src/main/kotlin/nbt/editor/CompressionSelection.kt =================================================================== --- src/main/kotlin/nbt/editor/CompressionSelection.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/editor/CompressionSelection.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,10 +20,12 @@ package com.demonwav.mcdev.nbt.editor -enum class CompressionSelection(private val selectionName: String) { - GZIP("GZipped"), - UNCOMPRESSED("Uncompressed"), +import com.demonwav.mcdev.asset.MCDevBundle + +enum class CompressionSelection(private val selectionNameFunc: () -> String) { + GZIP({ MCDevBundle("nbt.compression.gzip") }), + UNCOMPRESSED({ MCDevBundle("nbt.compression.uncompressed") }), ; - override fun toString() = selectionName + override fun toString(): String = selectionNameFunc() } Index: src/main/kotlin/nbt/editor/NbtToolbar.form =================================================================== --- src/main/kotlin/nbt/editor/NbtToolbar.form (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/editor/NbtToolbar.form (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -8,7 +8,7 @@ - + Index: src/main/kotlin/nbt/editor/NbtToolbar.kt =================================================================== --- src/main/kotlin/nbt/editor/NbtToolbar.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/editor/NbtToolbar.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,20 +20,26 @@ package com.demonwav.mcdev.nbt.editor +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.nbt.NbtVirtualFile import com.demonwav.mcdev.util.runWriteTaskLater import javax.swing.JButton import javax.swing.JComboBox +import javax.swing.JLabel import javax.swing.JPanel class NbtToolbar(nbtFile: NbtVirtualFile) { lateinit var panel: JPanel + private lateinit var fileTypeLabel: JLabel private lateinit var compressionBox: JComboBox lateinit var saveButton: JButton private var lastSelection: CompressionSelection init { + fileTypeLabel.text = MCDevBundle("nbt.compression.file_type.label") + saveButton.text = MCDevBundle("nbt.compression.save.button") + compressionBox.addItem(CompressionSelection.GZIP) compressionBox.addItem(CompressionSelection.UNCOMPRESSED) compressionBox.selectedItem = Index: src/main/kotlin/nbt/filetype/NbtFileType.kt =================================================================== --- src/main/kotlin/nbt/filetype/NbtFileType.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/filetype/NbtFileType.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.nbt.filetype +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.asset.PlatformAssets import com.intellij.openapi.fileTypes.FileType import com.intellij.openapi.vfs.VirtualFile @@ -28,8 +29,8 @@ override fun getDefaultExtension() = "nbt" override fun getIcon() = PlatformAssets.MINECRAFT_ICON override fun getCharset(file: VirtualFile, content: ByteArray): String? = null - override fun getName() = "NBT" - override fun getDescription() = "NBT" + override fun getName() = MCDevBundle("nbt.file_type.name") + override fun getDescription() = MCDevBundle("nbt.file_type.description") override fun isBinary() = true override fun isReadOnly() = false } Index: src/main/kotlin/nbt/lang/NbttFileType.kt =================================================================== --- src/main/kotlin/nbt/lang/NbttFileType.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/lang/NbttFileType.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.nbt.lang +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.asset.PlatformAssets import com.intellij.openapi.fileTypes.LanguageFileType @@ -27,5 +28,5 @@ override fun getIcon() = PlatformAssets.MINECRAFT_ICON override fun getName() = "NBTT" override fun getDefaultExtension() = "nbtt" - override fun getDescription() = "NBT text representation (don't use this one)" + override fun getDescription() = MCDevBundle("nbt.lang.description") } Index: src/main/kotlin/nbt/lang/colors/NbttAnnotator.kt =================================================================== --- src/main/kotlin/nbt/lang/colors/NbttAnnotator.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/lang/colors/NbttAnnotator.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.nbt.lang.colors +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.nbt.lang.gen.psi.NbttByte import com.demonwav.mcdev.nbt.lang.gen.psi.NbttDouble import com.demonwav.mcdev.nbt.lang.gen.psi.NbttFloat @@ -29,7 +30,7 @@ import com.demonwav.mcdev.nbt.lang.gen.psi.NbttTagName import com.intellij.lang.annotation.AnnotationHolder import com.intellij.lang.annotation.Annotator -import com.intellij.lang.annotation.HighlightSeverity +import com.intellij.lang.annotation.HighlightSeverity.INFORMATION import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement @@ -51,7 +52,7 @@ NbttSyntaxHighlighter.STRING_NAME } - holder.newSilentAnnotation(HighlightSeverity.INFORMATION) + holder.newSilentAnnotation(INFORMATION) .range(element) .textAttributes(attributes) .create() @@ -70,7 +71,7 @@ // won't even let you escape them val range = TextRange(element.textRange.startOffset + index + 2, element.textRange.endOffset - 1) - holder.newAnnotation(HighlightSeverity.INFORMATION, "Material") + holder.newAnnotation(INFORMATION, MCDevBundle("nbt.lang.annotate.material")) .range(range) .textAttributes(NbttSyntaxHighlighter.MATERIAL) .create() @@ -79,11 +80,21 @@ private fun annotateTypes(element: PsiElement, holder: AnnotationHolder) { when (element) { - is NbttByte -> holder.newAnnotation(HighlightSeverity.INFORMATION, "Type: byte").range(element).create() - is NbttShort -> holder.newAnnotation(HighlightSeverity.INFORMATION, "Type: short").range(element).create() - is NbttLong -> holder.newAnnotation(HighlightSeverity.INFORMATION, "Type: long").range(element).create() - is NbttFloat -> holder.newAnnotation(HighlightSeverity.INFORMATION, "Type: float").range(element).create() - is NbttDouble -> holder.newAnnotation(HighlightSeverity.INFORMATION, "Type: double").range(element).create() + is NbttByte -> { + holder.newAnnotation(INFORMATION, MCDevBundle("nbt.lang.annotate.type_byte")).range(element).create() - } + } + is NbttShort -> { + holder.newAnnotation(INFORMATION, MCDevBundle("nbt.lang.annotate.type_short")).range(element).create() - } + } + is NbttLong -> { + holder.newAnnotation(INFORMATION, MCDevBundle("nbt.lang.annotate.type_long")).range(element).create() -} + } + is NbttFloat -> { + holder.newAnnotation(INFORMATION, MCDevBundle("nbt.lang.annotate.type_float")).range(element).create() + } + is NbttDouble -> { + holder.newAnnotation(INFORMATION, MCDevBundle("nbt.lang.annotate.type_double")).range(element).create() + } + } + } +} Index: src/main/kotlin/nbt/lang/colors/NbttColorSettingsPage.kt =================================================================== --- src/main/kotlin/nbt/lang/colors/NbttColorSettingsPage.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/lang/colors/NbttColorSettingsPage.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,7 +20,20 @@ package com.demonwav.mcdev.nbt.lang.colors +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.asset.PlatformAssets +import com.demonwav.mcdev.nbt.lang.colors.NbttSyntaxHighlighter.Companion.BYTE +import com.demonwav.mcdev.nbt.lang.colors.NbttSyntaxHighlighter.Companion.DOUBLE +import com.demonwav.mcdev.nbt.lang.colors.NbttSyntaxHighlighter.Companion.FLOAT +import com.demonwav.mcdev.nbt.lang.colors.NbttSyntaxHighlighter.Companion.INT +import com.demonwav.mcdev.nbt.lang.colors.NbttSyntaxHighlighter.Companion.KEYWORD +import com.demonwav.mcdev.nbt.lang.colors.NbttSyntaxHighlighter.Companion.LONG +import com.demonwav.mcdev.nbt.lang.colors.NbttSyntaxHighlighter.Companion.MATERIAL +import com.demonwav.mcdev.nbt.lang.colors.NbttSyntaxHighlighter.Companion.SHORT +import com.demonwav.mcdev.nbt.lang.colors.NbttSyntaxHighlighter.Companion.STRING +import com.demonwav.mcdev.nbt.lang.colors.NbttSyntaxHighlighter.Companion.STRING_NAME +import com.demonwav.mcdev.nbt.lang.colors.NbttSyntaxHighlighter.Companion.UNQUOTED_STRING +import com.demonwav.mcdev.nbt.lang.colors.NbttSyntaxHighlighter.Companion.UNQUOTED_STRING_NAME import com.intellij.openapi.options.colors.AttributesDescriptor import com.intellij.openapi.options.colors.ColorDescriptor import com.intellij.openapi.options.colors.ColorSettingsPage @@ -32,7 +45,7 @@ override fun getAdditionalHighlightingTagToDescriptorMap() = map override fun getAttributeDescriptors() = DESCRIPTORS override fun getColorDescriptors(): Array = ColorDescriptor.EMPTY_ARRAY - override fun getDisplayName() = "NBT Text" + override fun getDisplayName() = MCDevBundle("nbt.lang.display_name") override fun getDemoText() = """ "Level": { @@ -75,18 +88,21 @@ companion object { private val DESCRIPTORS = arrayOf( - AttributesDescriptor("Keyword", NbttSyntaxHighlighter.KEYWORD), - AttributesDescriptor("String", NbttSyntaxHighlighter.STRING), - AttributesDescriptor("Unquoted String", NbttSyntaxHighlighter.UNQUOTED_STRING), - AttributesDescriptor("Name", NbttSyntaxHighlighter.STRING_NAME), - AttributesDescriptor("Unquoted Name", NbttSyntaxHighlighter.UNQUOTED_STRING_NAME), - AttributesDescriptor("Byte", NbttSyntaxHighlighter.BYTE), - AttributesDescriptor("Short", NbttSyntaxHighlighter.SHORT), - AttributesDescriptor("Int", NbttSyntaxHighlighter.INT), - AttributesDescriptor("Long", NbttSyntaxHighlighter.LONG), - AttributesDescriptor("Float", NbttSyntaxHighlighter.FLOAT), - AttributesDescriptor("Double", NbttSyntaxHighlighter.DOUBLE), - AttributesDescriptor("Material", NbttSyntaxHighlighter.MATERIAL), + AttributesDescriptor(MCDevBundle("nbt.lang.highlighting.keyword.display_name"), KEYWORD), + AttributesDescriptor(MCDevBundle("nbt.lang.highlighting.string.display_name"), STRING), + AttributesDescriptor(MCDevBundle("nbt.lang.highlighting.unquoted_string.display_name"), UNQUOTED_STRING), + AttributesDescriptor(MCDevBundle("nbt.lang.highlighting.name.display_name"), STRING_NAME), + AttributesDescriptor( + MCDevBundle("nbt.lang.highlighting.unquoted_name.display_name"), + UNQUOTED_STRING_NAME + ), + AttributesDescriptor(MCDevBundle("nbt.lang.highlighting.byte.display_name"), BYTE), + AttributesDescriptor(MCDevBundle("nbt.lang.highlighting.short.display_name"), SHORT), + AttributesDescriptor(MCDevBundle("nbt.lang.highlighting.int.display_name"), INT), + AttributesDescriptor(MCDevBundle("nbt.lang.highlighting.long.display_name"), LONG), + AttributesDescriptor(MCDevBundle("nbt.lang.highlighting.float.display_name"), FLOAT), + AttributesDescriptor(MCDevBundle("nbt.lang.highlighting.double.display_name"), DOUBLE), + AttributesDescriptor(MCDevBundle("nbt.lang.highlighting.material.display_name"), MATERIAL), ) private val map = mapOf( Index: src/main/kotlin/nbt/lang/format/NbttCodeStyleSettingsProvider.kt =================================================================== --- src/main/kotlin/nbt/lang/format/NbttCodeStyleSettingsProvider.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/lang/format/NbttCodeStyleSettingsProvider.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.nbt.lang.format +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.nbt.lang.NbttLanguage import com.intellij.application.options.CodeStyleAbstractConfigurable import com.intellij.application.options.TabbedLanguageCodeStylePanel @@ -33,7 +34,7 @@ override fun getHelpTopic(): String? = null } - override fun getConfigurableDisplayName() = "NBT Text" + override fun getConfigurableDisplayName() = MCDevBundle("nbt.lang.display_name") override fun createCustomSettings(settings: CodeStyleSettings) = NbttCodeStyleSettings(settings) Index: src/main/kotlin/nbt/lang/format/NbttLanguageCodeStyleSettingsProvider.kt =================================================================== --- src/main/kotlin/nbt/lang/format/NbttLanguageCodeStyleSettingsProvider.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/lang/format/NbttLanguageCodeStyleSettingsProvider.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,7 +20,9 @@ package com.demonwav.mcdev.nbt.lang.format +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.nbt.lang.NbttLanguage +import com.intellij.CodeStyleBundle import com.intellij.application.options.IndentOptionsEditor import com.intellij.application.options.SmartIndentOptionsEditor import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable @@ -42,9 +44,9 @@ "Wrap list items", CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_BRACES, arrayOf( - "Do not wrap", - "Wrap as needed", - "Wrap always", + CodeStyleBundle.message("wrapping.do.not.wrap"), + CodeStyleBundle.message("wrapping.wrap.if.long"), + CodeStyleBundle.message("wrapping.wrap.always"), ), intArrayOf( CommonCodeStyleSettings.DO_NOT_WRAP, @@ -58,9 +60,9 @@ "Wrap array items", CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_BRACES, arrayOf( - "Do not wrap", - "Wrap as needed", - "Wrap always", + CodeStyleBundle.message("wrapping.do.not.wrap"), + CodeStyleBundle.message("wrapping.wrap.if.long"), + CodeStyleBundle.message("wrapping.wrap.always"), ), intArrayOf( CommonCodeStyleSettings.DO_NOT_WRAP, @@ -80,18 +82,20 @@ consumer.showCustomOption( NbttCodeStyleSettings::class.java, "SPACE_BEFORE_COLON", - "Space before colon", + MCDevBundle("nbt.lang.style.space_before_colon"), CodeStyleSettingsCustomizableOptions.getInstance().SPACES_AROUND_OPERATORS, ) consumer.showCustomOption( NbttCodeStyleSettings::class.java, "SPACE_AFTER_COLON", - "Space after colon", + MCDevBundle("nbt.lang.style.space_after_colon"), CodeStyleSettingsCustomizableOptions.getInstance().SPACES_AROUND_OPERATORS, ) - consumer.renameStandardOption("SPACE_WITHIN_BRACKETS", "List brackets") - consumer.renameStandardOption("SPACE_WITHIN_PARENTHESES", "Array parentheses") + val listBracket = MCDevBundle("nbt.lang.style.list_brackets") + consumer.renameStandardOption("SPACE_WITHIN_BRACKETS", listBracket) + val arrayParen = MCDevBundle("nbt.lang.style.array_parentheses") + consumer.renameStandardOption("SPACE_WITHIN_PARENTHESES", arrayParen) } else -> { Index: src/main/kotlin/nbt/lang/format/NbttParameterNameHints.kt =================================================================== --- src/main/kotlin/nbt/lang/format/NbttParameterNameHints.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/lang/format/NbttParameterNameHints.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.nbt.lang.format +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.nbt.lang.gen.psi.NbttByteArray import com.demonwav.mcdev.nbt.lang.gen.psi.NbttCompound import com.demonwav.mcdev.nbt.lang.gen.psi.NbttIntArray @@ -39,7 +40,7 @@ val size = element.getNamedTagList().size list.add( InlayInfo( - "$size ${if (size == 1) "child" else "children"}", + children(size), element.textRange.startOffset + 1, ), ) @@ -49,7 +50,7 @@ val size = element.getTagList().size list.add( InlayInfo( - "$size ${if (size == 1) "child" else "children"}", + children(size), element.textRange.startOffset + 1, ), ) @@ -65,7 +66,7 @@ val size = element.getByteList().size list.add( InlayInfo( - "$size ${if (size == 1) "child" else "children"}", + children(size), element.node.getChildren(null)[1].textRange.startOffset + 1, ), ) @@ -81,7 +82,7 @@ val size = element.getIntList().size list.add( InlayInfo( - "$size ${if (size == 1) "child" else "children"}", + children(size), element.node.getChildren(null)[1].textRange.startOffset + 1, ), ) @@ -97,7 +98,7 @@ val size = element.getLongList().size list.add( InlayInfo( - "$size ${if (size == 1) "child" else "children"}", + children(size), element.node.getChildren(null)[1].textRange.startOffset + 1, ), ) @@ -128,6 +129,14 @@ return list } + private fun children(size: Int): String { + return if (size == 1) { + MCDevBundle("nbt.lang.inlay_hints.one_child") + } else { + MCDevBundle("nbt.lang.inlay_hints.children", size) + } + } + override fun getHintInfo(element: PsiElement): HintInfo? = null override fun getDefaultBlackList() = mutableSetOf() } Index: src/main/kotlin/nbt/lang/psi/NbttMixinUtil.kt =================================================================== --- src/main/kotlin/nbt/lang/psi/NbttMixinUtil.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/lang/psi/NbttMixinUtil.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.nbt.lang.psi +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.nbt.MalformedNbtFileException import com.demonwav.mcdev.nbt.lang.gen.psi.NbttByte import com.demonwav.mcdev.nbt.lang.gen.psi.NbttByteArray @@ -51,6 +52,6 @@ NbtTypeId.COMPOUND -> (getTag() as NbttCompound).getCompoundTag() NbtTypeId.INT_ARRAY -> (getTag() as NbttIntArray).getIntArrayTag() NbtTypeId.LONG_ARRAY -> (getTag() as NbttLongArray).getLongArrayTag() - else -> throw MalformedNbtFileException("Unknown error") + else -> throw MalformedNbtFileException(MCDevBundle("nbt.lang.errors.unknown")) } } Index: src/main/kotlin/nbt/lang/psi/mixins/impl/NbttListImplMixin.kt =================================================================== --- src/main/kotlin/nbt/lang/psi/mixins/impl/NbttListImplMixin.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/lang/psi/mixins/impl/NbttListImplMixin.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.nbt.lang.psi.mixins.impl +import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.nbt.MalformedNbtFileException import com.demonwav.mcdev.nbt.lang.psi.getNbtTag import com.demonwav.mcdev.nbt.lang.psi.mixins.NbttListMixin @@ -39,7 +40,7 @@ if (type == null) { type = tagType } else if (type != tagType) { - throw MalformedNbtFileException("Lists can only contain elements of the same type.") + throw MalformedNbtFileException(MCDevBundle("nbt.lang.errors.invalid_list")) } } Index: src/main/kotlin/nbt/tags/NbtValueTag.kt =================================================================== --- src/main/kotlin/nbt/tags/NbtValueTag.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/tags/NbtValueTag.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -20,8 +20,10 @@ package com.demonwav.mcdev.nbt.tags -abstract class NbtValueTag(private val valueClass: Class) : NbtTag { +import kotlin.reflect.KClass +abstract class NbtValueTag(private val valueClass: KClass) : NbtTag { + abstract val value: T override fun equals(other: Any?): Boolean { @@ -48,7 +50,7 @@ override fun toString(sb: StringBuilder, indentLevel: Int, writerState: WriterState) = sb.append(value)!! override fun copy(): NbtValueTag { - val const = typeId.tagClass.java.getConstructor(valueClass) + val const = typeId.tagClass.java.getConstructor(valueClass.java) @Suppress("UNCHECKED_CAST") return const.newInstance(valueCopy()) as NbtValueTag } Index: src/main/kotlin/nbt/tags/TagByte.kt =================================================================== --- src/main/kotlin/nbt/tags/TagByte.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/tags/TagByte.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -22,7 +22,7 @@ import java.io.DataOutputStream -class TagByte(override val value: Byte) : NbtValueTag(Byte::class.java) { +class TagByte(override val value: Byte) : NbtValueTag(Byte::class) { override val payloadSize = 1 override val typeId = NbtTypeId.BYTE Index: src/main/kotlin/nbt/tags/TagByteArray.kt =================================================================== --- src/main/kotlin/nbt/tags/TagByteArray.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/tags/TagByteArray.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -22,7 +22,7 @@ import java.io.DataOutputStream -class TagByteArray(override val value: ByteArray) : NbtValueTag(ByteArray::class.java) { +class TagByteArray(override val value: ByteArray) : NbtValueTag(ByteArray::class) { override val payloadSize = 4 + value.size override val typeId = NbtTypeId.BYTE_ARRAY Index: src/main/kotlin/nbt/tags/TagDouble.kt =================================================================== --- src/main/kotlin/nbt/tags/TagDouble.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/tags/TagDouble.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -25,7 +25,7 @@ import java.text.NumberFormat import java.util.Locale -class TagDouble(override val value: Double) : NbtValueTag(Double::class.java) { +class TagDouble(override val value: Double) : NbtValueTag(Double::class) { override val payloadSize = 8 override val typeId = NbtTypeId.DOUBLE Index: src/main/kotlin/nbt/tags/TagFloat.kt =================================================================== --- src/main/kotlin/nbt/tags/TagFloat.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/tags/TagFloat.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -22,7 +22,7 @@ import java.io.DataOutputStream -class TagFloat(override val value: Float) : NbtValueTag(Float::class.java) { +class TagFloat(override val value: Float) : NbtValueTag(Float::class) { override val payloadSize = 4 override val typeId = NbtTypeId.FLOAT Index: src/main/kotlin/nbt/tags/TagInt.kt =================================================================== --- src/main/kotlin/nbt/tags/TagInt.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/tags/TagInt.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -22,7 +22,7 @@ import java.io.DataOutputStream -class TagInt(override val value: Int) : NbtValueTag(Int::class.java) { +class TagInt(override val value: Int) : NbtValueTag(Int::class) { override val payloadSize = 4 override val typeId = NbtTypeId.INT Index: src/main/kotlin/nbt/tags/TagIntArray.kt =================================================================== --- src/main/kotlin/nbt/tags/TagIntArray.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/tags/TagIntArray.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -22,7 +22,7 @@ import java.io.DataOutputStream -class TagIntArray(override val value: IntArray) : NbtValueTag(IntArray::class.java) { +class TagIntArray(override val value: IntArray) : NbtValueTag(IntArray::class) { override val payloadSize = 4 + value.size * 4 override val typeId = NbtTypeId.INT_ARRAY Index: src/main/kotlin/nbt/tags/TagLong.kt =================================================================== --- src/main/kotlin/nbt/tags/TagLong.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/tags/TagLong.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -22,7 +22,7 @@ import java.io.DataOutputStream -class TagLong(override val value: Long) : NbtValueTag(Long::class.java) { +class TagLong(override val value: Long) : NbtValueTag(Long::class) { override val payloadSize = 8 override val typeId = NbtTypeId.LONG Index: src/main/kotlin/nbt/tags/TagLongArray.kt =================================================================== --- src/main/kotlin/nbt/tags/TagLongArray.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/tags/TagLongArray.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -22,7 +22,7 @@ import java.io.DataOutputStream -class TagLongArray(override val value: LongArray) : NbtValueTag(LongArray::class.java) { +class TagLongArray(override val value: LongArray) : NbtValueTag(LongArray::class) { override val payloadSize = 4 + value.size * 8 override val typeId = NbtTypeId.LONG_ARRAY Index: src/main/kotlin/nbt/tags/TagShort.kt =================================================================== --- src/main/kotlin/nbt/tags/TagShort.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/tags/TagShort.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -22,7 +22,7 @@ import java.io.DataOutputStream -class TagShort(override val value: Short) : NbtValueTag(Short::class.java) { +class TagShort(override val value: Short) : NbtValueTag(Short::class) { override val payloadSize = 2 override val typeId = NbtTypeId.SHORT Index: src/main/kotlin/nbt/tags/TagString.kt =================================================================== --- src/main/kotlin/nbt/tags/TagString.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/nbt/tags/TagString.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -22,7 +22,7 @@ import java.io.DataOutputStream -class TagString(override val value: String) : NbtValueTag(String::class.java) { +class TagString(override val value: String) : NbtValueTag(String::class) { override val payloadSize = 2 + value.toByteArray().size override val typeId = NbtTypeId.STRING Index: src/main/kotlin/platform/mcp/fabricloom/FabricLoomDataService.kt =================================================================== --- src/main/kotlin/platform/mcp/fabricloom/FabricLoomDataService.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/platform/mcp/fabricloom/FabricLoomDataService.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -212,7 +212,7 @@ JavaDirectoryService.getInstance().createClass(psiDir, className) } catch (e: IncorrectOperationException) { invokeLater { - val message = MCDevBundle.message( + val message = MCDevBundle( "intention.error.cannot.create.class.message", className, e.localizedMessage, @@ -220,7 +220,7 @@ Messages.showErrorDialog( project, message, - MCDevBundle.message("intention.error.cannot.create.class.title"), + MCDevBundle("intention.error.cannot.create.class.title"), ) } return Index: src/main/kotlin/platform/mixin/action/GenerateAccessorHandler.kt =================================================================== --- src/main/kotlin/platform/mixin/action/GenerateAccessorHandler.kt (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/kotlin/platform/mixin/action/GenerateAccessorHandler.kt (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -288,7 +288,7 @@ JavaDirectoryService.getInstance().createInterface(pkg, name) } catch (e: IncorrectOperationException) { invokeLater { - val message = MCDevBundle.message( + val message = MCDevBundle( "intention.error.cannot.create.class.message", name, e.localizedMessage, @@ -296,7 +296,7 @@ Messages.showErrorDialog( project, message, - MCDevBundle.message("intention.error.cannot.create.class.title"), + MCDevBundle("intention.error.cannot.create.class.title"), ) } return@compute null Index: src/main/resources/messages/MinecraftDevelopment.properties =================================================================== --- src/main/resources/messages/MinecraftDevelopment.properties (revision f7cb291b6c44b3cb280c66160acb1bd526ec74f1) +++ src/main/resources/messages/MinecraftDevelopment.properties (revision b3d07a201b96ee310cdcbee0246521a9206968e8) @@ -73,8 +73,107 @@ creator.validation.jdk_preferred=Java {0} is recommended for {1} creator.validation.jdk_preferred_default_reason=these settings +error_reporter.submit.action=Report to Minecraft Dev GitHub Issue Tracker +error_reporter.submit.failure=Expected HTTP_CREATED (201), obtained {0} instead. +error_reporter.submit.ignored=Ignored error + +error_reporter.report.title=Error report +error_reporter.report.created=Created Issue #{0} successfully. +error_reporter.report.created.action=View issue +error_reporter.report.commented=Commented on existing Issue #{0} successfully. +error_reporter.report.commented.action=View comment + +error_reporter.report.error=Error Submitting Issue: {0}. +error_reporter.report.error.action=Open an issue on the GitHub issue tracker + +facet.editor.name=Minecraft Module Settings + generate.event_listener.title=Generate Event Listener generate.event_listener.settings=Event Listener Settings +generate.class.caption=Minecraft Class +generate.class.description=Class generation for modders + +generate.color.change_action=Change Color +generate.color.change_error=Can''t change colors in {0} +generate.color.choose_action=Choose Color + +insight.event_listener.marker=Event Listener line marker +insight.event_listener.marker.goto=Go to Event declaration +insight.event_listener.marker.accessible_name=event listener indicator +insight.event_listener.marker.multiple=Multiple method overrides + +insight.plugin.marker=Minecraft Plugin line marker +insight.plugin.marker.accessible_name=minecraft {0} entry point indicator +insight.plugin.marker.accessible_name_mod=mod +insight.plugin.marker.accessible_name_plugin=plugin +insight.plugin.marker.accessible_name_unsure=mod or plugin + +inspection.is_cancelled.name=Useless event isCancelled check +inspection.is_cancelled.description=Reports useless event cancellation checks +inspection.entry_point.name=Minecraft Entry Point +inspection.entity_data_param.description=Reports when the class passed to an entity data parameter definition is \ + not the same as the containing entity class. +inspection.entity_data_param.message=Entity class does not match this entity class +inspection.entity_data_param.fix=Replace other entity class with this entity class + +nbt.compression.gzip=GZipped +nbt.compression.uncompressed=Uncompressed +nbt.compression.file_type.label=File Type: +nbt.compression.save.button=Save + +nbt.file_type.name=NBT +nbt.file_type.description=NBT + +nbt.lang.annotate.material=Material +nbt.lang.annotate.type_byte=Type: byte +nbt.lang.annotate.type_short=Type: short +nbt.lang.annotate.type_long=Type: long +nbt.lang.annotate.type_float=Type: float +nbt.lang.annotate.type_double=Type: double + +nbt.lang.display_name=NBT Text +nbt.lang.description=NBT text representation (don't use this one) + +nbt.lang.highlighting.keyword.display_name=Keyword +nbt.lang.highlighting.string.display_name=String +nbt.lang.highlighting.unquoted_string.display_name=Unquoted string +nbt.lang.highlighting.name.display_name=Name +nbt.lang.highlighting.unquoted_name.display_name=Unquoted name +nbt.lang.highlighting.byte.display_name=Byte +nbt.lang.highlighting.short.display_name=Short +nbt.lang.highlighting.int.display_name=Int +nbt.lang.highlighting.long.display_name=Long +nbt.lang.highlighting.float.display_name=Float +nbt.lang.highlighting.double.display_name=Double +nbt.lang.highlighting.material.display_name=Material + +nbt.lang.style.space_before_colon=Space before colon +nbt.lang.style.space_after_colon=Space after colon +nbt.lang.style.list_brackets=List brackets +nbt.lang.style.array_parentheses=Array parentheses + +nbt.lang.inlay_hints.one_child=1 child +nbt.lang.inlay_hints.children={0} children + +nbt.lang.errors.unknown=Unknown error. +nbt.lang.errors.invalid_list=Lists can only contain elements of the same type. +nbt.lang.errors.wrong_tag_id=Unexpected tag id found: {0}. +nbt.lang.errors.invalid_root=Root tag in NBT file is not a compound. +nbt.lang.errors.reading=Error reading file. +nbt.lang.errors.parse_timeout=NBT parse timeout exceeded - Parse time: {0}, Timeout: {1}. + +nbt.lang.errors.wrapped_error_message=Malformed NBT file:\n{0} + +nbt.file.save_notify.success.title=Saved NBT file successfully +nbt.file.save_notify.success.content={0} was saved successfully. + +nbt.file.save_notify.file_type_error.title=Error saving NBT file +nbt.file.save_notify.file_type_error.content=The file is not recognised as a NBTT file. This might be caused by \ + wrong file type associations, or the file could be too large. + +nbt.file.save_notify.parse_error.title=Error saving NBT file +nbt.file.save_notify.parse_error.content=Due to errors in the text representation, {0} could not be saved. + intention.error.cannot.create.class.message=Cannot create class ''{0}''\n{1} intention.error.cannot.create.class.title=Failed to Create Class