|
5 | 5 | import dev.peri.yetanothermessageslibrary.util.TriFunction; |
6 | 6 | import dev.peri.yetanothermessageslibrary.viewer.Viewer; |
7 | 7 | import dev.peri.yetanothermessageslibrary.viewer.ViewerService; |
8 | | -import org.jetbrains.annotations.Contract; |
9 | | -import org.jetbrains.annotations.NotNull; |
10 | | -import org.jetbrains.annotations.Nullable; |
11 | | - |
12 | | -import java.util.*; |
| 8 | +import java.util.ArrayList; |
| 9 | +import java.util.Collection; |
| 10 | +import java.util.Collections; |
| 11 | +import java.util.HashSet; |
| 12 | +import java.util.List; |
| 13 | +import java.util.Locale; |
| 14 | +import java.util.Map; |
| 15 | +import java.util.Objects; |
| 16 | +import java.util.Set; |
| 17 | +import java.util.WeakHashMap; |
13 | 18 | import java.util.function.Consumer; |
14 | 19 | import java.util.function.Function; |
15 | 20 | import java.util.function.Predicate; |
16 | 21 | import java.util.function.Supplier; |
| 22 | +import org.jetbrains.annotations.Contract; |
| 23 | +import org.jetbrains.annotations.NotNull; |
| 24 | +import org.jetbrains.annotations.Nullable; |
17 | 25 |
|
18 | 26 | @SuppressWarnings("unchecked") |
19 | 27 | public class MessageDispatcher<R, D extends MessageDispatcher<R, ?>> { |
@@ -160,6 +168,15 @@ public <T extends R> D with( |
160 | 168 | return this.with(requiredType, replacementSupplier, null); |
161 | 169 | } |
162 | 170 |
|
| 171 | + @Contract("_, _ -> this") |
| 172 | + public <T extends R> D with( |
| 173 | + @NotNull Class<T> requiredType, |
| 174 | + @NotNull Collection<Function<@NotNull T, ? extends @NotNull Replaceable>> replacementSuppliers |
| 175 | + ) { |
| 176 | + replacementSuppliers.forEach(replacementSupplier -> this.with(requiredType, replacementSupplier)); |
| 177 | + return (D) this; |
| 178 | + } |
| 179 | + |
163 | 180 | @Contract(" -> this") |
164 | 181 | public D send() { |
165 | 182 | this.receivers.forEach(this::sendTo); |
|
0 commit comments