Skip to content

Commit

Permalink
Bugfixes for private chat #131
Browse files Browse the repository at this point in the history
Private chat toggle is no longer active when the player is not married
Private chat target will be removed when a player gets divorced from the current target
Private chat no longer sends commands as private chat messages on BungeeCord
  • Loading branch information
GeorgH93 committed Apr 19, 2020
1 parent 573ffdd commit 0984d1c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public List<HelpData> getHelp(@NotNull CommandSender requester)
@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(ChatEvent event)
{
if(!(event.getSender() instanceof ProxiedPlayer)) return;
if(!(event.getSender() instanceof ProxiedPlayer) || event.isCommand()) return;
MarriagePlayer player = getMarriagePlugin().getPlayerData((ProxiedPlayer) event.getSender());
if(player.isPrivateChatDefault())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class MarriagePlayerDataBase<MARRIAGE_PLAYER extends MarriagePla
@Getter private boolean married = false;
@Getter @Setter private Object databaseKey = null;
private MARRIAGE privateChatTarget = null;
private Map<MARRIAGE_PLAYER, MARRIAGE> partnersMarriages = new ConcurrentHashMap<>();
private final Map<MARRIAGE_PLAYER, MARRIAGE> partnersMarriages = new ConcurrentHashMap<>();

//region Constructor
protected MarriagePlayerDataBase(final @Nullable UUID uuid, final @NotNull String name)
Expand Down Expand Up @@ -100,6 +100,7 @@ public void removeMarriage(MARRIAGE marriage)
{
partnersMarriages.remove(marriage.getPartner(this));
married = partnersMarriages.size() > 0;
if(privateChatTarget.equals(marriage)) privateChatTarget = null;
}
//endregion

Expand Down Expand Up @@ -153,7 +154,7 @@ public void setPrivateChatDefault(boolean enable)
@Override
public boolean isPrivateChatDefault()
{
return privateChat;
return privateChat && isMarried();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<packaging>pom</packaging>

<properties>
<revision>2.1.6-RC1</revision>
<revision>2.1.6</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Expand Down

0 comments on commit 0984d1c

Please sign in to comment.