-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 Create universal hologram provider instead of HoloEasy. #72
base: master
Are you sure you want to change the base?
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThis 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 The New utility functions for generating hologram names are introduced, and the 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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
📒 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.
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramNameUtil.java
Show resolved
Hide resolved
There was a problem hiding this 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 handlingThe 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
📒 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:
- Replace
{PLAYER}
with player name - Process PlaceholderAPI placeholders
- Deserialize with MiniMessage
- 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
@@ -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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ale jaja
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Czemu taka zmiana?
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramService.java
Show resolved
Hide resolved
@@ -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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Czemu taka zmiana?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/block/BlockController.java (1)
57-57
: Unused variable
skullData
is never used. Remove it if it’s no longer needed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
buildSrc/src/main/kotlin/lobbyheads-repositories.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/ConfigurationService.java
(2 hunks)lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/configuration/implementation/HeadsConfiguration.java
(2 hunks)lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/configuration/serializer/SoundSerializer.java
(1 hunks)lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/block/BlockController.java
(2 hunks)lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramService.java
(2 hunks)lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/provider/HologramProvider.java
(1 hunks)lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/provider/HologramProviderNotFoundException.java
(1 hunks)lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/provider/HologramProviderPicker.java
(1 hunks)lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/provider/fancyholograms/FancyHologramsProvider.java
(1 hunks)lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/sound/SoundController.java
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- buildSrc/src/main/kotlin/lobbyheads-repositories.gradle.kts
- lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/configuration/implementation/HeadsConfiguration.java
🔇 Additional comments (33)
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/block/BlockController.java (3)
9-10
: Good imports
Using UUID
and TimeUnit
is a neat addition. No issues here.
60-61
: Smooth scheduling
Placing the update call in a scheduled task helps avoid blocking. Nice approach!
64-65
: Clear ownership setting
Assigning the skull’s owner with the player’s UUID is straightforward and effective.
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/HologramService.java (13)
3-3
: Neat static import!
It simplifies name generation nicely.
8-9
: Good choice of direct imports.
This keeps the code clear and organized.
13-13
: Import looks fine.
UUID usage seems straightforward.
26-28
: Well-structured fields.
Declaring them as final is a helpful design choice.
29-35
: Constructor is nicely simplified.
Easy to understand and maintain.
39-40
: Clear assignments.
Keeps references easy to track.
44-44
: Consider lightening PAPI dependency.
A flexible bridge might help in optional usage.
45-47
: MiniMessage and serialization look great.
It keeps the text formatting flexible.
49-49
: Provider usage is tidy.
This new approach is a neat improvement.
55-55
: Loop logic is clear.
Neatly iterates over heads.
62-62
: Removal step is straightforward.
This is easy to follow.
71-71
: Keeps all holograms in sync.
Nice way to ensure updates.
77-77
: Offset is a nice touch.
Helps positioning the hologram better.
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/provider/HologramProviderNotFoundException.java (1)
1-7
: Custom exception looks good.
It clarifies missing provider scenarios.
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/provider/HologramProvider.java (1)
1-13
: Interface-based design is great.
It fosters easy swapping of implementations.
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/provider/HologramProviderPicker.java (1)
1-17
: Dynamic picking is clever.
Makes it simpler to select a suitable provider at runtime.
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/configuration/serializer/SoundSerializer.java (1)
1-30
: Neat serialization approach.
Makes sound configurations easy and consistent.
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/sound/SoundController.java (2)
3-3
: Everything looks fine.
Nice addition of the new XSound
import. No problems spotted here.
33-33
: Clear and simple usage of XSound
.
This is easier to read and maintain than raw sound calls.
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/configuration/ConfigurationService.java (2)
3-3
: Good import placement.
Neat to see SoundSerializer
integrated here.
35-35
: Registration of SoundSerializer
is clear.
This looks straightforward. Ensure the sounds load as expected.
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/head/hologram/provider/fancyholograms/FancyHologramsProvider.java (1)
1-67
: Nice provider-based approach.
This new class is laid out clearly and uses FancyHolograms well. Good asynchronous handling for hologram creation and updating. Looks friendly to maintain.
lobbyheads-core/build.gradle.kts (5)
34-34
: Dependency for XSeries
looks good.
This is the correct version and should help with sound features.
36-36
: Compile-only FancyHolograms is well-chosen.
This ensures flexibility without forcing the plugin dependency.
66-66
: Depend on PlaceholderAPI
only.
Seems like a simpler setup. Everything else is optional now.
67-67
: Great use of softDepend
.
This broadens compatibility with other plugins nicely.
107-109
: Re-enable quality checks and tests if possible.
Similar to a prior comment about turning tests and checkstyle back on. It keeps the project tidy.
lobbyheads-core/src/main/java/com/eternalcode/lobbyheads/HeadsPlugin.java (3)
18-19
: Looking good! 👍
These imports match perfectly with the switch to the new hologram system.
49-50
: Nice formatting! 👍
The split makes the code easier to read.
76-82
: Clean and clear service setup! 👍
The new HologramService setup looks great with the hologram provider parameter.
HologramProviderPicker hologramProviderPicker = new HologramProviderPicker(); | ||
HologramProvider hologramProvider = hologramProviderPicker.pickProvider(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Provider selection looks good but needs a fallback option
The code checks for FancyHolograms plugin, but it might be better to have a backup plan. Right now it throws an error if FancyHolograms isn't available.
- Consider adding a default/fallback hologram provider in
HologramProviderPicker.java
for when FancyHolograms isn't installed - This would make the plugin more resilient and user-friendly
🔗 Analysis chain
Let's double-check the provider selection
The code looks good, but we should verify that the right hologram provider is being selected.
Run this check to see which provider is being used:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Find the provider selection logic
ast-grep --pattern 'class HologramProviderPicker {
$$$
pickProvider($$$) {
$$$
}
$$$
}'
Length of output: 101
Script:
#!/bin/bash
# Let's try finding the file first using fd
fd HologramProviderPicker
# Then let's look at its content
rg -A 10 "class HologramProviderPicker" --type java
Length of output: 1718
No description provided.