-
-
Notifications
You must be signed in to change notification settings - Fork 20
GH-1147 Make UserManager use UserRepository #1147
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
Merged
+429
−450
Merged
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
92868fe
Add database for users, add batch fetching, update tests
CitralFlo 1a7dd18
Codestyle fixes
CitralFlo 3c6ad2a
Resolve gemini review
CitralFlo 7d3ee9e
Resolve @sadcenter and @Jakubk15 reviews
CitralFlo 9414f7d
wip
Rollczi b3efc5f
wip2
CitralFlo 2050371
Merge remote-tracking branch 'origin/user-manager-database' into user…
CitralFlo 0cdf8b2
wip
CitralFlo 11813d4
Update methods and failsafe for cache
CitralFlo 14a95d6
Merge branch 'master' into user-manager-database
vLuckyyy c3aa70a
Merge branch 'master' into user-manager-database
vLuckyyy 80730a5
Refactor `UserManager` and related classes to improve database integr…
vLuckyyy 2e0a7e1
Remove MySQL and Testcontainers integration, refactor database config…
vLuckyyy 5cebc63
CR
Rollczi 5f086ae
Remove `created` and `lastLogin` fields from `User`, cleanup related …
vLuckyyy d42de10
Remove `IntegrationTestSpec` and `TestScheduler` utilities as they ar…
vLuckyyy 982ce14
Add `lastSeen` and `accountCreated` fields to `User`, enhance `UserMa…
vLuckyyy 8858585
Merge branch 'master' into user-manager-database
vLuckyyy c9ae250
Update `UserTable` to use `DATE_STRING` for `lastSeen` and `accountCr…
vLuckyyy 10f2f98
Merge branch 'master' into user-manager-database
vLuckyyy a4cfc08
Update `UserTable` to replace `Instant` with `Date` fields and downgr…
vLuckyyy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
eternalcore-core/src/main/java/com/eternalcode/core/user/LoadUserController.java
This file was deleted.
Oops, something went wrong.
53 changes: 0 additions & 53 deletions
53
eternalcore-core/src/main/java/com/eternalcode/core/user/PrepareUserController.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
eternalcore-core/src/main/java/com/eternalcode/core/user/UserClientBukkitSettings.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
eternalcore-core/src/main/java/com/eternalcode/core/user/UserClientNoneSettings.java
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
eternalcore-core/src/main/java/com/eternalcode/core/user/UserClientSettings.java
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
eternalcore-core/src/main/java/com/eternalcode/core/user/UserController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package com.eternalcode.core.user; | ||
|
|
||
| import com.eternalcode.core.injector.annotations.Inject; | ||
| import com.eternalcode.core.injector.annotations.component.Controller; | ||
| import java.util.function.BiConsumer; | ||
| import java.util.logging.Level; | ||
| import java.util.logging.Logger; | ||
| import org.bukkit.Server; | ||
| import org.bukkit.entity.Player; | ||
| import org.bukkit.event.EventHandler; | ||
| import org.bukkit.event.EventPriority; | ||
| import org.bukkit.event.Listener; | ||
| import org.bukkit.event.player.PlayerJoinEvent; | ||
| import org.bukkit.event.server.ServerLoadEvent; | ||
|
|
||
| @Controller | ||
| class UserController implements Listener { | ||
|
|
||
| private final UserManager userManager; | ||
| private final Server server; | ||
| private final Logger logger; | ||
|
|
||
| @Inject | ||
| UserController(UserManager userManager, Server server, Logger logger) { | ||
| this.userManager = userManager; | ||
| this.server = server; | ||
| this.logger = logger; | ||
| } | ||
|
|
||
| @EventHandler(priority = EventPriority.LOWEST) | ||
| void onJoin(PlayerJoinEvent event) { | ||
| Player player = event.getPlayer(); | ||
| this.userManager.findOrCreate(player.getUniqueId(), player.getName()) | ||
| .whenComplete(this.handleFutureResult(player, "Failed to load user: " + player.getName() + ". Please try again.")); | ||
| } | ||
|
|
||
| private <T> BiConsumer<T, Throwable> handleFutureResult(Player player, String message) { | ||
| return (user, throwable) -> { | ||
| if (throwable != null) { | ||
| player.kickPlayer(message); | ||
| this.logger.log(Level.SEVERE, message, throwable); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| @EventHandler | ||
| void onReload(ServerLoadEvent event) { | ||
| if (event.getType() != ServerLoadEvent.LoadType.RELOAD) { | ||
| return; | ||
| } | ||
|
|
||
| for (Player player : this.server.getOnlinePlayers()) { | ||
| this.userManager.findOrCreate(player.getUniqueId(), player.getName()); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.