Skip to content

Add auto unclaim feature#1918

Draft
Copilot wants to merge 3 commits intodevelopfrom
copilot/add-auto-unclaim-feature
Draft

Add auto unclaim feature#1918
Copilot wants to merge 3 commits intodevelopfrom
copilot/add-auto-unclaim-feature

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 13, 2025

  • Create MfFactionUnclaimAutoCommand similar to MfFactionClaimAutoCommand
  • Add autounclaim boolean property to MfFaction data class
  • Update database migration to add autounclaim column
  • Add auto unclaim logic to PlayerMoveListener
  • Register command in MfFactionUnclaimCommand
  • Add language strings for auto unclaim feature
  • Add permission for toggle auto unclaim
  • Update help command to include auto unclaim
  • Complete code review
  • Address review comments:
    • Fixed help text to show /faction unclaim auto instead of /faction autounclaim across all 5 language files
    • Removed redundant null check for playerFaction by merging autounclaim logic into same if-block

Implementation Notes

  • Follows the same pattern as autoclaim feature for consistency
  • All language files updated (en_US, en_GB, de_DE, fr_FR, pt_BR)
  • Permission check follows existing codebase pattern (uses OR logic like other commands)
  • Database migration V9 adds autounclaim column
  • JOOQ classes will need regeneration when project can be built
  • Autounclaim logic now properly contained within single playerFaction null check
Original prompt

This section details on the original issue you should resolve

<issue_title>Auto unclaim feature</issue_title>
<issue_description>To go along with the auto claim feature, this would be very a very welcome addition.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copilot AI changed the title [WIP] Add auto unclaim feature Add auto unclaim feature Dec 13, 2025
Copy link
Copy Markdown

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 pull request implements an auto unclaim feature that mirrors the existing auto claim functionality. When enabled via /faction unclaim auto, faction members with appropriate permissions can walk through their faction's territory to automatically unclaim chunks.

Changes:

  • Added database migration to add autounclaim boolean column to mf_faction table
  • Extended MfFaction data model and repository with autounclaim field
  • Refactored MfFactionUnclaimCommand to support subcommands, creating separate MfFactionUnclaimAutoCommand and MfFactionUnclaimCircleCommand classes
  • Added autounclaim trigger logic to PlayerMoveListener to detect and delete claims when players enter their faction's territory
  • Added TOGGLE_AUTOUNCLAIM faction permission and corresponding Bukkit permissions
  • Added translations for all new messages across 5 supported languages (English US/GB, French, Portuguese BR, German)

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
V9__Add_autounclaim.sql Database migration adding autounclaim boolean column with default false
MfFaction.kt Added autounclaim boolean field to faction data model
JooqMfFactionRepository.kt Updated persistence layer to save/load autounclaim field
MfFactionUnclaimCommand.kt Refactored to delegate to subcommands (auto/circle pattern)
MfFactionUnclaimAutoCommand.kt New command to toggle autounclaim for faction
MfFactionUnclaimCircleCommand.kt Extracted original unclaim logic to separate class
PlayerMoveListener.kt Added autounclaim trigger logic when entering owned chunks
MfFactionPermissions.kt Added TOGGLE_AUTOUNCLAIM permission
MfFactionHelpCommand.kt Added autounclaim help text to command list
lang_*.properties (x5) Added translations for autounclaim messages in all 5 languages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

CommandFactionHelpFaction=/faction - Faction management commands
CommandFactionHelpFactionAlly=/faction ally [faction] - Ally with a given faction
CommandFactionHelpFactionAutoclaim=/faction autoclaim - Enable autoclaim for your faction
CommandFactionHelpFactionAutounclaim=/faction autounclaim - Enable autounclaim for your faction
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

The help text shows /faction autounclaim but the actual command structure is /faction unclaim auto based on the implementation in MfFactionUnclaimCommand.kt. The help text should be corrected to /faction unclaim auto to match the actual command structure.

Suggested change
CommandFactionHelpFactionAutounclaim=/faction autounclaim - Enable autounclaim for your faction
CommandFactionHelpFactionAutounclaim=/faction unclaim auto - Enable autounclaim for your faction

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in cc7dfac - Changed help text to /faction unclaim auto

CommandFactionHelpFaction=/faction - Faction management commands
CommandFactionHelpFactionAlly=/faction ally [faction] - Ally with a given faction
CommandFactionHelpFactionAutoclaim=/faction autoclaim - Enable autoclaim for your faction
CommandFactionHelpFactionAutounclaim=/faction autounclaim - Enable autounclaim for your faction
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

The help text shows /faction autounclaim but the actual command structure is /faction unclaim auto. The help text should be corrected to /faction unclaim auto to match the actual command structure.

Suggested change
CommandFactionHelpFactionAutounclaim=/faction autounclaim - Enable autounclaim for your faction
CommandFactionHelpFactionAutounclaim=/faction unclaim auto - Enable autounclaim for your faction

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in cc7dfac - Changed help text to /faction unclaim auto

CommandFactionHelpFaction=/faction - Commandes de gestion de faction
CommandFactionHelpFactionAlly=/faction ally [faction] - S''allier � une faction donn�e
CommandFactionHelpFactionAutoclaim=/faction autoclaim - Activer l''autoclaim pour votre faction
CommandFactionHelpFactionAutounclaim=/faction autounclaim - Activer l''autounclaim pour votre faction
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

The help text shows /faction autounclaim but the actual command structure is /faction unclaim auto. The help text should be corrected to /faction unclaim auto to match the actual command structure.

Suggested change
CommandFactionHelpFactionAutounclaim=/faction autounclaim - Activer l''autounclaim pour votre faction
CommandFactionHelpFactionAutounclaim=/faction unclaim auto - Activer l''autounclaim pour votre faction

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in cc7dfac - Changed help text to /faction unclaim auto

CommandFactionHelpFaction=/faction - Comandos de gerenciamento de facção
CommandFactionHelpFactionAlly=/faction ally [faction] - Aliar-se a uma determinada facção
CommandFactionHelpFactionAutoclaim=/faction autoclaim - Ative a reivindicação automática para sua facção
CommandFactionHelpFactionAutounclaim=/faction autounclaim - Ative a desreivindicação automática para sua facção
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

The help text shows /faction autounclaim but the actual command structure is /faction unclaim auto. The help text should be corrected to /faction unclaim auto to match the actual command structure.

Suggested change
CommandFactionHelpFactionAutounclaim=/faction autounclaim - Ative a desreivindicação automática para sua facção
CommandFactionHelpFactionAutounclaim=/faction unclaim auto - Ative a desreivindicação automática para sua facção

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in cc7dfac - Changed help text to /faction unclaim auto

CommandFactionHelpFactionAutoclaim=/fraktion autoanspruch - Aktiviere den Autoanspruch f�r deine Fraktion
CommandFactionHelpFactionAlly=/fraktion verb�ndeter [faction] - Verb�nde dich mit einer bestimmten Fraktion
CommandFactionHelpFactionAutoclaim=/fraktion autoanspruch - Aktiviere den Autoanspruch f�r deine Fraktion
CommandFactionHelpFactionAutounclaim=/fraktion autoaufhebung - Aktiviere die Autoaufhebung f�r deine Fraktion
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

The help text shows /fraktion autoaufhebung but the actual command structure is /fraktion deklarieren auto (based on the English equivalent /faction unclaim auto). The help text should be corrected to match the actual command structure.

Suggested change
CommandFactionHelpFactionAutounclaim=/fraktion autoaufhebung - Aktiviere die Autoaufhebung f�r deine Fraktion
CommandFactionHelpFactionAutounclaim=/fraktion deklarieren auto - Aktiviere die Autoaufhebung f�r deine Fraktion

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in cc7dfac - Changed help text to /fraktion deklarieren auto

if (newChunkClaim != null && newChunkClaim.factionId.value == playerFaction.id.value && playerFaction.autounclaim) {
val playerRole = playerFaction.getRole(mfPlayer.id) ?: return@Runnable
val unclaimPermissionValue = playerRole.getPermissionValue(plugin.factionPermissions.unclaim) ?: return@Runnable
if (!unclaimPermissionValue || !event.player.hasPermission("mf.unclaim")) {
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

The permission check on line 95 verifies both the faction permission (unclaimPermissionValue) and the Bukkit permission (mf.unclaim). However, this check returns early silently if the player lacks permissions. When autounclaim is enabled but the player lacks permissions, they will walk through their territory without any feedback that autounclaim failed due to insufficient permissions. Consider adding a message to inform the player why autounclaim didn't work, similar to how autoclaim shows messages when it's automatically disabled due to power limits or contiguity issues.

Suggested change
if (!unclaimPermissionValue || !event.player.hasPermission("mf.unclaim")) {
if (!unclaimPermissionValue || !event.player.hasPermission("mf.unclaim")) {
plugin.server.scheduler.runTask(
plugin,
Runnable {
event.player.sendMessage("${RED}You do not have permission to automatically unclaim territory.")
}
)

Copilot uses AI. Check for mistakes.
Comment on lines +91 to +103
if (playerFaction != null) {
if (newChunkClaim != null && newChunkClaim.factionId.value == playerFaction.id.value && playerFaction.autounclaim) {
val playerRole = playerFaction.getRole(mfPlayer.id) ?: return@Runnable
val unclaimPermissionValue = playerRole.getPermissionValue(plugin.factionPermissions.unclaim) ?: return@Runnable
if (!unclaimPermissionValue || !event.player.hasPermission("mf.unclaim")) {
return@Runnable
}
claimService.delete(newChunkClaim).onFailure {
plugin.logger.log(SEVERE, "Failed to delete chunk claim: ${it.reason.message}", it.reason.cause)
return@Runnable
}
}
}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

The null check for playerFaction on line 91 is redundant. The variable playerFaction is already checked for null on line 40, and between lines 40-90, there's no code that could make it null again (it's a val, not reassigned). The autounclaim block could be merged into the same if-block as the autoclaim logic on line 40, or at minimum, this redundant null check should be removed.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in cc7dfac - Removed redundant null check by merging autounclaim logic into the same if-block as autoclaim (line 40)

@dmccoystephenson
Copy link
Copy Markdown
Member

@copilot address comments

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
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