Skip to content
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

GH-72 Use UniHologram Library instead of HoloEasy. #72

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

Conversation

vLuckyyy
Copy link
Member

No description provided.

Copy link

coderabbitai bot commented Nov 10, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces several changes across multiple files in the project.

In the Gradle build scripts, a new group ID and version number are defined for the project, and the list of Maven repositories is updated by removing one and adding another. Additionally, the dependency on the Spigot API in the lobbyheads-api project is changed from api to compileOnlyApi, affecting its visibility during compilation.

The lobbyheads-core project sees a removal of a test dependency and an update to another dependency, along with modifications to the plugin's dependency management. The HeadsPlugin class is updated to integrate a new hologram provider, altering how holograms are instantiated. The HeadsConfiguration class has the @Names annotation removed, which may impact property serialization.

New utility functions for generating hologram names are introduced, and the HologramService class undergoes significant refactoring to streamline hologram management, including changes to its constructor and methods. Overall, the changes reflect a comprehensive update to the project's structure and dependencies.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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

@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: 2

🧹 Outside diff range and nitpick comments (2)
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramNameUtil.java (2)

7-7: Add a quick comment explaining the name format.

A simple comment would help others understand what the format represents.

+    /** Format: heads_worldname_x_y_z */
     private static final String HOLOGRAM_NAME_PREFIX = "heads_%s_%s_%s_%s";

17-19: Consider using Pattern.compile for better performance.

If this gets called often, a pre-compiled pattern would be faster.

+    private static final Pattern INVALID_CHARS = Pattern.compile("[^a-zA-Z0-9_-]");
+
     private static String sanitize(String input) {
-        return input.replaceAll("[^a-zA-Z0-9_-]", "_");
+        return INVALID_CHARS.matcher(input).replaceAll("_");
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7e5e4b1 and 49baa20.

📒 Files selected for processing (8)
  • buildSrc/src/main/kotlin/lobbyheads-java-17.gradle.kts (1 hunks)
  • buildSrc/src/main/kotlin/lobbyheads-repositories.gradle.kts (1 hunks)
  • lobbyheads-api/build.gradle.kts (1 hunks)
  • lobbyheads-core/build.gradle.kts (3 hunks)
  • lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/HeadsPlugin.java (3 hunks)
  • lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/configuration/implementation/HeadsConfiguration.java (0 hunks)
  • lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramNameUtil.java (1 hunks)
  • lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramService.java (3 hunks)
💤 Files with no reviewable changes (1)
  • lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/configuration/implementation/HeadsConfiguration.java
✅ Files skipped from review due to trivial changes (1)
  • buildSrc/src/main/kotlin/lobbyheads-java-17.gradle.kts
🧰 Additional context used
🪛 Gitleaks
lobbyheads-api/build.gradle.kts

8-8: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🔇 Additional comments (20)
lobbyheads-api/build.gradle.kts (1)

8-8: Nice improvement!

Using compileOnlyApi for the Spigot API is perfect since the server already provides it at runtime. This keeps your plugin lightweight.

🧰 Tools
🪛 Gitleaks

8-8: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

buildSrc/src/main/kotlin/lobbyheads-repositories.gradle.kts (2)

14-14: LGTM! Repository added for UniHologram Library.

The new Maven repository looks good and aligns with the PR objective of switching to UniHologram.


Line range hint 1-15: Double-check dependency resolution.

Let's make sure all dependencies can still be resolved after removing the old repository.

✅ Verification successful

All dependencies look good after repository changes

I've checked all the build files and dependencies. None of them use packages from the removed repository, and all current dependencies are pointing to repositories that are still in the configuration. Everything should continue working as expected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to packages from the old repository
rg -l "pl.minecodes" .

# Look for potential build files that might need updates
fd -e gradle -e gradle.kts

Length of output: 452


Script:

#!/bin/bash
# Let's check the dependencies in the build files to see if any still reference the old repository
rg -l "minecodes" lobbyheads-api/build.gradle.kts lobbyheads-core/build.gradle.kts

# Also check the actual dependency declarations
rg "implementation|api|compile" lobbyheads-api/build.gradle.kts lobbyheads-core/build.gradle.kts

Length of output: 1964

lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramNameUtil.java (1)

1-5: LGTM! Good choice on package visibility.

The class is properly scoped to its package, which keeps things neat and tidy.

lobbyheads-core/build.gradle.kts (2)

69-70: Check if ProtocolLib is still needed.

The removal of ProtocolLib dependency needs verification since it's still downloaded in the runServer task.

#!/bin/bash
# Search for ProtocolLib usage in the code
rg -l "ProtocolLib|protocollib" --type java

37-39: Looks good! Let's verify the dependency.

The new hologram library is properly configured with the CMILib exclusion.

lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/HeadsPlugin.java (3)

26-27: Looking good! Clean import additions.

The new imports match perfectly with the switch to UniHologram.

Also applies to: 35-35


50-51: Nice formatting improvement!

The split makes the code easier to read.


74-77: Let's double-check the hologram setup.

The switch to UniHologram looks good, but let's verify that all hologram-related code has been updated.

✅ Verification successful

All hologram-related code has been properly updated

The codebase shows a complete transition to UniHologram:

  • All hologram classes use the new UniHologram imports
  • No traces of HoloEasy found
  • HologramService and HologramController properly integrated with the new provider
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining HoloEasy references
rg -i "holoeasy" 

# Look for other hologram-related classes that might need updates
rg "Hologram" -g "*.java"

Length of output: 6751

lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramService.java (11)

3-4: Import added successfully

The static import for generateHologramName looks good.


12-15: Updated imports to UniHologram library

The new imports from UniHologram are correctly added.


30-32: New fields added

Fields headManager and provider are properly added.


33-39: Constructor updated

The constructor now includes headManager and provider, which is great.


43-44: Fields initialized correctly

Fields headManager and provider are initialized properly.


48-51: Code update looks good

The placeholder handling and location conversion are correctly implemented.


53-55: Hologram creation updated successfully

Holograms are now created using the new provider, which is correct.


63-66: Loading holograms updated

The hologram loading loop using headManager looks good.


70-71: Check the hologram type casting

Please ensure that casting to Hologram<Location> is safe to avoid any issues.


80-83: Hologram updates look correct

The holograms are updated properly with the new manager.


90-94: Confirm Java version compatibility

The instanceof pattern matching requires Java 16 or higher. Make sure the project supports this version.

Copy link

@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

🧹 Outside diff range and nitpick comments (1)
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramService.java (1)

70-71: Consider adding error handling

The hologram removal could benefit from some basic error logging when the hologram isn't found.

-        this.provider.getHologram(generateHologramName(position))
-            .ifPresent(hologram -> ((Hologram<Location>) hologram).clear());
+        this.provider.getHologram(generateHologramName(position))
+            .ifPresentOrElse(
+                hologram -> ((Hologram<Location>) hologram).clear(),
+                () -> System.out.println("No hologram found at position: " + position)
+            );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 49baa20 and 594096d.

📒 Files selected for processing (1)
  • lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramService.java (2 hunks)
🔇 Additional comments (5)
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramService.java (5)

12-15: Nice job with the new imports!

The switch to UniHologram's classes looks clean and organized.


30-31: Good field organization!

The switch from pool-based to provider-based approach looks cleaner.


33-44: Constructor looks better now!

The removal of direct Plugin dependency and addition of HologramProvider makes the class more focused and easier to test.


90-94: Visibility handling looks good!

The new visibility system using PlayerVisibility interface is a nice improvement.


48-55: Double-check the text processing logic

While the hologram creation looks good, we should verify that the text processing works the same way as before.

Let's check if the text processing matches the old implementation:

✅ Verification successful

Let me check for any previous text processing logic to compare with.


Text processing looks good! 👍

The old and new implementations handle text processing in the same way:

  1. Replace {PLAYER} with player name
  2. Process PlaceholderAPI placeholders
  3. Deserialize with MiniMessage
  4. Serialize with section serializer
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any other text processing logic in the old code
rg -A 3 "PlaceholderAPI.setPlaceholders" 

Length of output: 781


Script:

#!/bin/bash
# Look for git history of the file to see previous implementation
git log -p lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramService.java

Length of output: 13117

@vLuckyyy vLuckyyy changed the title Use UniHologram Library instead of HoloEasy. GH-72 Use UniHologram Library instead of HoloEasy. Nov 13, 2024
@@ -5,7 +5,7 @@ plugins {
}

dependencies {
api("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT")
compileOnlyApi("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT")
Copy link
Member

Choose a reason for hiding this comment

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

ale jaja

Copy link
Member

Choose a reason for hiding this comment

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

Czemu taka zmiana?

String string = PlaceholderAPI.setPlaceholders(player, replace);
Component deserialize = this.miniMessage.deserialize(string);
String serialize = AdventureUtil.SECTION_SERIALIZER.serialize(deserialize);
String placeholderText = PlaceholderAPI.setPlaceholders(player, headName.replace("{PLAYER}", player.getName()));
Copy link
Member

Choose a reason for hiding this comment

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

kurczaki można było by tu zrobić jakiś simple bridge żeby PAPI nie musiało być dependem

@@ -5,7 +5,7 @@ plugins {
}

dependencies {
api("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT")
compileOnlyApi("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT")
Copy link
Member

Choose a reason for hiding this comment

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

Czemu taka zmiana?

@imDMK imDMK removed their request for review December 9, 2024 10:10
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