@@ -51,7 +51,8 @@ public void send() throws InvalidPlayerError {
5151 final @ NotNull Optional <@ NotNull Player > recipientPlayer = Optional .ofNullable (this .recipient .getPlayer ());
5252
5353 sendMessage (sender , CloudnodeMSG .getInstance ().config ().outgoing (senderUsername , recipientUsername , message ));
54- setReplyTo (sender , recipient );
54+ if (senderPlayer .isPresent () && !Message .hasChannel (senderPlayer .get (), recipient ))
55+ setReplyTo (sender , recipient );
5556
5657 if (
5758 (recipientPlayer .isPresent () && Message .isIgnored (recipientPlayer .get (), sender ))
@@ -60,7 +61,8 @@ public void send() throws InvalidPlayerError {
6061 ) return ;
6162 sendMessage (recipient , CloudnodeMSG .getInstance ().config ()
6263 .incoming (senderUsername , recipientUsername , message ));
63- setReplyTo (recipient , sender );
64+ if (recipientPlayer .isPresent () && !Message .hasChannel (recipientPlayer .get (), sender ))
65+ setReplyTo (recipient , sender );
6466 }
6567
6668 public final static @ NotNull OfflinePlayer console = CloudnodeMSG .getInstance ().getServer ()
@@ -179,4 +181,15 @@ public static void exitChannel(final @NotNull Player player) {
179181 return Optional .ofNullable (player .getPersistentDataContainer ().get (CHANNEL_RECIPIENT , PersistentDataType .STRING ))
180182 .map (uuid -> CloudnodeMSG .getInstance ().getServer ().getOfflinePlayer (UUID .fromString (uuid )));
181183 }
184+
185+ /**
186+ * Check whether player has DM channel with recipient
187+ *
188+ * @param player The player
189+ * @param recipient The recipient
190+ */
191+ public static boolean hasChannel (final @ NotNull Player player , final @ NotNull OfflinePlayer recipient ) {
192+ final @ NotNull Optional <@ NotNull OfflinePlayer > channel = getChannel (player );
193+ return channel .isPresent () && channel .get ().getUniqueId ().equals (recipient .getUniqueId ());
194+ }
182195}
0 commit comments