Skip to content

Conversation

@twisti-dev
Copy link

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:

  • Replaced the SurfModerationToolConfigProvider class with a new singleton-style SurfModerationToolConfig object, 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., FreezeService instead of freezeService). (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 FaqArgument implementation. (src/main/kotlin/dev/slne/surf/moderation/tools/commands/argument/FaqArgument.kt src/main/kotlin/dev/slne/surf/moderation/tools/commands/argument/FaqArgument.ktL10-R30)

Dependency and Build Tooling Updates:

  • Upgraded Gradle wrapper from 8.14.3 to 9.1.0, updated the surf-bitmap dependency version, and incremented the plugin version. Adjusted the Gradle wrapper scripts to use the -jar option 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:

  • Removed redundant copyright years and unused code, and improved code readability in several places. (gradlew gradlewL4-R4)

These changes collectively modernize the codebase, improve maintainability, and set up the project for easier future enhancements.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

Comment on lines +21 to 25
object FaqService {
private val faqCooldown = SurfModerationToolConfig.getConfig().faqCooldown
private val lastFaqUsage = Caffeine.newBuilder()
.expireAfterWrite(faqCooldown.milliseconds)
.build<Faq, Long>()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Read faq cooldown dynamically

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 👍 / 👎.

Copy link
Contributor

Copilot AI left a 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 SurfModerationToolConfigProvider class with singleton SurfModerationToolConfig object for centralized config access
  • Converted services (FreezeService, FaqService) and listeners to object singletons and added suspend function support
  • Refactored Faq from 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.

Comment on lines +43 to 50
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()
}
Copy link

Copilot AI Jan 1, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +17
.append("Faq ")
.appendArgInput()
.append(" not found.")
Copy link

Copilot AI Jan 1, 2026

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.

Suggested change
.append("Faq ")
.appendArgInput()
.append(" not found.")
.append("FAQ ")
.appendArgInput()
.append(" nicht gefunden.")

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@JoField08 JoField08 left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants