diff --git a/spigot/src/main/java/ru/brikster/chatty/chat/message/transform/stage/early/RecipientsWithRangeStrategy.java b/spigot/src/main/java/ru/brikster/chatty/chat/message/transform/stage/early/SpyModeStrategy.java similarity index 76% rename from spigot/src/main/java/ru/brikster/chatty/chat/message/transform/stage/early/RecipientsWithRangeStrategy.java rename to spigot/src/main/java/ru/brikster/chatty/chat/message/transform/stage/early/SpyModeStrategy.java index 46ff48c..fafe4c6 100644 --- a/spigot/src/main/java/ru/brikster/chatty/chat/message/transform/stage/early/RecipientsWithRangeStrategy.java +++ b/spigot/src/main/java/ru/brikster/chatty/chat/message/transform/stage/early/SpyModeStrategy.java @@ -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; @@ -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 { +public final class SpyModeStrategy implements MessageTransformStrategy { @Inject private PlayerDataRepository repository; @Override public @NotNull MessageTransformResult handle(MessageContext context) { - List recipients = Bukkit.getOnlinePlayers() - .stream() - .filter(recipient -> Ranges.isApplicable(context.getSender(), recipient, context.getChat().getRange())) - .collect(Collectors.toList()); + List recipients = new ArrayList<>(context.getRecipients()); - MessageTransformResultBuilder builder = MessageTransformResultBuilder.fromContext(context) - .withRecipients(recipients); + MessageTransformResultBuilder builder = MessageTransformResultBuilder.fromContext(context); List spies = new ArrayList<>(); if (context.getChat().isEnableSpy()) { @@ -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 diff --git a/spigot/src/main/java/ru/brikster/chatty/guice/GeneralGuiceModule.java b/spigot/src/main/java/ru/brikster/chatty/guice/GeneralGuiceModule.java index 399f8a3..c7c167b 100644 --- a/spigot/src/main/java/ru/brikster/chatty/guice/GeneralGuiceModule.java +++ b/spigot/src/main/java/ru/brikster/chatty/guice/GeneralGuiceModule.java @@ -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; @@ -134,7 +134,7 @@ protected void configure() { Multibinder> strategyMultibinder = Multibinder.newSetBinder(binder(), new TypeLiteral>() {}); // 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()) {