|
5 | 5 | import com.eternalcode.core.feature.warp.WarpService; |
6 | 6 | import com.eternalcode.core.injector.annotations.Inject; |
7 | 7 | import com.eternalcode.core.injector.annotations.lite.LiteArgument; |
| 8 | +import com.eternalcode.core.notice.EternalCoreBroadcast; |
| 9 | +import com.eternalcode.core.notice.NoticeService; |
8 | 10 | import com.eternalcode.core.translation.Translation; |
9 | 11 | import com.eternalcode.core.translation.TranslationManager; |
| 12 | +import com.eternalcode.core.viewer.Viewer; |
10 | 13 | import com.eternalcode.core.viewer.ViewerService; |
11 | 14 | import dev.rollczi.litecommands.argument.Argument; |
12 | 15 | import dev.rollczi.litecommands.argument.parser.ParseResult; |
|
20 | 23 | class WarpArgument extends AbstractViewerArgument<Warp> { |
21 | 24 |
|
22 | 25 | private final WarpService warpService; |
| 26 | + private final NoticeService noticeService; |
23 | 27 |
|
24 | 28 | @Inject |
25 | | - WarpArgument(WarpService warpService, TranslationManager translationManager, ViewerService viewerService) { |
| 29 | + WarpArgument( |
| 30 | + WarpService warpService, |
| 31 | + TranslationManager translationManager, |
| 32 | + ViewerService viewerService, |
| 33 | + NoticeService noticeService |
| 34 | + ) { |
26 | 35 | super(viewerService, translationManager); |
27 | 36 | this.warpService = warpService; |
| 37 | + this.noticeService = noticeService; |
28 | 38 | } |
29 | 39 |
|
30 | 40 | @Override |
31 | 41 | public ParseResult<Warp> parse(Invocation<CommandSender> invocation, String argument, Translation translation) { |
32 | 42 | Optional<Warp> warpOption = this.warpService.findWarp(argument); |
33 | 43 |
|
34 | 44 | return warpOption.map(ParseResult::success) |
35 | | - .orElseGet(() -> ParseResult.failure(translation.warp().notExist())); |
| 45 | + .orElseGet(() -> { |
| 46 | + EternalCoreBroadcast<Viewer, Translation, ?> warpNotExistNotice = this.noticeService.create() |
| 47 | + .sender(invocation.sender()) |
| 48 | + .notice(translation.warp().notExist()) |
| 49 | + .placeholder("{WARP}", argument); |
| 50 | + |
| 51 | + return ParseResult.failure(warpNotExistNotice); |
| 52 | + }); |
36 | 53 | } |
37 | 54 |
|
38 | 55 | @Override |
|
0 commit comments