Skip to content
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

New Config Option - factions.maxMembers #1722

Merged
merged 3 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class MfFactionAddMemberCommand(private val plugin: MedievalFactions) : CommandE
return true
}

val maxMembers = plugin.config.getInt("factions.maxMembers")
if (maxMembers > 0 && targetFaction.members.size >= maxMembers) {
sender.sendMessage("${ChatColor.RED}${plugin.language["CommandFactionAddMemberTargetFactionFull"]}")
return true
}

// add member to faction
val updatedFaction = factionService.save(
targetFaction.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class MfFactionInviteCommand(private val plugin: MedievalFactions) : CommandExec
sender.sendMessage("${BukkitChatColor.RED}${plugin.language["CommandFactionInviteAlreadyMember"]}")
return@Runnable
}
val maxMembers = plugin.config.getInt("factions.maxMembers")
if (maxMembers > 0 && faction.members.size >= maxMembers) {
sender.sendMessage("${BukkitChatColor.RED}${plugin.language["CommandFactionInviteFactionFull"]}")
return@Runnable
}
factionService.save(
faction.copy(
invites = faction.invites + MfFactionInvite(targetMfPlayer.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ class MfFactionJoinCommand(private val plugin: MedievalFactions) : CommandExecut
}
return@Runnable
}
val maxMembers = plugin.config.getInt("factions.maxMembers")
if (maxMembers > 0 && faction.members.size >= maxMembers) {
sender.sendMessage("$RED${plugin.language["CommandFactionJoinFactionFull"]}")
return@Runnable
}
val updatedFaction = factionService.save(
faction.copy(
members = faction.members + MfFactionMember(mfPlayer.id, faction.roles.default),
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ factions:
allowNeutrality: false
factionlessFactionName: Factionless
factionHomeTeleportDelay: 5
maxMembers: -1
defaults:
flags:
alliesCanInteractWithLand: false
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/lang/lang_de_DE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1066,5 +1066,8 @@ CommandFactionAddMemberUnknownNewPlayerFaction=Unbekanntes neues Mitglied
CommandFactionAddMemberSuccess=Dieser Spieler ist jetzt Mitglied der angegebenen Fraktion.
CommandFactionHelpAddMember=/faction addmember <player> <faction> - F�gt zwangsweise ein Mitglied zu einer Fraktion hinzu.
CommandFactionRoleSetPermissionCannotModifyRolePermissionToModifyOwnRolePermission=Du kannst die Berechtigung deiner Rolle nicht �ndern, um die Berechtigungen deiner eigenen Rolle zu �ndern.
CommandFactionInviteFactionFull=Die Fraktion, zu der du diesen Spieler einladen m�chtest, ist voll.
CommandFactionJoinFactionFull=Die Fraktion, der du beitreten m�chtest, ist voll.
CommandFactionAddMemberTargetFactionFull=Die Fraktion, zu der du diesen Spieler hinzuf�gen m�chtest, ist voll.
PlayerInteractEntityFailedToSavePlayer=Der Spieler konnte nicht gespeichert werden.
PlayerInteractEntityCannotTradeWithVillager=Du kannst nicht mit diesem Dorfbewohner handeln.
3 changes: 3 additions & 0 deletions src/main/resources/lang/lang_en_GB.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1068,5 +1068,8 @@ CommandFactionInfoAlliesTitle=Allies:
CommandFactionInfoEnemiesTitle=Enemies:
BlockNotLocked=That block is not locked.
CommandFactionRoleSetPermissionCannotModifyRolePermissionToModifyOwnRolePermission=You cannot modify your role''s permission to modify your own role''s permissions.
CommandFactionInviteFactionFull=You cannot invite any more members to your faction.
CommandFactionJoinFactionFull=The faction you are trying to join is full.
CommandFactionAddMemberTargetFactionFull=The faction you are trying to add a member to is full.
PlayerInteractEntityFailedToSavePlayer=Failed to save player.
PlayerInteractEntityCannotTradeWithVillager=You cannot trade with this villager.
4 changes: 4 additions & 0 deletions src/main/resources/lang/lang_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1068,5 +1068,9 @@ CommandFactionInfoVassalsTitle=Vassals:
CommandFactionInfoAlliesTitle=Allies:
CommandFactionInfoEnemiesTitle=Enemies:
CommandFactionRoleSetPermissionCannotModifyRolePermissionToModifyOwnRolePermission=You cannot modify your role''s permission to modify your own role''s permissions.
CommandFactionInviteFactionFull=You cannot invite any more members to your faction.
CommandFactionJoinFactionFull=The faction you are trying to join is full.
CommandFactionAddMemberTargetFactionFull=The faction you are trying to add a member to is full.

PlayerInteractEntityFailedToSavePlayer=Failed to save player.
PlayerInteractEntityCannotTradeWithVillager=You cannot trade with this villager.
3 changes: 3 additions & 0 deletions src/main/resources/lang/lang_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1068,5 +1068,8 @@ CommandFactionAddMemberSuccess=Ce joueur est maintenant membre de la faction sp
CommandFactionHelpAddMember=/faction addmember <joueur> <faction> - Ajoute de force un membre � une faction.
BlockNotLocked=Ce bloc n'est pas verrouill�.
CommandFactionRoleSetPermissionCannotModifyRolePermissionToModifyOwnRolePermission=Vous ne pouvez pas modifier les autorisations de votre r\u00e9le pour modifier les autorisations de votre propre r\u00e9le.
CommandFactionInviteFactionFull=La faction est pleine.
CommandFactionJoinFactionFull=La faction est pleine.
CommandFactionAddMemberTargetFactionFull=La faction est pleine.
PlayerInteractEntityFailedToSavePlayer=Impossible de sauvegarder le joueur.
PlayerInteractEntityCannotTradeWithVillager=Vous ne pouvez pas commercer avec ce villageois.