Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Chat: fix noRecipient message to be after main message
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Dec 22, 2023
1 parent 51d6e32 commit c0664ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,22 @@ public void playerChatEvent(@NotNull AsyncPlayerChatEvent event) {
String chatFormat = config.getVaultString(sender, getModule() + ".list." + playerChat + ".format");
chatFormat = MessageUtil.formatPlayerString(sender, chatFormat);

((ChatModule) getModule()).send(sender, recipientsList, message, chatFormat, featuresList);
List<Player> finalRecipientsList = recipientsList;
String finalPlayerChat1 = playerChat;
((ChatModule) getModule()).send(sender, recipientsList, message, chatFormat, featuresList, () -> {
finalRecipientsList.removeIf(player -> player.getGameMode() == GameMode.SPECTATOR);

boolean noRecipientsMessageEnabled = config.getVaultBoolean(sender, getModule() + ".list." + finalPlayerChat1 + ".no-recipients.enable");
if ((finalRecipientsList.isEmpty() || finalRecipientsList.size() == 1) && noRecipientsMessageEnabled) {
String recipientsEmpty = locale.getVaultString(sender, getModule() + ".no-recipients");
sender.sendMessage(MessageUtil.formatAll(sender, recipientsEmpty));
}
});

CommandSpy.send(sender, playerChat, recipientsList, CommandSpy.Type.DEFAULT, message);

fPlayer.playSound(sender, recipientsList, getModule() + "." + playerChat);

recipientsList.removeIf(player -> player.getGameMode() == GameMode.SPECTATOR);

boolean noRecipientsMessageEnabled = config.getVaultBoolean(sender, getModule() + ".list." + playerChat + ".no-recipients.enable");
if ((recipientsList.isEmpty() || recipientsList.size() == 1) && noRecipientsMessageEnabled) {
String recipientsEmpty = locale.getVaultString(sender, getModule() + ".no-recipients");
sender.sendMessage(MessageUtil.formatAll(sender, recipientsEmpty));
}

boolean isCancelled = config.getVaultBoolean(sender, getModule() + ".list." + playerChat + ".set-cancelled");
event.setCancelled(isCancelled);
event.setMessage(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void init() {

public void send(@NotNull Player sender, @NotNull List<Player> recipientsList,
@NotNull String message, @NotNull String chatFormat,
@NotNull List<String> featuresList) {
@NotNull List<String> featuresList, @NotNull Runnable noRecipientRunnable) {

message = IntegrationsModule.interactiveChatMark(message, sender.getUniqueId());

Expand All @@ -43,6 +43,8 @@ public void send(@NotNull Player sender, @NotNull List<Player> recipientsList,
if (fModule instanceof ChatBubbleModule chatBubbleModule) {
chatBubbleModule.add(sender, messageBuilder.getMessage(""));
}

noRecipientRunnable.run();
});
}
}

0 comments on commit c0664ab

Please sign in to comment.