Skip to content

Commit

Permalink
fix: ignoring a player also hides mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
rexlManu committed Apr 2, 2024
1 parent f6e6c97 commit d350ef5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.inject.Singleton;
import de.rexlmanu.fairychat.plugin.Constants;
import de.rexlmanu.fairychat.plugin.configuration.PluginConfiguration;
import de.rexlmanu.fairychat.plugin.core.ignore.UserIgnoreService;
import de.rexlmanu.fairychat.plugin.integration.IntegrationRegistry;
import lombok.RequiredArgsConstructor;
import net.kyori.adventure.key.Key;
Expand All @@ -21,6 +22,7 @@ public class MentionService {
private final Provider<PluginConfiguration> configurationProvider;
private final MiniMessage miniMessage;
private final IntegrationRegistry registry;
private final UserIgnoreService userIgnoreService;

public Component checkMentions(Player viewer, Component message) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import de.rexlmanu.fairychat.plugin.configuration.PluginConfiguration;
import de.rexlmanu.fairychat.plugin.core.ignore.UserIgnoreService;
import de.rexlmanu.fairychat.plugin.core.mentions.MentionService;
import de.rexlmanu.fairychat.plugin.integration.IntegrationRegistry;
import de.rexlmanu.fairychat.plugin.integration.chat.PlaceholderSupport;
Expand Down Expand Up @@ -33,6 +34,7 @@ public class PlayerChatFormatRenderer implements ChatRenderer {
private final PermissionProvider permissionProvider;
private final MentionService mentionService;
private final IntegrationRegistry registry;
private final UserIgnoreService userIgnoreService;

@Named("colorMiniMessage")
private final MiniMessage colorMiniMessage;
Expand All @@ -48,6 +50,9 @@ public class PlayerChatFormatRenderer implements ChatRenderer {
if (!(viewer instanceof Player player)) {
return formattedMessage;
}
if (this.userIgnoreService.isIgnored(player.getUniqueId(), source.getUniqueId())) {
return formattedMessage;
}
return this.mentionService.checkMentions(player, formattedMessage);
}

Expand Down Expand Up @@ -106,7 +111,8 @@ public Component formatMessage(@NotNull Player source, @NotNull Component messag
.toList());

tagResolvers.add(Placeholder.component("message", message));
tagResolvers.add(Placeholder.unparsed("server_name", this.configurationProvider.get().serverName()));
tagResolvers.add(
Placeholder.unparsed("server_name", this.configurationProvider.get().serverName()));

return this.miniMessage.deserialize(chatFormat, TagResolver.resolver(tagResolvers));
}
Expand Down

0 comments on commit d350ef5

Please sign in to comment.