refactor: update Rarity enum to use string display names and simplify…#302
refactor: update Rarity enum to use string display names and simplify…#302ammodev merged 1 commit intoversion/26.1from
Conversation
… component creation
There was a problem hiding this comment.
Pull request overview
Refactors the core Rarity enum to define display names as plain strings and build the corresponding Adventure components via the lightweight text(...) helper, along with a patch version bump.
Changes:
- Replace per-enum
SurfComponentBuilderlambdas with string display names and constructdisplayNameviatext(displayName, color). - Remove
buildText/SurfComponentBuilderusage fromRarity. - Bump project version from
3.0.6to3.0.7.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/rarity/Rarity.kt | Simplifies rarity display name construction to a string + color-based TextComponent. |
| gradle.properties | Updates the project version to 3.0.7. |
| * @property displayName The visual display name of the rarity level. | ||
| * @property color The textual color associated with the rarity level. | ||
| */ | ||
| enum class Rarity( | ||
| displayName: SurfComponentBuilder.() -> Unit, | ||
| displayName: String, | ||
| val color: TextColor |
There was a problem hiding this comment.
The KDoc uses @property displayName, but displayName is no longer a constructor property (the constructor parameter is not declared as val/var). This can lead to Dokka/KDoc being misleading or emitting warnings. Consider removing the @property displayName tag and instead documenting the val displayName property directly, or rename/store the constructor parameter as a (private) property (e.g., private val displayNameText) and document accordingly.
| val displayName = text(displayName, color) | ||
| override fun asComponent() = displayName |
There was a problem hiding this comment.
val displayName = text(displayName, color) reuses the same identifier as the constructor parameter, relying on Kotlin's name shadowing rules. This is easy to misread and can confuse future refactors. Rename the constructor parameter to something like displayNameText/displayNameRaw (or store it as a private property) so the initializer reads unambiguously.
… component creation