Skip to content

Commit

Permalink
Allowed operators to forcefully set roles. (#1669)
Browse files Browse the repository at this point in the history
Players are now able to forcefully set members' roles in other factions
if they are in bypass mode.

One translation key has been removed and another has been modified.

closes #1610
  • Loading branch information
dmccoystephenson authored Jan 5, 2023
1 parent 646424d commit 3d1f3bd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ class MfFactionRoleSetCommand(private val plugin: MedievalFactions) : CommandExe
return@Runnable
}
val factionService = plugin.services.factionService
val faction = factionService.getFaction(mfPlayer.id)
val faction = factionService.getFaction(targetMfPlayer.id)
if (faction == null) {
sender.sendMessage("$RED${plugin.language["CommandFactionRoleSetMustBeInAFaction"]}")
sender.sendMessage("$RED${plugin.language["CommandFactionRoleSetTargetMustBeInAFaction"]}")
return@Runnable
}
if (faction.members.none { it.playerId == targetMfPlayer.id }) {
Expand All @@ -68,9 +69,15 @@ class MfFactionRoleSetCommand(private val plugin: MedievalFactions) : CommandExe
sender.sendMessage("$RED${plugin.language["CommandFactionRoleSetInvalidTargetRole"]}")
return@Runnable
}
if (role == null || !role.hasPermission(faction, plugin.factionPermissions.setMemberRole(targetRole.id))) {
sender.sendMessage("$RED${plugin.language["CommandFactionRoleSetNoFactionPermission"]}")
return@Runnable
if (!mfPlayer.isBypassEnabled) {
if (role == null || !role.hasPermission(
faction,
plugin.factionPermissions.setMemberRole(targetRole.id)
)
) {
sender.sendMessage("$RED${plugin.language["CommandFactionRoleSetNoFactionPermission"]}")
return@Runnable
}
}
factionService.save(
faction.copy(
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/lang/lang_de_DE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ CommandFactionRoleSetInvalidTarget=Ung
CommandFactionRoleSetFailedToSavePlayer=Fehlgeschlagen beim Speichern der Spielerinformationen.
CommandFactionRoleSetFailedToSaveTargetPlayer=Fehlgeschlagen beim Speichern der Zielspielerinformationen.
CommandFactionRoleSetCannotSetOwnRole=Du kannst deine eigene Rolle nicht einstellen.
CommandFactionRoleSetMustBeInAFaction=Du musst in einer Fraktion sein, um die Rolle eines Mitglieds zu setzen.
CommandFactionRoleSetTargetMustBeInAFaction=Du musst einer Fraktion angehören, um die Rolle eines Mitglieds festzulegen.
CommandFactionRoleSetTargetMustBeInFaction=Dieser Spieler ist nicht in deiner Fraktion.
CommandFactionRoleSetInvalidTargetRole=Es gibt in dieser Fraktion keine Rolle mit diesem Namen.
CommandFactionRoleSetNoFactionPermission=Deine Rolle in dieser Fraktion gibt dir nicht das Recht, die Rollen der Mitglieder zu setzen.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/lang/lang_en_GB.properties
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ CommandFactionRoleSetInvalidTarget=Invalid target.
CommandFactionRoleSetFailedToSavePlayer=Failed to save player information.
CommandFactionRoleSetFailedToSaveTargetPlayer=Failed to save target player information.
CommandFactionRoleSetCannotSetOwnRole=You cannot set your own role.
CommandFactionRoleSetMustBeInAFaction=You must be in a faction to set a member''s role.
CommandFactionRoleSetTargetMustBeInAFaction=You must be in a faction to set a member''s role.
CommandFactionRoleSetTargetMustBeInFaction=That player is not in your faction.
CommandFactionRoleSetInvalidTargetRole=There is no role in this faction by that name.
CommandFactionRoleSetNoFactionPermission=Your role in this faction does not grant you permission to set members'' roles.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/lang/lang_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ CommandFactionRoleSetInvalidTarget=Invalid target.
CommandFactionRoleSetFailedToSavePlayer=Failed to save player information.
CommandFactionRoleSetFailedToSaveTargetPlayer=Failed to save target player information.
CommandFactionRoleSetCannotSetOwnRole=You cannot set your own role.
CommandFactionRoleSetMustBeInAFaction=You must be in a faction to set a member''s role.
CommandFactionRoleSetTargetMustBeInAFaction=You must be in a faction to set a member''s role.
CommandFactionRoleSetTargetMustBeInFaction=That player is not in your faction.
CommandFactionRoleSetInvalidTargetRole=There is no role in this faction by that name.
CommandFactionRoleSetNoFactionPermission=Your role in this faction does not grant you permission to set members'' roles.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/lang/lang_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ CommandFactionRoleSetInvalidTarget=Cible non valide.
CommandFactionRoleSetFailedToSavePlayer=Échec de la sauvegarde des informations relatives au joueur.
CommandFactionRoleSetFailedToSaveTargetPlayer=Échec de l''enregistrement des informations relatives au joueur cible.
CommandFactionRoleSetCannotSetOwnRole=Vous ne pouvez pas définir votre propre rôle.
CommandFactionRoleSetMustBeInAFaction=Vous devez faire partie d''une faction pour définir le rôle d''un membre.
CommandFactionRoleSetTargetMustBeInAFaction=Vous devez appartenir à une faction pour définir le rôle d''un membre.
CommandFactionRoleSetTargetMustBeInFaction=Ce joueur ne fait pas partie de votre faction.
CommandFactionRoleSetInvalidTargetRole=Il n''existe pas de rôle de ce nom dans cette faction.
CommandFactionRoleSetNoFactionPermission=Votre rôle dans cette faction ne vous donne pas la permission de définir les rôles des membres.
Expand Down

0 comments on commit 3d1f3bd

Please sign in to comment.