Skip to content

GH-1330 Accept latest teleport request if no player specified - #1408

Open
Pawelusze wants to merge 1 commit into
EternalCodeTeam:masterfrom
Pawelusze:feature/tpaccept-latest-request
Open

GH-1330 Accept latest teleport request if no player specified#1408
Pawelusze wants to merge 1 commit into
EternalCodeTeam:masterfrom
Pawelusze:feature/tpaccept-latest-request

Conversation

@Pawelusze

Copy link
Copy Markdown
Contributor

If a player runs /tpaccept or /tpahereaccept without arguments, it automatically accepts their most recent pending teleport request

@Pawelusze Pawelusze self-assigned this Jul 27, 2026
@Pawelusze
Pawelusze requested a review from a team as a code owner July 27, 2026 11:15
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Comment on lines +41 to +45
Player target = this.requestService.findRequests(player.getUniqueId()).stream()
.map(this.server::getPlayer)
.filter(Objects::nonNull)
.findFirst()
.orElse(null);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this can be moved to service. To not sort and filter both in findRequests and here in .stream

return requesters;
return this.requests.asMap().entrySet().stream()
.filter(entry -> entry.getValue().target().equals(target))
.sorted(Map.Entry.comparingByValue(Comparator.comparing(Request::createdAt).reversed()))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we compare Instants better?

return requesters;
return this.requests.asMap().entrySet().stream()
.filter(entry -> entry.getValue().target().equals(target))
.sorted(Map.Entry.comparingByValue(Comparator.comparing(Request::createdAt).reversed()))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same as before

@Permission("eternalcore.tpaccept")
@DescriptionDocs(description = "Accept the last received teleport here request")
void acceptLatest(@Sender Player player) {
Player target = this.requestService.findRequests(player.getUniqueId()).stream()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants