diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/request/TpaCommand.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/request/TpaCommand.java index d07d78453..bbe0a703a 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/request/TpaCommand.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/request/TpaCommand.java @@ -1,6 +1,7 @@ package com.eternalcode.core.feature.teleport.request; import com.eternalcode.annotations.scan.command.DescriptionDocs; +import com.eternalcode.core.feature.ignore.IgnoreService; import com.eternalcode.core.injector.annotations.Inject; import com.eternalcode.core.notice.NoticeService; import dev.rollczi.litecommands.argument.Arg; @@ -8,17 +9,20 @@ import dev.rollczi.litecommands.command.permission.Permission; import dev.rollczi.litecommands.command.route.Route; import org.bukkit.entity.Player; +import panda.std.reactive.Completable; @Route(name = "tpa") @Permission("eternalcore.tpa") class TpaCommand { private final TeleportRequestService requestService; + private final IgnoreService ignoreService; private final NoticeService noticeService; @Inject - TpaCommand(TeleportRequestService requestService, NoticeService noticeService) { + TpaCommand(TeleportRequestService requestService, IgnoreService ignoreService, NoticeService noticeService) { this.requestService = requestService; + this.ignoreService = ignoreService; this.noticeService = noticeService; } @@ -26,14 +30,12 @@ class TpaCommand { @DescriptionDocs(description = "Send teleport request to player", arguments = "") void execute(Player player, @Arg Player target) { if (player.equals(target)) { - this.noticeService.player(player.getUniqueId(), translation -> translation.tpa().tpaSelfMessage()); return; } if (this.requestService.hasRequest(player.getUniqueId(), target.getUniqueId())) { - this.noticeService.player(player.getUniqueId(), translation -> translation.tpa().tpaAlreadySentMessage()); return; @@ -46,14 +48,29 @@ void execute(Player player, @Arg Player target) { .placeholder("{PLAYER}", target.getName()) .send(); - this.noticeService - .create() - .player(target.getUniqueId()) - .notice(translation -> translation.tpa().tpaReceivedMessage()) - .placeholder("{PLAYER}", player.getName()) - .send(); + this.isIgnoring(target, player).then((isIgnoring) -> { + if (isIgnoring) { + this.noticeService.create() + .player(player.getUniqueId()) + .notice(translation -> translation.tpa().tpaTargetIgnoresYou()) + .placeholder("{PLAYER}", target.getName()) + .send(); + + return; + } + + this.noticeService.create() + .player(target.getUniqueId()) + .notice(translation -> translation.tpa().tpaReceivedMessage()) + .placeholder("{PLAYER}", player.getName()) + .send(); + + this.requestService.createRequest(player.getUniqueId(), target.getUniqueId()); + }); + } - this.requestService.createRequest(player.getUniqueId(), target.getUniqueId()); + Completable isIgnoring(Player target, Player sender) { + return this.ignoreService.isIgnored(target.getUniqueId(), sender.getUniqueId()); } } diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java index d6e1477a3..34d5f563c 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java @@ -7,7 +7,6 @@ import org.bukkit.Material; import org.bukkit.event.entity.EntityDamageEvent; -import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; @@ -186,6 +185,7 @@ interface TpaSection { Notice tpaAlreadySentMessage(); Notice tpaSentMessage(); Notice tpaReceivedMessage(); + Notice tpaTargetIgnoresYou(); Notice tpaDenyNoRequestMessage(); Notice tpaDenyDoneMessage(); diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java index 546361c11..2eb5d1abf 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java @@ -320,6 +320,9 @@ public static class ENTpaSection implements TpaSection { @Description(" ") public Notice tpaAcceptAllAccepted = Notice.chat("All players have accepted your teleport request!"); + + @Description(" ") + public Notice tpaTargetIgnoresYou = Notice.chat("{PLAYER} is ignoring you!"); } @Description({ diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java index 172173621..2edf721f5 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java @@ -325,6 +325,9 @@ public static class PLTpaSection implements TpaSection { @Description(" ") public Notice tpaAcceptAllAccepted = Notice.chat("Zaakceptowano wszystkie prośby o teleportację!"); + + @Description(" ") + public Notice tpaTargetIgnoresYou = Notice.chat("{PLAYER} ignoruje Cię!"); } @Description({