-
-
Couldn't load subscription status.
- Fork 21
GH-971 Migrate jail feature from Position to Location with LocationPersister. Rename config section. #1141
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
base: master
Are you sure you want to change the base?
Conversation
Introduced JailCommandRestrictionType enum to support both whitelist and blacklist command restrictions for jailed players. Updated JailConfig and JailSettings to use 'restrictedCommands' and 'restrictionType' instead of 'allowedCommands'. Modified JailController logic to handle both restriction types. Took 12 minutes
Added a record of the player's previous location. Configuration values and messages have been migrated. Added constant permission values and used static imports for better appearance. Other cosmetic or quality improvements have been made. Took 49 minutes
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.
Code Review
This pull request refactors the jail system, introducing features like storing a player's last location before being jailed and a more flexible command restriction system (whitelist/blacklist). The refactoring also includes centralizing permission constants and cleaning up configuration keys and message structures. My review has identified a couple of issues: a critical bug where a new configuration migration is not registered, which could lead to data loss for users, and a logical flaw in the releaseAllPlayers method where event cancellations are not fully respected. I've also suggested a minor improvement to a configuration comment for better clarity. Overall, this is a solid refactoring with significant improvements, and addressing these points will make it even better.
eternalcore-core/src/main/java/com/eternalcode/core/configuration/migrations/Migrations.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/feature/jail/JailServiceImpl.java
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/feature/jail/JailConfig.java
Outdated
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.
Good job, follow gemini suggestions 🙌
| private final Duration prisonTime; | ||
| private final String detainedBy; | ||
| @Nullable | ||
| private final Location lastLocation; |
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.
Location -> Position, We don't keep the location because it creates memory leaks and has a lot of world dependencies
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 I think I will be obliged to use another serializer for Position class in database?
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.
Other than that, please apply Gemini's suggestions. It gave valuable feedback
eternalcore-core/src/main/java/com/eternalcode/core/feature/jail/messages/JailMessages.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/feature/jail/messages/JailMessages.java
Outdated
Show resolved
Hide resolved
Refactored JailServiceImpl.releaseAllPlayers to avoid clearing all jailed players and prisoners at once, now only releasing non-cancelled events and handling null players. Updated JailConfig comments for clarity and registered new migration for jail section in Migrations. Took 8 minutes
Took 15 minutes
releasePrivate -> released
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.
Nice
Replaced custom Position class with Bukkit's Location for storing and handling player locations in jail-related classes. Updated constructors, field names, and database persister to reflect this change, improving compatibility and simplifying location management. Took 36 minutes
eternalcore-api/build.gradle.kts
Outdated
|
|
||
| dependencies { | ||
| compileOnly("org.spigotmc:spigot-api:${Versions.SPIGOT_API}") | ||
| compileOnly("com.eternalcode:eternalcode-commons-bukkit:${Versions.ETERNALCODE_COMMONS}") |
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.
?
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.
Position usage in API
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.
trochę słabo będzie wystawiać API które jest relokowane
...eternalcode/core/configuration/migrations/Migration_0010_Move_jail_to_dedicated_section.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/feature/jail/JailPermissionConstant.java
Show resolved
Hide resolved
Took 58 minutes
Deleted PositionArgument class and removed references to invalidPosition messages in ArgumentMessages, ENArgumentMessages, and PLArgumentMessages. Updated HomeAdminCommand to use Location instead of Position for home setting, simplifying argument handling. Took 25 minutes
When setting a home for a user, the location now explicitly uses the sender's world, yaw, and pitch to avoid inconsistencies if a custom location is provided without these values. Took 8 minutes
Renamed migration class and references from 'Move_jail_to_dedicated_section' to 'Rename_jail_section' for clarity. Updated PositionPersister to use Position's toString method and added type safety. Minor import and formatting adjustments in JailedPlayer and PrisonerTable. Took 35 minutes
Took 2 minutes
eternalcore-api/src/main/java/com/eternalcode/core/feature/home/event/HomeCreateEvent.java
Outdated
Show resolved
Hide resolved
eternalcore-api/src/main/java/com/eternalcode/core/feature/home/event/HomeCreateEvent.java
Outdated
Show resolved
Hide resolved
eternalcore-api/src/main/java/com/eternalcode/core/feature/home/event/HomeOverrideEvent.java
Outdated
Show resolved
Hide resolved
eternalcore-api/src/main/java/com/eternalcode/core/feature/home/event/PreHomeTeleportEvent.java
Outdated
Show resolved
Hide resolved
eternalcore-api/src/main/java/com/eternalcode/core/feature/jail/JailedPlayer.java
Outdated
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.
Zmiany w home do wywalenia, migracje były testowane? I czy ten persister do DB był testowany? I czy API z jakrą było testowane? Nie mówię, że nie było albo że trzeba wszystko testować ale widzę parę miejsc które słabo rokują
szczególnie te zmiany w wystawianiu libki jako API #1141 (comment)
...core/configuration/migrations/Migration_0009_Rename_allowed_to_restricted_jail_commands.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/database/persister/PositionPersister.java
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/feature/home/HomeImpl.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/feature/home/HomeManager.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/feature/home/HomeManager.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/feature/home/command/SetHomeCommand.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/feature/home/database/HomeTable.java
Outdated
Show resolved
Hide resolved
...nalcore-core/src/main/java/com/eternalcode/core/feature/home/homeadmin/HomeAdminCommand.java
Outdated
Show resolved
Hide resolved
# Conflicts: # eternalcore-core/src/main/java/com/eternalcode/core/configuration/migrations/Migrations.java # eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java # eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java
The entire prison system has been improved and fixes from #971 have been applied.
All game changes and migrations have been tested.