-
-
Notifications
You must be signed in to change notification settings - Fork 16
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-897 Fix dependency injector configuration class instance handling of plugin config #897
Conversation
WalkthroughThe pull request introduces several modifications across different Java classes in the eternalcore-core project. The changes primarily involve adjustments to random teleport settings, configuration compatibility, and dependency injection mechanisms. Key modifications include updating the default radius configuration for random teleports to include negative coordinates, changing the visibility of a configuration compatibility class, and refactoring dependency resolution methods. The EternalCore class has also been updated with new import statements and initialization calls for configuration-related classes. These changes appear to be part of an ongoing effort to improve the project's configuration and dependency management infrastructure. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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: 0
🧹 Nitpick comments (1)
eternalcore-core/src/main/java/com/eternalcode/core/feature/randomteleport/RandomTeleportSafeLocationService.java (1)
54-56
: Clean up extra blank linesThe coordinate generation looks good, but we can remove the extra blank lines after it.
int randomX = this.random.nextInt(-radius.minX(), radius.maxX()); int randomZ = this.random.nextInt(-radius.minZ(), radius.maxZ()); -
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
eternalcore-core/src/main/java/com/eternalcode/core/feature/randomteleport/RandomTeleportSafeLocationService.java
(3 hunks)eternalcore-core/src/main/java/com/eternalcode/core/feature/randomteleport/RandomTeleportTaskService.java
(1 hunks)
🔇 Additional comments (2)
eternalcore-core/src/main/java/com/eternalcode/core/feature/randomteleport/RandomTeleportTaskService.java (1)
47-47
: Nice cleanup! 👍Good call on removing the temporary variable. The code looks cleaner now.
eternalcore-core/src/main/java/com/eternalcode/core/feature/randomteleport/RandomTeleportSafeLocationService.java (1)
8-8
: Are we planning to add logging?The @slf4j annotation is added but not used yet. Let me know if you'd like help adding some useful log messages!
Also applies to: 21-21
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)
eternalcore-core/src/main/java/com/eternalcode/core/injector/bean/LazyBeanCandidate.java (1)
18-18
: Nice simplification!The code is cleaner now. Good job removing the unnecessary local variable while keeping the same functionality.
Just a small note: Since
getType()
triggers instance creation throughgetInstance()
, you might want to store the result locally if you need to use it multiple times in the future. For now, it's perfectly fine as is.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
eternalcore-core/src/main/java/com/eternalcode/core/EternalCore.java
(2 hunks)eternalcore-core/src/main/java/com/eternalcode/core/configuration/compatibility/ConfigurationCompatibilityV21_2.java
(1 hunks)eternalcore-core/src/main/java/com/eternalcode/core/injector/bean/LazyBeanCandidate.java
(1 hunks)eternalcore-core/src/main/java/com/eternalcode/core/injector/bean/LazyFieldBeanCandidate.java
(1 hunks)
🔇 Additional comments (2)
eternalcore-core/src/main/java/com/eternalcode/core/configuration/compatibility/ConfigurationCompatibilityV21_2.java (1)
10-13
: Let's align the class visibility with the TODO commentThe TODO comment suggests making this class package-private, but it's still marked as public. We should either:
- Remove the
public
modifier to make it package-private now, or- Create a tracking issue for this TODO if it needs to be done later
Would you like me to help create a tracking issue for this TODO?
eternalcore-core/src/main/java/com/eternalcode/core/EternalCore.java (1)
83-84
: Track temporary CDN workaroundThese initialization calls are marked as temporary workarounds for a CDN issue. Let's:
- Add a reference to the CDN issue ticket
- Document when these workarounds can be safely removed
Run this script to check for related CDN issues:
eternalcore-core/src/main/java/com/eternalcode/core/injector/bean/LazyFieldBeanCandidate.java
Show resolved
Hide resolved
@coderabbitai What would be the appropriate title for this PR? |
Tip For best results, initiate chat on the files or code changes. @Jakubk15 Based on the changes in this PR, I suggest the title: "Improve random teleport functionality and radius configuration" This title reflects the main changes:
|
int randomX = spawnX + (Math.random() < 0.5 ? 1 : -1) * this.random.nextInt(radius.minX(), radius.maxX()); | ||
int randomZ = spawnZ + (Math.random() < 0.5 ? 1 : -1) * this.random.nextInt(radius.minZ(), radius.maxZ()); |
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.
@coderabbitai explain 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.
@Jakubk15 The changes improve how random teleport locations are generated:
- Previously, players would only teleport in positive directions from spawn (like northeast)
- Now, the coordinates can be generated in any direction (northeast, northwest, southeast, southwest)
- This creates a more balanced distribution of random teleport locations around the spawn point
The change makes the random teleport feature more fair and intuitive, as players have an equal chance to be teleported in any direction from spawn.
🐰 (thoughtfully considering the technical details)
✏️ Learnings added
Learnt from: Jakubk15
PR: EternalCodeTeam/EternalCore#897
File: eternalcore-core/src/main/java/com/eternalcode/core/feature/randomteleport/RandomTeleportSafeLocationService.java:53-54
Timestamp: 2025-01-24T09:16:19.464Z
Learning: The random teleport feature in EternalCore should generate coordinates in both positive and negative directions from spawn point to ensure balanced distribution of teleport locations.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
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.
Ok but why the author decided to use Math.random() < 0.5?
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.
@Jakubk15 Math.random() < 0.5
is used because it's a simple way to get a 50/50 chance in Java. Since Math.random()
returns a number between 0 and 1, comparing it with 0.5 gives you:
- 50% chance for true (when the random number is 0.0 to 0.49...)
- 50% chance for false (when the random number is 0.5 to 0.99...)
This creates an equal probability of getting either 1 or -1 as the direction multiplier, ensuring fair distribution in all directions.
✏️ Learnings added
Learnt from: Jakubk15
PR: EternalCodeTeam/EternalCore#897
File: eternalcore-core/src/main/java/com/eternalcode/core/feature/randomteleport/RandomTeleportSafeLocationService.java:53-54
Timestamp: 2025-01-24T09:28:00.008Z
Learning: In Java random teleport implementations, Math.random() < 0.5 is used to achieve a 50/50 chance between positive and negative directions, providing a simple and efficient way to ensure equal distribution around a center point.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
IMO: Improve of rtp teleport radius and dependency injector fix with creating and using instance of configuration class |
No description provided.