Skip to content

Commit

Permalink
Add AnnounceOnDivorce config option
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgH93 committed Jun 18, 2022
1 parent 0ec8a4f commit 7a97874
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
7 changes: 5 additions & 2 deletions MarriageMaster/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ private Set<GameMode> 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()
{
Expand All @@ -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()
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
Expand All @@ -598,7 +599,7 @@ public void selfFinishDivorce(@NotNull Marriage marriage, @NotNull MarriagePlaye
{
otherPlayer.send(messageSelfDivorcedPlayer, divorceBy);
}
if(announceMarriage)
if(announceDivorce)
{
messageSelfBroadcastDivorce.broadcast(divorceBy, otherPlayer);
}
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<packaging>pom</packaging>

<properties>
<revision>2.6.3</revision>
<revision>2.6.4</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<bukkitVersion>1.15.2-R0.1-SNAPSHOT</bukkitVersion>
<bungeeVersion>1.15-SNAPSHOT</bungeeVersion>
<pcgfPluginLibVersion>1.0.37-SNAPSHOT</pcgfPluginLibVersion>

<configFileVersion>105</configFileVersion>
<configFileVersion>106</configFileVersion>
<configFileVersionBungee>102</configFileVersionBungee>
<languageFileVersion>111</languageFileVersion>

Expand Down

0 comments on commit 7a97874

Please sign in to comment.