-
Notifications
You must be signed in to change notification settings - Fork 1
Chore/refactor #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: version/1.21.10
Are you sure you want to change the base?
Chore/refactor #18
Conversation
…TextColor.color()
…ove cooldown handling
…layers management
…ctionality and readability
…for configuration reloading
…ne support and improved configuration handling
…arity and consistency
…ecks for improved clarity and performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| object FaqService { | ||
| private val faqCooldown = SurfModerationToolConfig.getConfig().faqCooldown | ||
| private val lastFaqUsage = Caffeine.newBuilder() | ||
| .expireAfterWrite(faqCooldown.milliseconds) | ||
| .build<Faq, Long>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FaqService now snapshots faqCooldown when the object is initialized, so later config changes (e.g. via setMessageCooldown or reload) will not affect the enforced cooldown or the cache expiry until the JVM restarts. In the previous implementation, the cooldown was read from config on each use, so operators could change it at runtime. This regression means admins will think the command/reload worked while the old cooldown is still applied.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the moderation tools plugin by replacing the configuration provider pattern with a singleton-style config object, modernizing command implementations with suspend functions, and updating dependencies (Gradle 9.1.0, surf-bitmap 2.1.3). The changes streamline configuration management, improve coroutine support in commands, and refactor the FAQ system from sealed classes to enums.
- Replaced
SurfModerationToolConfigProviderclass with singletonSurfModerationToolConfigobject for centralized config access - Converted services (
FreezeService,FaqService) and listeners to object singletons and added suspend function support - Refactored
Faqfrom sealed class to enum, simplifying FAQ management and improving type safety
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
SurfModerationToolConfig.kt |
Implements new singleton config pattern with companion object extending SpongeYmlConfigClass |
SurfModerationToolConfigProvider.kt |
Removed legacy provider class in favor of singleton approach |
FreezeService.kt |
Converted to object singleton with simplified Caffeine cache-based freeze tracking |
FaqService.kt |
Converted to object with suspend function support and refactored cooldown logic |
FreezeCommand.kt |
Updated to use suspend executors and simplified teleportation logic |
UnfreezeCommand.kt |
Updated service references and message formatting |
RotateCommand.kt |
Migrated to suspend executors with improved random number generation |
FaqCommand.kt |
Updated to suspend executors and simplified target handling |
FaqArgument.kt |
Simplified argument handling with updated error messages |
PlayerActionListener.kt |
Converted to object singleton with updated service references |
Faq.kt |
Refactored from sealed class to enum with improved message handling |
surf-util.kt |
Updated to use ShadowColor type and adjusted parameter ordering |
DurationArgument.kt |
Complete rewrite using Brigadier's StringReader for more robust parsing |
PaperMain.kt |
Added config initialization in onLoadAsync and removed provider instance |
ReloadConfigCommand.kt |
Updated to use static config reload method |
SetArtyCooldownCommand.kt |
Updated to use static config edit method with duration argument |
| Gradle files | Upgraded to Gradle 9.1.0, updated surf-bitmap to 2.1.3-SNAPSHOT, incremented plugin version |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| val location = targetPlayer.location | ||
| val world = location.world | ||
|
|
||
| var teleported = false | ||
| for (y in location.blockY downTo 0) { | ||
| val block = world.getBlockAt(location.blockX, y, location.blockZ) | ||
| if (block.type.isSolid) { | ||
| location.y = y + 1.0 | ||
| targetPlayer.teleportAsync(location) | ||
| teleported = true | ||
| break | ||
| } | ||
| } | ||
| val teleported = targetPlayer.teleportAsync(location.toHighestLocation()).await() | ||
|
|
||
| if (!teleported) { | ||
| val fallbackLocation = world.spawnLocation | ||
| targetPlayer.teleportAsync(fallbackLocation) | ||
| targetPlayer.teleportAsync(world.spawnLocation).await() | ||
| } |
Copilot
AI
Jan 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The teleportation logic has been simplified to use toHighestLocation(), but there's no fallback handling if the highest location is not suitable (e.g., in void or lava). The original code searched downward for a solid block, which provided more robust teleportation behavior. Consider whether the new approach adequately handles edge cases.
src/main/kotlin/dev/slne/surf/moderation/tools/utils/DurationArgument.kt
Show resolved
Hide resolved
src/main/kotlin/dev/slne/surf/moderation/tools/commands/UnfreezeCommand.kt
Show resolved
Hide resolved
src/main/kotlin/dev/slne/surf/moderation/tools/commands/FreezeCommand.kt
Show resolved
Hide resolved
| .append("Faq ") | ||
| .appendArgInput() | ||
| .append(" not found.") |
Copilot
AI
Jan 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message has been changed to English ("Faq ... not found.") while the rest of the codebase uses German error messages. This inconsistency should be corrected to maintain uniform language across the application. The original German message was appropriate.
| .append("Faq ") | |
| .appendArgInput() | |
| .append(" not found.") | |
| .append("FAQ ") | |
| .appendArgInput() | |
| .append(" nicht gefunden.") |
src/main/kotlin/dev/slne/surf/moderation/tools/utils/DurationArgument.kt
Show resolved
Hide resolved
src/main/kotlin/dev/slne/surf/moderation/tools/commands/FreezeCommand.kt
Show resolved
Hide resolved
src/main/kotlin/dev/slne/surf/moderation/tools/commands/UnfreezeCommand.kt
Show resolved
Hide resolved
JoField08
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Du wirst schon wissen was du hier tust
This pull request introduces several improvements and refactorings to the moderation tools plugin, focusing on configuration management, command handling, and dependency/tooling updates. The most significant changes include a major refactor of configuration handling (removing the provider class in favor of a singleton-style config object), modernization and simplification of command implementations, and updates to dependencies and build tooling for better maintainability and compatibility.
Configuration Management Refactor:
SurfModerationToolConfigProviderclass with a new singleton-styleSurfModerationToolConfigobject, centralizing config access and management. All usages of the old provider have been updated to use the new object and its static methods for initialization, editing, and reloading. (src/main/kotlin/dev/slne/surf/moderation/tools/config/SurfModerationToolConfig.kt[1]src/main/kotlin/dev/slne/surf/moderation/tools/config/SurfModerationToolConfigProvider.kt[2]src/main/kotlin/dev/slne/surf/moderation/tools/PaperMain.kt[3]src/main/kotlin/dev/slne/surf/moderation/tools/commands/ReloadConfigCommand.kt[4]src/main/kotlin/dev/slne/surf/moderation/tools/commands/SetArtyCooldownCommand.kt[5]Command and Service Improvements:
Refactored command executors to use suspend functions where appropriate, improving coroutine support and simplifying asynchronous logic. Updated usages of command executors and service calls to use new class-based service access patterns (e.g.,
FreezeServiceinstead offreezeService). (src/main/kotlin/dev/slne/surf/moderation/tools/commands/FreezeCommand.kt[1]src/main/kotlin/dev/slne/surf/moderation/tools/commands/RotateCommand.kt[2]src/main/kotlin/dev/slne/surf/moderation/tools/commands/FaqCommand.kt[3]src/main/kotlin/dev/slne/surf/moderation/tools/commands/UnfreezeCommand.kt[4] [5]Improved argument handling and suggestions for the FAQ command, using new static methods and simplifying the
FaqArgumentimplementation. (src/main/kotlin/dev/slne/surf/moderation/tools/commands/argument/FaqArgument.ktsrc/main/kotlin/dev/slne/surf/moderation/tools/commands/argument/FaqArgument.ktL10-R30)Dependency and Build Tooling Updates:
surf-bitmapdependency version, and incremented the plugin version. Adjusted the Gradle wrapper scripts to use the-jaroption instead of classpath for launching. (gradle/wrapper/gradle-wrapper.properties[1]gradle/libs.versions.toml[2]gradle.properties[3]gradlew[4] [5] [6] [7]gradlew.bat[8]settings.gradle.kts[9]General Codebase Cleanup:
gradlewgradlewL4-R4)These changes collectively modernize the codebase, improve maintainability, and set up the project for easier future enhancements.