-
Notifications
You must be signed in to change notification settings - Fork 33
Prompt for confirmation when addmember targets player already in faction #1919
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: develop
Are you sure you want to change the base?
Conversation
…in faction Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
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 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.
| 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. |
Copilot
AI
Feb 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 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.
| 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. |
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.
French translations added in commit b32a3b0.
| 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. |
Copilot
AI
Feb 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 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.
| 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. |
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.
Portuguese (BR) translations added in commit b32a3b0.
| 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. |
Copilot
AI
Feb 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 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.
| 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. |
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.
German translations added in commit b32a3b0.
| val force = if (args.lastOrNull() == "-f") { | ||
| lastArgOffset = 1 | ||
| true | ||
| } else { | ||
| false | ||
| } |
Copilot
AI
Feb 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 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")
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.
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] | ||
| ) |
Copilot
AI
Feb 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.
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.
| ) | |
| ) | |
| // 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}." | |
| ) | |
| } |
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.
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"] |
Copilot
AI
Feb 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 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.
| var targetName = targetMfPlayer.name ?: plugin.language["CommandFactionAddMemberUnknownNewPlayerFaction"] | |
| val targetName = targetMfPlayer.name ?: plugin.language["CommandFactionAddMemberUnknownNewPlayerFaction"] |
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.
Changed to val in commit b32a3b0.
|
@copilot address comments |
…ication, and code improvements Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Implementation Complete ✅
Summary
Modified the
/mf addmembercommand 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)
-f) - only users withmf.force.addmemberormf.force.joincan use itvar targetNametoval targetNamefor better code qualityChanges Made
Code Changes
MfFactionJoinCommandpattern)confirmAddMember()method to display clickable confirmation UILanguage Files
CommandFactionAddMemberConfirmRemoval: Main confirmation messageCommandFactionAddMemberConfirmButton: Confirm button textCommandFactionAddMemberConfirmButtonHover: Confirm button hover textCommandFactionAddMemberCancelButton: Cancel button textCommandFactionAddMemberCancelButtonHover: Cancel button hover textCommandFactionAddMemberFailedToRemoveFromCurrentFaction: Error messageCommandFactionAddMemberRemovedFromFactionTitle: Notification titleCommandFactionAddMemberRemovedFromFactionBody: Notification bodyCommandFactionAddMemberPlayerNotification: Message to target playerUser Experience Flow
mf.force.addmemberormf.force.joinpermission runs:/mf addmember Steve TheFaction/mf addmember Steve TheFaction -fTechnical Details
/faction joinwith permission-checked force flag)Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.