Skip to content

GH-926 Add teleport timer to TeleportBackCommand, add teleport-here functionality. #926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Jakubk15
Copy link
Member

@Jakubk15 Jakubk15 commented Mar 16, 2025

Resolves #904

Film.bez.tytulu.mp4
Film.bez.tytulu.1.mp4

@Jakubk15 Jakubk15 changed the title Add teleport timer to TeleportBackCommand, add teleport-here functionality. GH-926 Add teleport timer to TeleportBackCommand, add teleport-here functionality. Mar 16, 2025
Copy link
Contributor

coderabbitai bot commented Mar 16, 2025

Walkthrough

This update adds a new "teleport here" feature, allowing players to request others to teleport to their location. It introduces new classes and messages to support this, including commands for sending, accepting, and denying these requests. The teleport back command now includes a warmup delay, with a bypass option for certain permissions. Several new messages and interface methods are added to handle notifications for these features. There are also minor build updates, such as a new LuckPerms version constant and plugin dependency.

Assessment against linked issues

Objective Addressed Explanation
Add warmup/countdown to teleport back command (#904)
Add bypass permission for teleport back warmup (#904)

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4a955d and 04e3fe9.

📒 Files selected for processing (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereCommand.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereCommand.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (17)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (5)
eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TeleportHereRequestService.java (1)

35-45: Consider simplifying the hasRequest method

The implementation works, but could be simplified by directly using the Cache.getIfPresent method instead of iterating through all entries.

 boolean hasRequest(UUID requester, UUID target) {
-    Map<UUID, UUID> map = this.requests.asMap();
-
-    for (Map.Entry<UUID, UUID> entry : map.entrySet()) {
-        if (entry.getKey().equals(requester) && entry.getValue().equals(target)) {
-            return true;
-        }
-    }
-
-    return false;
+    UUID storedTarget = this.requests.getIfPresent(requester);
+    return storedTarget != null && storedTarget.equals(target);
 }
eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/command/TeleportBackCommand.java (2)

50-55: Consider updating the success message timing.

The teleport success message is sent immediately even when using the delayed teleport. This might confuse players who haven't teleported yet.

        if (player.hasPermission(TIMER_BYPASS_PERMISSION)) {
            this.teleportService.teleport(player, location.get());
+           this.noticeService.player(player.getUniqueId(), translation -> translation.teleport().teleportedToLastLocation());
        } else {
            this.teleportTaskService.createTeleport(player.getUniqueId(), PositionAdapter.convert(player.getLocation()), PositionAdapter.convert(location.get()), this.settings.teleportTime());
        }

-       this.noticeService.player(player.getUniqueId(), translation -> translation.teleport().teleportedToLastLocation());

71-76: Same message timing issue in second method.

The success message should be sent after immediate teleport but not for delayed teleports.

        if (player.hasPermission(TIMER_BYPASS_PERMISSION)){
            this.teleportService.teleport(player, location.get());
+           this.noticeService.player(player.getUniqueId(), translation -> translation.teleport().teleportedToLastLocation());
+
+           this.noticeService.create()
+               .viewer(viewer)
+               .notice(translation -> translation.teleport().teleportedSpecifiedPlayerLastLocation())
+               .placeholder("{PLAYER}", player.getName())
+               .send();
        } else {
            this.teleportTaskService.createTeleport(player.getUniqueId(), PositionAdapter.convert(player.getLocation()), PositionAdapter.convert(location.get()), this.settings.teleportTime());
        }

-       this.noticeService.player(player.getUniqueId(), translation -> translation.teleport().teleportedToLastLocation());
-
-       this.noticeService.create()
-           .viewer(viewer)
-           .notice(translation -> translation.teleport().teleportedSpecifiedPlayerLastLocation())
-           .placeholder("{PLAYER}", player.getName())
-           .send();
eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereCommand.java (2)

51-68: Add error handling for async operations.

The CompletableFuture might throw exceptions that aren't being handled.

        this.isIgnoring(target, sender).thenAccept(isIgnoring -> {
           if (isIgnoring) {
               this.noticeService.create()
                   .player(sender.getUniqueId())
                   .notice(translation -> translation.tpa().tpaTargetIgnoresYou())
                   .placeholder("{PLAYER}", target.getName())
                   .send();
               return;
           }
           this.noticeService.create()
                .player(target.getUniqueId())
                .notice(translation -> translation.tpa().tpaHereReceivedMessage())
                .placeholder("{PLAYER}", sender.getName())
                .send();

           this.requestService.createRequest(sender.getUniqueId(), target.getUniqueId());
-        });
+        }).exceptionally(ex -> {
+            this.noticeService.player(sender.getUniqueId(), translation -> translation.general().error());
+            ex.printStackTrace();
+            return null;
+        });

70-72: Consider making method private.

The isIgnoring method is only used within this class, so it could be made private.

-    CompletableFuture<Boolean> isIgnoring(Player target, Player sender) {
+    private CompletableFuture<Boolean> isIgnoring(Player target, Player sender) {
        return this.ignoreService.isIgnored(target.getUniqueId(), sender.getUniqueId());
    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e98be2c and 855beaa.

📒 Files selected for processing (10)
  • buildSrc/src/main/kotlin/Versions.kt (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/command/TeleportBackCommand.java (4 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/messages/ENTeleportRequestMessages.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/messages/PLTeleportRequestMessages.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/messages/TeleportRequestMessages.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/SelfRequesterArgument.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TeleportHereRequestService.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereActionCommand.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereCommand.java (1 hunks)
  • eternalcore-plugin/build.gradle.kts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (17)
🔇 Additional comments (15)
buildSrc/src/main/kotlin/Versions.kt (1)

38-38: Good addition of LuckPerms version constant.

This addition follows the project's pattern for dependency versioning. It will help maintain consistent version references across the project.

eternalcore-plugin/build.gradle.kts (1)

42-42: Good implementation of LuckPerms plugin download.

This correctly references the version constant you added and ensures the server has the right LuckPerms version during development.

eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/messages/TeleportRequestMessages.java (1)

12-14: Interface methods added properly for teleport-here feature.

These new methods nicely complement the existing teleport request messages and support the new teleport-here functionality mentioned in the PR.

eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/messages/PLTeleportRequestMessages.java (1)

19-26: Polish message implementations look good.

The implementation follows the existing pattern with clear messages. The interactive elements with hover and click actions will make for a user-friendly experience.

eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/messages/ENTeleportRequestMessages.java (1)

19-26: Nice addition of teleport-here messages!

The new messages look good and match the style of existing messages. The interactive elements with hover text and click actions will help players easily respond to teleport requests.

eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TeleportHereRequestService.java (1)

14-25: Good implementation of request service with caching

The service implementation looks clean and uses Guava cache with expiration based on settings. This is a good approach for managing temporary teleport requests.

eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereActionCommand.java (2)

37-61: Accept method looks good

The implementation handles the teleport request acceptance properly with appropriate notifications to both players.


83-112: Good implementation of "deny all" functionality

The method correctly handles the case when no requests exist and properly notifies all involved players.

eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/SelfRequesterArgument.java (2)

35-48: Parse method looks solid

The method handles all necessary checks for the teleport requester argument, including validation that the sender is a player and the request exists.


50-61: Nice implementation of suggestions feature

The suggest method provides helpful auto-complete functionality by suggesting only players who have sent teleport requests to the current player.

eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/command/TeleportBackCommand.java (3)

24-24: Good addition of permission constant.

Clear naming for the bypass permission - makes the code more readable and easier to maintain.


26-27: New fields properly defined.

The teleport task service and settings are correctly added as fields.


31-35: Constructor updated correctly.

The constructor properly initializes the new dependencies.

eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereCommand.java (2)

16-28: Well-structured command class.

Good implementation with proper dependency injection.


31-43: Good validation checks.

The self-teleport and duplicate request checks are well-implemented.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereCommand.java (1)

53-69: Asynchronous ignore check is neat.
The CompletableFuture approach is clean. Just remember to handle cases if a player disconnects mid-check.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d73ce90 and bab4e63.

📒 Files selected for processing (4)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/command/TeleportBackCommand.java (3 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/TeleportRequestPermissionConstant.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereActionCommand.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereCommand.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/TeleportRequestPermissionConstant.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereActionCommand.java
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/command/TeleportBackCommand.java
🔇 Additional comments (4)
eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereCommand.java (4)

17-19: Command setup looks clean.
Everything here is straightforward. Nice work keeping the command name and permission aligned with the service.


34-38: Friendly self-check.
This is a helpful way to prevent self-request confusion. The message to the sender is concise.


40-44: Good repeated-request check.
This avoids accidental spam or duplicates. Straightforward flow.


72-74: Utility method isIgnoring.
Keeps the logic simple and readable. Clear separation of concerns.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/TeleportRequestPermissionConstant.java (1)

3-14: Looks good, though consider making this a utility class

The permission constants are well-organized and clearly named. Since this is a constants-only class, consider making it final and adding a private constructor to prevent instantiation.

-public class TeleportRequestPermissionConstant {
+public final class TeleportRequestPermissionConstant {
+
+    private TeleportRequestPermissionConstant() {
+        // Utility class
+    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bab4e63 and f4d518b.

📒 Files selected for processing (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/TeleportRequestPermissionConstant.java (1 hunks)
🔇 Additional comments (2)
eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/TeleportRequestPermissionConstant.java (2)

5-10: Nice alignment of permission strings

The aligned format makes these constants easy to read and maintain.


12-12: Good separation of bypass permission

The empty lines before and after this constant help distinguish it as a different category from the request-related permissions above.

Copy link
Member

@Rollczi Rollczi left a comment

Choose a reason for hiding this comment

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

Ogólnie jest spoko raczej drobne poprawki zostały, fajnie, że zmiany w ogóle nie wychodzą po za pakiet w którym pracujesz

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereActionCommand.java (1)

65-84: Implementation looks good

The deny logic correctly removes the request and notifies both players appropriately. Permissions are properly configured.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4d518b and e4a955d.

📒 Files selected for processing (3)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/command/TeleportBackCommand.java (4 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereActionCommand.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereCommand.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/command/TeleportBackCommand.java
🔇 Additional comments (3)
eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereCommand.java (2)

30-68: Well implemented teleport here request flow.

The logic correctly handles self-teleport prevention, duplicate detection, and async ignore checking. The flow of sending confirmation first, then checking ignore status is user-friendly.


70-72: Clean helper method

Simple and effective delegation to the ignore service. Good encapsulation.

eternalcore-core/src/main/java/com/eternalcode/core/feature/teleportrequest/self/TpaHereActionCommand.java (1)

86-112: Well-implemented bulk deny functionality

Good handling of edge cases including empty request lists and offline requesters. The logic flow is clear and robust.

…leportrequest/self/TpaHereCommand.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.

Add warmup to teleportback/back command.
3 participants