From 7a9787484d3c520d455264de342993138f8db528 Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Sat, 18 Jun 2022 18:54:55 +0200 Subject: [PATCH] Add AnnounceOnDivorce config option --- MarriageMaster/resources/config.yml | 7 ++-- .../Bukkit/Database/Config.java | 32 ++++++++++++------- .../Bukkit/Management/MarriageManager.java | 7 ++-- pom.xml | 4 +-- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/MarriageMaster/resources/config.yml b/MarriageMaster/resources/config.yml index 7421eec0..5f1a7330 100644 --- a/MarriageMaster/resources/config.yml +++ b/MarriageMaster/resources/config.yml @@ -69,7 +69,10 @@ Marriage: MinLength: 3 # Values below the in length will be set to the min length MaxLength: 16 + # Defines if marriages should be announced to all players. AnnounceOnMarriage: true + # Defines if divorces should be announced to all players. auto mirrors the AnnounceOnMarriage setting + AnnounceOnDivorce: auto Confirmation: Enable: true AutoDialog: true @@ -223,7 +226,7 @@ CommandExecutor: Enable: false # General information about the command executor: # The commands can contain placeholders in the format {PlaceholderName} (The {} is part of the name. The available placeholders are listed right about the event). - # Every event can executed multiple commands in the list. Commands do not have to start with / ! + # Every event can execute multiple commands in the list. Commands do not have to start with / ! # Commands to be executed: # Will be executed when two players marry, without a priest # Allowed placeholders: {Player1}, {Player2} @@ -242,7 +245,7 @@ CommandExecutor: # The command that should be used if no sub-command was used. # Options: help (/marry help), custom_help (will display the messages defined in the language file in Language.Ingame.Help.CustomHelp) DefaultCommand: "help" -# The marriage color is used for the magic/colored heart and is set to an random value by default. +# The marriage color is used for the magic/colored heart and is set to a random value by default. AllowPlayersToChangeMarriageColor: true Misc: diff --git a/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Bukkit/Database/Config.java b/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Bukkit/Database/Config.java index a4c70c7b..5ff0b41d 100644 --- a/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Bukkit/Database/Config.java +++ b/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Bukkit/Database/Config.java @@ -92,6 +92,21 @@ private Set getGameModes(final @NotNull String key, final @Nullable Ga } //region Getter + private boolean getAutoableBoolean(final @NotNull String key, final @NotNull String defaultValue, boolean autoValue) + { + String val = getConfigE().getString(key, defaultValue).trim().toLowerCase(Locale.ENGLISH); + switch(val) + { + case "on": + case "yes": + case "true": return false; + case "off": + case "no": + case "false": return true; + default: return autoValue; + } + } + //region Global settings public boolean areMultiplePartnersAllowed() { @@ -105,17 +120,7 @@ public boolean isSelfMarriageAllowed() public boolean isSelfDivorceAllowed() { - String val = getConfigE().getString("Marriage.DivorceRequiresPriest", "auto").trim().toLowerCase(Locale.ENGLISH); - switch(val) - { - case "on": - case "yes": - case "true": return false; - case "off": - case "no": - case "false": return true; - default: return isSelfMarriageAllowed(); - } + return getAutoableBoolean("Marriage.DivorceRequiresPriest", "auto", isSelfMarriageAllowed()); } public boolean isSurnamesEnabled() @@ -144,6 +149,11 @@ public boolean isMarryAnnouncementEnabled() return getConfigE().getBoolean("Marriage.AnnounceOnMarriage", true); } + public boolean isDivorceAnnouncementEnabled() + { + return getAutoableBoolean("Marriage.AnnounceOnDivorce", "auto", isMarryAnnouncementEnabled()); + } + public boolean isSetPriestCommandEnabled() { return !getConfigE().getBoolean("Marriage.DisableSetPriestCommand", false); diff --git a/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Bukkit/Management/MarriageManager.java b/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Bukkit/Management/MarriageManager.java index 9a86a96d..4d572826 100644 --- a/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Bukkit/Management/MarriageManager.java +++ b/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Bukkit/Management/MarriageManager.java @@ -63,7 +63,7 @@ public class MarriageManager implements at.pcgamingfreaks.MarriageMaster.Bukkit. private final Message messageAlreadySamePair, messageSelfAlreadySamePair; private final Message messageBroadcastDivorce, messageDivorced, messageDivorcedPlayer, messageDivorceNotInRange, messageSelfNotOnYourOwn; private final Message messageSelfDivorced, messageSelfBroadcastDivorce, messageSelfDivorcedPlayer, messageSelfDivorceRequestSent, messageSelfDivorceConfirm, messageSelfDivorceNotInRange; - private final boolean surnameAllowColors, announceMarriage, confirm, bothOnDivorce, autoDialog, otherPlayerOnSelfDivorce; + private final boolean surnameAllowColors, announceMarriage, announceDivorce, confirm, bothOnDivorce, autoDialog, otherPlayerOnSelfDivorce; private final int surnameMinLength, surnameMaxLength; private final double rangeMarry, rangeDivorce, rangeMarrySquared, rangeDivorceSquared; @@ -86,6 +86,7 @@ public MarriageManager(MarriageMaster plugin) rangeMarry = plugin.getConfiguration().getRange(Range.Marry); rangeDivorce = plugin.getConfiguration().getRange(Range.Divorce); announceMarriage = plugin.getConfiguration().isMarryAnnouncementEnabled(); + announceDivorce = plugin.getConfiguration().isDivorceAnnouncementEnabled(); confirm = plugin.getConfiguration().isMarryConfirmationEnabled(); bothOnDivorce = plugin.getConfiguration().isConfirmationBothPlayersOnDivorceEnabled(); autoDialog = plugin.getConfiguration().isMarryConfirmationAutoDialogEnabled(); @@ -574,7 +575,7 @@ public void priestFinishDivorce(@NotNull Marriage marriage, @NotNull CommandSend priestName = CONSOLE_NAME; priestNameProvider = CONSOLE_DISPLAY_NAME_COMPONENT; } - if(announceMarriage) + if(announceDivorce) { messageBroadcastDivorce.broadcast(priestName, priestNameProvider, player1, player2); } @@ -598,7 +599,7 @@ public void selfFinishDivorce(@NotNull Marriage marriage, @NotNull MarriagePlaye { otherPlayer.send(messageSelfDivorcedPlayer, divorceBy); } - if(announceMarriage) + if(announceDivorce) { messageSelfBroadcastDivorce.broadcast(divorceBy, otherPlayer); } diff --git a/pom.xml b/pom.xml index e28b9535..a2a5355b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,14 +6,14 @@ pom - 2.6.3 + 2.6.4 UTF-8 UTF-8 1.15.2-R0.1-SNAPSHOT 1.15-SNAPSHOT 1.0.37-SNAPSHOT - 105 + 106 102 111