9
0
mirror of https://github.com/WiIIiam278/HuskSync.git synced 2025-12-25 17:49:20 +00:00

Minor performance improvement to event cancelling, add checks against inventory clicks

This commit is contained in:
William278
2022-11-15 17:46:55 +00:00
parent efcb36d345
commit 945b65e1bc
2 changed files with 20 additions and 14 deletions

View File

@@ -122,8 +122,8 @@ public abstract class EventListener {
private void handleSynchronisationCompletion(@NotNull OnlineUser user, boolean succeeded) {
if (succeeded) {
plugin.getLocales().getLocale("synchronisation_complete").ifPresent(user::sendActionBar);
lockedPlayers.remove(user.uuid);
plugin.getDatabase().ensureUser(user).join();
lockedPlayers.remove(user.uuid);
plugin.getEventCannon().fireSyncCompleteEvent(user);
} else {
plugin.getLocales().getLocale("synchronisation_failed")
@@ -154,7 +154,8 @@ public abstract class EventListener {
optionalUserData -> optionalUserData.ifPresent(userData -> plugin.getRedisManager()
.setUserData(user, userData).thenRun(() -> plugin.getDatabase()
.setUserData(user, userData, DataSaveCause.DISCONNECT)))))
.thenRun(() -> lockedPlayers.remove(user.uuid)).exceptionally(throwable -> {
.thenRun(() -> lockedPlayers.remove(user.uuid))
.exceptionally(throwable -> {
plugin.getLoggingAdapter().log(Level.SEVERE,
"An exception occurred handling a player disconnection");
throwable.printStackTrace();
@@ -196,11 +197,11 @@ public abstract class EventListener {
/**
* Determine whether a player event should be cancelled
*
* @param user {@link OnlineUser} performing the event
* @param userUuid The UUID of the user to check
* @return Whether the event should be cancelled
*/
protected final boolean cancelPlayerEvent(@NotNull OnlineUser user) {
return disabling || lockedPlayers.contains(user.uuid);
protected final boolean cancelPlayerEvent(@NotNull UUID userUuid) {
return disabling || lockedPlayers.contains(userUuid);
}
/**