Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 13, 2025

Implementation Complete ✅

Summary

Modified the /mf addmember command to prompt users for confirmation when attempting to add a player who is already in another faction, instead of immediately rejecting the action.

Recent Changes (addressing PR feedback)

  • ✅ Added French, German, and Portuguese translations for all new language keys
  • ✅ Added permission check for force flag (-f) - only users with mf.force.addmember or mf.force.join can use it
  • ✅ Added notification to target player when they are moved between factions (if online)
  • ✅ Changed var targetName to val targetName for better code quality

Changes Made

Code Changes

  • MfFactionAddMemberCommand.kt:
    • Added permission validation for force flag (following MfFactionJoinCommand pattern)
    • Implemented confirmAddMember() method to display clickable confirmation UI
    • When force flag is present with proper permissions, removes player from current faction before adding to new one
    • Notifies the old faction when a member is forcefully removed
    • Notifies the target player (if online) about being moved between factions

Language Files

  • Added 9 language keys with full translations in all 5 language files (en_US, en_GB, de_DE, fr_FR, pt_BR):
    • CommandFactionAddMemberConfirmRemoval: Main confirmation message
    • CommandFactionAddMemberConfirmButton: Confirm button text
    • CommandFactionAddMemberConfirmButtonHover: Confirm button hover text
    • CommandFactionAddMemberCancelButton: Cancel button text
    • CommandFactionAddMemberCancelButtonHover: Cancel button hover text
    • CommandFactionAddMemberFailedToRemoveFromCurrentFaction: Error message
    • CommandFactionAddMemberRemovedFromFactionTitle: Notification title
    • CommandFactionAddMemberRemovedFromFactionBody: Notification body
    • CommandFactionAddMemberPlayerNotification: Message to target player

User Experience Flow

  1. Admin with mf.force.addmember or mf.force.join permission runs: /mf addmember Steve TheFaction
  2. If Steve is already in "OldFaction", they see:
    • "Steve is currently in OldFaction. Do you want to remove them and add them to TheFaction?"
    • [Confirm] button (green, clickable)
    • [Cancel] button (red, clickable)
  3. Clicking [Confirm] executes: /mf addmember Steve TheFaction -f
    • Removes Steve from OldFaction
    • OldFaction members see notification about removal
    • Steve (if online) sees: "You have been moved from faction OldFaction to faction TheFaction."
    • Adds Steve to TheFaction
    • TheFaction members see notification about new member
  4. Clicking [Cancel] shows the help menu

Technical Details

  • Follows existing codebase patterns (similar to /faction join with permission-checked force flag)
  • Minimal changes to existing code
  • No new services or repositories needed
  • Linting passes ✅
  • All PR feedback addressed ✅
Original prompt

This section details on the original issue you should resolve

<issue_title>Prompt the user regarding whether they'd like the target player to be removed from their current faction when using the 'addmember' command.</issue_title>
<issue_description>At this time, users are informed that the target player is already in a faction when attempting to add them to a faction w/ the 'addmember' command. Instead, we should prompt the user regarding whether they'd like the target player to be removed from their current faction or if they'd like to cancel the action.</issue_description>

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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 13, 2025 05:34
…in faction

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copilot AI changed the title [WIP] Prompt user about faction removal on addmember command Prompt for confirmation when addmember targets player already in faction Dec 13, 2025
Copy link

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 adds confirmation prompts when using the addmember command to add a player who is already in another faction. Previously, the command would reject such attempts. Now it prompts the admin for confirmation and provides a force flag (-f) to complete the operation.

Changes:

  • Added force flag (-f) handling to allow bypassing the confirmation prompt and forcefully moving players between factions
  • Implemented confirmAddMember() method that displays interactive buttons for confirming or canceling the operation
  • Added 8 new localization keys for confirmation messages, though translations are only complete for English variants

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/main/kotlin/com/dansplugins/factionsystem/command/faction/addmember/MfFactionAddMemberCommand.kt Added force flag handling, confirmation flow, and logic to remove players from their current faction before adding to target faction
src/main/resources/lang/lang_en_US.properties Added 8 English (US) localization keys for the confirmation feature
src/main/resources/lang/lang_en_GB.properties Added 8 English (GB) localization keys for the confirmation feature
src/main/resources/lang/lang_fr_FR.properties Added 8 localization key entries, but content is in English instead of French
src/main/resources/lang/lang_pt_BR.properties Added 8 localization key entries, but content is in English instead of Portuguese
src/main/resources/lang/lang_de_DE.properties Added 8 localization key entries, but content is in English instead of German
Comments suppressed due to low confidence (1)

src/main/kotlin/com/dansplugins/factionsystem/command/faction/addmember/MfFactionAddMemberCommand.kt:110

  • The target faction member limit check occurs after attempting to remove the player from their current faction. This creates a scenario where a player could be removed from their current faction, but then the add operation fails due to the target faction being full, leaving the player in no faction at all. The member limit check should be performed before removing the player from their current faction to ensure the operation can complete successfully. Move lines 106-110 to before line 86.
        val maxMembers = plugin.config.getInt("factions.maxMembers")
        if (maxMembers > 0 && targetFaction.members.size >= maxMembers) {
            sender.sendMessage("${ChatColor.RED}${plugin.language["CommandFactionAddMemberTargetFactionFull"]}")
            return true
        }

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

Comment on lines 1064 to 1071
CommandFactionAddMemberConfirmRemoval={0} is currently in {1}. Do you want to remove them and add them to {2}?
CommandFactionAddMemberConfirmButton=[Confirm]
CommandFactionAddMemberConfirmButtonHover=Click to confirm and remove the player from their current faction
CommandFactionAddMemberCancelButton=[Cancel]
CommandFactionAddMemberCancelButtonHover=Click to cancel
CommandFactionAddMemberFailedToRemoveFromCurrentFaction=Failed to remove player from their current faction.
CommandFactionAddMemberRemovedFromFactionTitle={0} was removed from the faction
CommandFactionAddMemberRemovedFromFactionBody={0} was forcefully removed from the 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 new language keys added for confirmation messages are in English only, while the other language files (French, Portuguese BR, German) should have these translated. Currently, lines 1064-1071 in lang_fr_FR.properties, lang_pt_BR.properties, and lang_de_DE.properties contain English text instead of French, Portuguese, and German translations respectively.

Suggested change
CommandFactionAddMemberConfirmRemoval={0} is currently in {1}. Do you want to remove them and add them to {2}?
CommandFactionAddMemberConfirmButton=[Confirm]
CommandFactionAddMemberConfirmButtonHover=Click to confirm and remove the player from their current faction
CommandFactionAddMemberCancelButton=[Cancel]
CommandFactionAddMemberCancelButtonHover=Click to cancel
CommandFactionAddMemberFailedToRemoveFromCurrentFaction=Failed to remove player from their current faction.
CommandFactionAddMemberRemovedFromFactionTitle={0} was removed from the faction
CommandFactionAddMemberRemovedFromFactionBody={0} was forcefully removed from the faction.
CommandFactionAddMemberConfirmRemoval={0} est actuellement dans {1}. Voulez-vous le retirer de {1} et l'ajouter � {2} ?
CommandFactionAddMemberConfirmButton=[Confirmer]
CommandFactionAddMemberConfirmButtonHover=Cliquez pour confirmer et retirer le joueur de sa faction actuelle
CommandFactionAddMemberCancelButton=[Annuler]
CommandFactionAddMemberCancelButtonHover=Cliquez pour annuler
CommandFactionAddMemberFailedToRemoveFromCurrentFaction=�chec de la suppression du joueur de sa faction actuelle.
CommandFactionAddMemberRemovedFromFactionTitle={0} a �t� retir� de la faction
CommandFactionAddMemberRemovedFromFactionBody={0} a �t� retir� de force de la faction.

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

Choose a reason for hiding this comment

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

French translations added in commit b32a3b0.

Comment on lines 1063 to 1070
CommandFactionAddMemberConfirmRemoval={0} is currently in {1}. Do you want to remove them and add them to {2}?
CommandFactionAddMemberConfirmButton=[Confirm]
CommandFactionAddMemberConfirmButtonHover=Click to confirm and remove the player from their current faction
CommandFactionAddMemberCancelButton=[Cancel]
CommandFactionAddMemberCancelButtonHover=Click to cancel
CommandFactionAddMemberFailedToRemoveFromCurrentFaction=Failed to remove player from their current faction.
CommandFactionAddMemberRemovedFromFactionTitle={0} was removed from the faction
CommandFactionAddMemberRemovedFromFactionBody={0} was forcefully removed from the 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 new language keys added for confirmation messages are in English only and should be translated to Portuguese (BR). Currently, lines 1064-1071 contain English text instead of Portuguese translations.

Suggested change
CommandFactionAddMemberConfirmRemoval={0} is currently in {1}. Do you want to remove them and add them to {2}?
CommandFactionAddMemberConfirmButton=[Confirm]
CommandFactionAddMemberConfirmButtonHover=Click to confirm and remove the player from their current faction
CommandFactionAddMemberCancelButton=[Cancel]
CommandFactionAddMemberCancelButtonHover=Click to cancel
CommandFactionAddMemberFailedToRemoveFromCurrentFaction=Failed to remove player from their current faction.
CommandFactionAddMemberRemovedFromFactionTitle={0} was removed from the faction
CommandFactionAddMemberRemovedFromFactionBody={0} was forcefully removed from the faction.
CommandFactionAddMemberConfirmRemoval={0} atualmente está em {1}. Deseja removê-lo(a) e adicioná-lo(a) a {2}?
CommandFactionAddMemberConfirmButton=[Confirmar]
CommandFactionAddMemberConfirmButtonHover=Clique para confirmar e remover o jogador da facção atual
CommandFactionAddMemberCancelButton=[Cancelar]
CommandFactionAddMemberCancelButtonHover=Clique para cancelar
CommandFactionAddMemberFailedToRemoveFromCurrentFaction=Falha ao remover o jogador da facção atual.
CommandFactionAddMemberRemovedFromFactionTitle={0} foi removido da facção
CommandFactionAddMemberRemovedFromFactionBody={0} foi removido(a) à força da facção.

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

Choose a reason for hiding this comment

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

Portuguese (BR) translations added in commit b32a3b0.

Comment on lines 1064 to 1071
CommandFactionAddMemberConfirmRemoval={0} is currently in {1}. Do you want to remove them and add them to {2}?
CommandFactionAddMemberConfirmButton=[Confirm]
CommandFactionAddMemberConfirmButtonHover=Click to confirm and remove the player from their current faction
CommandFactionAddMemberCancelButton=[Cancel]
CommandFactionAddMemberCancelButtonHover=Click to cancel
CommandFactionAddMemberFailedToRemoveFromCurrentFaction=Failed to remove player from their current faction.
CommandFactionAddMemberRemovedFromFactionTitle={0} was removed from the faction
CommandFactionAddMemberRemovedFromFactionBody={0} was forcefully removed from the 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 new language keys added for confirmation messages are in English only and should be translated to German. Currently, lines 1064-1071 contain English text instead of German translations.

Suggested change
CommandFactionAddMemberConfirmRemoval={0} is currently in {1}. Do you want to remove them and add them to {2}?
CommandFactionAddMemberConfirmButton=[Confirm]
CommandFactionAddMemberConfirmButtonHover=Click to confirm and remove the player from their current faction
CommandFactionAddMemberCancelButton=[Cancel]
CommandFactionAddMemberCancelButtonHover=Click to cancel
CommandFactionAddMemberFailedToRemoveFromCurrentFaction=Failed to remove player from their current faction.
CommandFactionAddMemberRemovedFromFactionTitle={0} was removed from the faction
CommandFactionAddMemberRemovedFromFactionBody={0} was forcefully removed from the faction.
CommandFactionAddMemberConfirmRemoval={0} ist derzeit Mitglied von {1}. M�chtest du ihn aus dieser Fraktion entfernen und zu {2} hinzuf�gen?
CommandFactionAddMemberConfirmButton=[Best�tigen]
CommandFactionAddMemberConfirmButtonHover=Klicken, um zu best�tigen und den Spieler aus seiner aktuellen Fraktion zu entfernen
CommandFactionAddMemberCancelButton=[Abbrechen]
CommandFactionAddMemberCancelButtonHover=Klicken, um abzubrechen
CommandFactionAddMemberFailedToRemoveFromCurrentFaction=Spieler konnte nicht aus seiner aktuellen Fraktion entfernt werden.
CommandFactionAddMemberRemovedFromFactionTitle={0} wurde aus der Fraktion entfernt
CommandFactionAddMemberRemovedFromFactionBody={0} wurde zwangsweise aus der Fraktion entfernt.

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

Choose a reason for hiding this comment

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

German translations added in commit b32a3b0.

Comment on lines 42 to 47
val force = if (args.lastOrNull() == "-f") {
lastArgOffset = 1
true
} else {
false
}
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 force flag is accepted without validating that the sender has the appropriate permission. In MfFactionJoinCommand.kt (lines 31-38), the pattern is to check hasUninvitedJoinPermission before accepting the force flag. Similarly, here the force flag should only be accepted if the sender has the required permission, otherwise users could attempt to use the flag inappropriately. The force flag check should be: val force = if (sender.hasPermission("mf.force.addmember") || sender.hasPermission("mf.force.join")) && args.lastOrNull() == "-f")

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

Choose a reason for hiding this comment

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

Permission check added for force flag following the MfFactionJoinCommand pattern in commit b32a3b0. Now only users with mf.force.addmember or mf.force.join permission can use the -f flag.

updatedCurrentFaction.sendMessage(
plugin.language["CommandFactionAddMemberRemovedFromFactionTitle", targetName],
plugin.language["CommandFactionAddMemberRemovedFromFactionBody", targetName]
)
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.

When a player is forcibly removed from their current faction before being added to a new faction, the target player should be notified about this removal. The current implementation only notifies the old faction members but doesn't send a message to the target player themselves. Consider sending a direct message to the target player (if online) informing them that they have been moved from one faction to another.

Suggested change
)
)
// Notify target player (if online) about being moved from one faction to another
val targetPlayer = plugin.server.getPlayer(targetMfPlayer.id)
if (targetPlayer != null) {
targetPlayer.sendMessage(
"${ChatColor.YELLOW}" +
"You have been moved from faction ${currentFaction.name} to faction ${targetFaction.name}."
)
}

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

Choose a reason for hiding this comment

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

Target player notification added in commit b32a3b0. If the target player is online, they now receive a message: "You have been moved from faction {old} to faction {new}." with localized versions in all supported languages.

return true
}
// Notify old faction
var targetName = targetMfPlayer.name ?: plugin.language["CommandFactionAddMemberUnknownNewPlayerFaction"]
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 variable targetName is declared as var but should be declared as val since it's never reassigned. On line 98, you retrieve the name or set a default, but you don't reassign it later. Using val instead of var is more idiomatic in Kotlin for immutable references.

Suggested change
var targetName = targetMfPlayer.name ?: plugin.language["CommandFactionAddMemberUnknownNewPlayerFaction"]
val targetName = targetMfPlayer.name ?: plugin.language["CommandFactionAddMemberUnknownNewPlayerFaction"]

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

Choose a reason for hiding this comment

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

Changed to val in commit b32a3b0.

@dmccoystephenson
Copy link
Member

@copilot address comments

…ication, and code improvements

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.

2 participants