mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 22:15:45 +00:00
chore: Reduce code duplication in join/save exception handlers
This commit is contained in:
4 files changed
+35
-25
No files matched your search
+4
-4
@@ -34,6 +34,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
import static net.draycia.carbon.common.util.PlayerUtils.saveExceptionHandler;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class FabricJoinQuitListener implements ServerPlayConnectionEvents.Join, ServerPlayConnectionEvents.Disconnect {
|
||||
|
||||
@@ -70,10 +72,8 @@ public class FabricJoinQuitListener implements ServerPlayConnectionEvents.Join,
|
||||
|
||||
@Override
|
||||
public void onPlayDisconnect(final ServerGamePacketListenerImpl handler, final MinecraftServer server) {
|
||||
this.userManager.loggedOut(handler.getPlayer().getGameProfile().getId()).exceptionally(thr -> {
|
||||
this.logger.warn("Exception saving data for player " + handler.getPlayer().getGameProfile().getName() + " with uuid " + handler.getPlayer().getGameProfile().getId());
|
||||
return null;
|
||||
});
|
||||
this.userManager.loggedOut(handler.getPlayer().getGameProfile().getId())
|
||||
.exceptionally(saveExceptionHandler(this.logger, handler.getPlayer().getGameProfile().getName(), handler.getPlayer().getGameProfile().getId()));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user