Skip to content

Commit

Permalink
Fix chats read permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Brikster committed Dec 19, 2023
1 parent 061ac29 commit 50dc8c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import ru.brikster.chatty.api.chat.message.context.MessageContext;
import ru.brikster.chatty.api.chat.message.strategy.MessageTransformStrategy;
import ru.brikster.chatty.api.chat.message.strategy.result.MessageTransformResult;
import ru.brikster.chatty.api.chat.range.Ranges;
import ru.brikster.chatty.chat.message.transform.result.MessageTransformResultBuilder;
import ru.brikster.chatty.repository.player.PlayerDataRepository;

Expand All @@ -16,22 +15,17 @@
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

@Singleton
public final class RecipientsWithRangeStrategy implements MessageTransformStrategy<String> {
public final class SpyModeStrategy implements MessageTransformStrategy<String> {

@Inject private PlayerDataRepository repository;

@Override
public @NotNull MessageTransformResult<String> handle(MessageContext<String> context) {
List<Player> recipients = Bukkit.getOnlinePlayers()
.stream()
.filter(recipient -> Ranges.isApplicable(context.getSender(), recipient, context.getChat().getRange()))
.collect(Collectors.toList());
List<Player> recipients = new ArrayList<>(context.getRecipients());

MessageTransformResultBuilder<String> builder = MessageTransformResultBuilder.<String>fromContext(context)
.withRecipients(recipients);
MessageTransformResultBuilder<String> builder = MessageTransformResultBuilder.fromContext(context);

List<Player> spies = new ArrayList<>();
if (context.getChat().isEnableSpy()) {
Expand All @@ -51,7 +45,9 @@ public final class RecipientsWithRangeStrategy implements MessageTransformStrate

repository.createOrUpdateUser(context.getSender().getUniqueId(), context.getSender().getName());

return builder.build();
return builder
.withRecipients(recipients)
.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
import ru.brikster.chatty.chat.message.transform.processor.MessageTransformStrategiesProcessor;
import ru.brikster.chatty.chat.message.transform.processor.MessageTransformStrategiesProcessorImpl;
import ru.brikster.chatty.chat.message.transform.stage.early.CooldownStrategy;
import ru.brikster.chatty.chat.message.transform.stage.early.RecipientsWithRangeStrategy;
import ru.brikster.chatty.chat.message.transform.stage.early.RemoveChatSymbolStrategy;
import ru.brikster.chatty.chat.message.transform.stage.early.SpyModeStrategy;
import ru.brikster.chatty.chat.message.transform.stage.early.moderation.AdModerationStrategyModeration;
import ru.brikster.chatty.chat.message.transform.stage.early.moderation.CapsModerationStrategy;
import ru.brikster.chatty.chat.message.transform.stage.early.moderation.SwearModerationStrategyModeration;
Expand Down Expand Up @@ -134,7 +134,7 @@ protected void configure() {
Multibinder<MessageTransformStrategy<?>> strategyMultibinder = Multibinder.newSetBinder(binder(), new TypeLiteral<MessageTransformStrategy<?>>() {});
// Early
strategyMultibinder.addBinding().to(RemoveChatSymbolStrategy.class);
strategyMultibinder.addBinding().to(RecipientsWithRangeStrategy.class);
strategyMultibinder.addBinding().to(SpyModeStrategy.class);
strategyMultibinder.addBinding().to(CooldownStrategy.class);

if (moderationConfig.getAdvertisement().isEnable()) {
Expand Down

0 comments on commit 50dc8c6

Please sign in to comment.