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

Commit

Permalink
CommandTell: fix duplicated messages
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Dec 3, 2023
1 parent 7c07333 commit 71895fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/net/flectone/chat/module/FCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.flectone.chat.module;

import lombok.Getter;
import lombok.Setter;
import net.flectone.chat.FlectoneChat;
import net.flectone.chat.builder.MessageBuilder;
import net.flectone.chat.database.sqlite.Database;
Expand Down Expand Up @@ -42,6 +43,9 @@ public abstract class FCommand implements CommandExecutor, TabCompleter, FAction
private final String name;
private Command command;

@Setter
private boolean isSilent;

protected final FlectoneChat plugin;
protected final FPlayerManager playerManager;
protected final FModuleManager moduleManager;
Expand Down Expand Up @@ -150,12 +154,14 @@ public void sendGlobalMessage(@NotNull Collection<Player> recipients, @Nullable
@Nullable ItemStack itemStack, @NotNull String format,
@NotNull String message, boolean isClickable) {

FPlayer.sendToConsole(format
.replace("<message>", message)
.replace("<player>", player != null ? player.getName() : "CONSOLE"));

if (player != null) {
message = IntegrationsModule.interactiveChatMark(message, player.getUniqueId());
}

if (!isSilent) {
FPlayer.sendToConsole(format
.replace("<message>", message)
.replace("<player>", player != null ? player.getName() : "CONSOLE"));
sendToSpy(player, recipients, CommandSpy.Type.DEFAULT, message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public void asyncOnCommand(@NotNull CommandSender commandSender, @NotNull Comman
sendGlobalMessage(new ArrayList<>(List.of(fReceiver.getPlayer())), cmdSettings.getSender(),
cmdSettings.getItemStack(), getMessage, message, true);

setSilent(true);

String sendMessage = locale.getVaultString(cmdSettings.getSender(), this + ".send");
sendMessage = MessageUtil.formatPlayerString(fReceiver.getPlayer(), sendMessage);

Expand Down

0 comments on commit 71895fa

Please sign in to comment.