From 1ed7bca0e401235412ab22f894bf299522a553b0 Mon Sep 17 00:00:00 2001 From: dmccoystephenson Date: Sun, 7 May 2023 01:16:27 -0600 Subject: [PATCH 1/2] Added unique name check to `set name` command. --- .../command/faction/set/name/MfFactionSetNameCommand.kt | 4 ++++ src/main/resources/lang/lang_en_GB.properties | 1 + src/main/resources/lang/lang_en_US.properties | 1 + 3 files changed, 6 insertions(+) diff --git a/src/main/kotlin/com/dansplugins/factionsystem/command/faction/set/name/MfFactionSetNameCommand.kt b/src/main/kotlin/com/dansplugins/factionsystem/command/faction/set/name/MfFactionSetNameCommand.kt index 9264d44b..21c58fc7 100644 --- a/src/main/kotlin/com/dansplugins/factionsystem/command/faction/set/name/MfFactionSetNameCommand.kt +++ b/src/main/kotlin/com/dansplugins/factionsystem/command/faction/set/name/MfFactionSetNameCommand.kt @@ -108,6 +108,10 @@ class MfFactionSetNameCommand(private val plugin: MedievalFactions) : CommandExe player.sendMessage("$RED${plugin.language["CommandFactionSetNameNoFactionPermission"]}") return@Runnable } + if (factionService.getFaction(name) != null) { + player.sendMessage("$RED${plugin.language["CommandFactionSetNameFactionAlreadyExists"]}") + return@Runnable + } val updatedFaction = factionService.save(faction.copy(name = name)).onFailure { player.sendMessage("$RED${plugin.language["CommandFactionSetNameFailedToSaveFaction"]}") plugin.logger.log(Level.SEVERE, "Failed to save faction: ${it.reason.message}", it.reason.cause) diff --git a/src/main/resources/lang/lang_en_GB.properties b/src/main/resources/lang/lang_en_GB.properties index 4d8ab802..7339f499 100644 --- a/src/main/resources/lang/lang_en_GB.properties +++ b/src/main/resources/lang/lang_en_GB.properties @@ -515,6 +515,7 @@ CommandFactionSetNameNameTooLong=You cannot have a faction name longer than {0} CommandFactionSetNameNoFactionPermission=Your role in this faction does not grant you permission to change its name. CommandFactionSetNameFailedToSaveFaction=Failed to save faction. CommandFactionSetNameSuccess=Faction name set to {0}. +CommandFactionSetNameFactionAlreadyExists=A faction by that name already exists. CommandFactionSetPrefixNotAPlayer=You must be a player in order to set your faction''s prefix CommandFactionSetPrefixOperationCancelled=Operation cancelled. CommandFactionSetPrefixPrefixPrompt=Enter the new prefix of the faction, or type ''{0}'' to cancel. diff --git a/src/main/resources/lang/lang_en_US.properties b/src/main/resources/lang/lang_en_US.properties index 39d6fe28..89ffa1af 100644 --- a/src/main/resources/lang/lang_en_US.properties +++ b/src/main/resources/lang/lang_en_US.properties @@ -515,6 +515,7 @@ CommandFactionSetNameNameTooLong=You cannot have a faction name longer than {0} CommandFactionSetNameNoFactionPermission=Your role in this faction does not grant you permission to change its name. CommandFactionSetNameFailedToSaveFaction=Failed to save faction. CommandFactionSetNameSuccess=Faction name set to {0}. +CommandFactionSetNameFactionAlreadyExists=A faction by that name already exists. CommandFactionSetPrefixNotAPlayer=You must be a player in order to set your faction''s prefix CommandFactionSetPrefixOperationCancelled=Operation cancelled. CommandFactionSetPrefixPrefixPrompt=Enter the new prefix of the faction, or type ''{0}'' to cancel. From f75959ef083f2fed3dbda2a5ea73d1b8b42b8e2b Mon Sep 17 00:00:00 2001 From: dmccoystephenson Date: Sun, 7 May 2023 01:21:20 -0600 Subject: [PATCH 2/2] Added german translations for `CommandFactionSetNameFactionAlreadyExists` translation key. --- src/main/resources/lang/lang_de_DE.properties | 1 + src/main/resources/lang/lang_fr_FR.properties | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/resources/lang/lang_de_DE.properties b/src/main/resources/lang/lang_de_DE.properties index 87498c3a..f2c91be5 100644 --- a/src/main/resources/lang/lang_de_DE.properties +++ b/src/main/resources/lang/lang_de_DE.properties @@ -513,6 +513,7 @@ CommandFactionSetNameNameTooLong=Dein Fraktionsname darf nicht l CommandFactionSetNameNoFactionPermission=Deine Rolle in dieser Fraktion gibt dir nicht die Erlaubnis, ihren Namen zu ändern. CommandFactionSetNameFailedToSaveFaction=Fraktion konnte nicht gespeichert werden. CommandFactionSetNameSuccess=Fraktion-Name auf {0} gesetzt. +CommandFactionSetNameFactionAlreadyExists=Eine Fraktion mit diesem Namen existiert bereits. CommandFactionSetPrefixNotAPlayer=Du hast nicht die Erlaubnis, den Präfix deiner Fraktion zu setzen. CommandFactionSetPrefixOperationCancelled=Operation abgebrochen. CommandFactionSetPrefixPrefixPrompt=Gib den neuen Präfix der Fraktion ein oder gib ''{0}'' ein, um abzubrechen. diff --git a/src/main/resources/lang/lang_fr_FR.properties b/src/main/resources/lang/lang_fr_FR.properties index b8d79568..8eac1ede 100644 --- a/src/main/resources/lang/lang_fr_FR.properties +++ b/src/main/resources/lang/lang_fr_FR.properties @@ -515,6 +515,7 @@ CommandFactionSetNameNameTooLong=Le nom de votre faction ne peut pas d CommandFactionSetNameNoFactionPermission=Votre rôle dans cette faction ne vous donne pas le droit de changer son nom. CommandFactionSetNameFailedToSaveFaction=Échec de l''enregistrement de la faction. CommandFactionSetNameSuccess=Le nom de la faction est réglé sur {0}. +CommandFactionSetNameFactionAlreadyExists=Une faction de ce nom existe déjà. CommandFactionSetPrefixNotAPlayer=Vous devez être un joueur pour pouvoir définir le préfixe de votre faction. CommandFactionSetPrefixOperationCancelled=Opération annulée. CommandFactionSetPrefixPrefixPrompt=Entrez le nouveau préfixe de la faction, ou tapez ''{0}'' pour annuler.