Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ public class TeleportRequestConfig extends OkaeriConfig implements TeleportReque

@Comment("# Time of teleportation time in /tpa commands")
public Duration tpaTimer = Duration.ofSeconds(10);

@Comment("# Minimum Y level required for accepting /tpa requests")
public int minimumTpaAcceptY = -1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ public interface TeleportRequestSettings {

Duration tpaTimer();

int minimumTpaAcceptY();

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class TpaAcceptCommand {
@Execute
@DescriptionDocs(description = "Accept teleport request", arguments = "<player>")
void executeTarget(@Sender Player player, @Arg(RequesterArgument.KEY) Player target) {
if (!this.canAcceptTeleportRequest(player)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply the low-Y guard to tpahereaccept too

When players also have eternalcore.tpahere, this guard can be bypassed: /tpahereaccept is handled by self/TpaHereActionCommand.accept at lines 37-44, where the accepter is teleported to the requester's target.getLocation() without checking minimumTpaAcceptY(). A player below the configured minimum can still send /tpahere and have the recipient accept, pulling them to that low Y despite the new protection.

Useful? React with 👍 / 👎.

this.sendTooLowMessage(player);

return;
}

this.teleportTaskService.createTeleport(
target.getUniqueId(),
PositionAdapter.convert(target.getLocation()),
Expand Down Expand Up @@ -64,6 +70,12 @@ void executeTarget(@Sender Player player, @Arg(RequesterArgument.KEY) Player tar
@Execute(name = "-all", aliases = "*")
@DescriptionDocs(description = "Accept all teleport requests")
void executeAll(@Sender Player player) {
if (!this.canAcceptTeleportRequest(player)) {
this.sendTooLowMessage(player);

return;
}

List<UUID> requests = this.requestService.findRequests(player.getUniqueId());

if (requests.isEmpty()) {
Expand Down Expand Up @@ -97,4 +109,17 @@ void executeAll(@Sender Player player) {

this.noticeService.player(player.getUniqueId(), translation -> translation.tpa().tpaAcceptAllAccepted());
}

private boolean canAcceptTeleportRequest(Player player) {
return player.getLocation().getY() >= this.settings.minimumTpaAcceptY();
}

private void sendTooLowMessage(Player player) {
this.noticeService
.create()
.player(player.getUniqueId())
.notice(translation -> translation.tpa().tpaAcceptTooLowMessage())
.placeholder("{Y}", String.valueOf(this.settings.minimumTpaAcceptY()))
.send();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public class ENTeleportRequestMessages extends OkaeriConfig implements TeleportR
Notice tpaAcceptMessage = Notice.chat(
"<color:#9d6eef>► <white>You have accepted the teleportation from the player: <color:#9d6eef>{PLAYER}<white>!");

@Comment({ " ", "# {Y} - Minimum Y level required to accept /tpa requests" })
Notice tpaAcceptTooLowMessage = Notice.chat(
"<red>✘ <dark_red>You must be at least at Y level <red>{Y}<dark_red> to accept this teleport request!");

@Comment(" ")
Notice tpaAcceptNoRequestMessage = Notice.chat("<red>✘ <dark_red>This player has not sent you a teleport request!");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public class PLTeleportRequestMessages extends OkaeriConfig implements TeleportR
Notice tpaAcceptMessage = Notice.chat(
"<color:#9d6eef>► <white>Zaakceptowałeś prośbę o teleportację od gracza: <color:#9d6eef>{PLAYER}<white>!");

@Comment({ " ", "# {Y} - Minimalny poziom Y wymagany do zaakceptowania prośby /tpa" })
Notice tpaAcceptTooLowMessage = Notice.chat(
"<red>✘ <dark_red>Musisz być co najmniej na poziomie Y <red>{Y}<dark_red>, aby zaakceptować tę prośbę o teleportację!");

@Comment(" ")
Notice tpaAcceptNoRequestMessage = Notice
.chat("<red>✘ <dark_red>Ten gracz nie wysłał do ciebie prośby o teleportację!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public interface TeleportRequestMessages {
Notice tpaDenyAllDenied();

Notice tpaAcceptMessage();
Notice tpaAcceptTooLowMessage();
Notice tpaAcceptNoRequestMessage();
Notice tpaAcceptReceivedMessage();
Notice tpaAcceptAllAccepted();
Expand Down
Loading