Skip to content

Commit 0d0c44a

Browse files
committed
fix: Disconnect sending packets, and running off executor
1 parent 83eead7 commit 0d0c44a

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

api/src/main/java/me/tofaa/entitylib/ve/ViewerEngineListener.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,19 @@ else if (type == PacketType.Play.Server.CHUNK_DATA) {
8585

8686
@Override
8787
public void onUserDisconnect(final UserDisconnectEvent event) {
88-
final UUID uniqueId = event.getUser().getUUID();
89-
90-
// Note from Chubbyduck1: While this says it's non-null, it can actually be null in this case. Not sure why. When run without this, it would spam NPEs for me.
91-
if (uniqueId == null) {
92-
return;
93-
}
88+
engine.getExecutor().execute(() -> {
89+
final UUID uniqueId = event.getUser().getUUID();
9490

95-
engine.getTracked0().forEach(entity -> {
96-
if (entity.hasViewer(uniqueId)) {
97-
entity.removeViewer(uniqueId);
91+
// Note from Chubbyduck1: While this says it's non-null, it can actually be null in this case. Not sure why. When run without this, it would spam NPEs for me.
92+
if (uniqueId == null) {
93+
return;
9894
}
95+
96+
engine.getTracked0().forEach(entity -> {
97+
if (entity.hasViewer(uniqueId)) {
98+
entity.removeViewerSilently(uniqueId);
99+
}
100+
});
99101
});
100102
}
101103

0 commit comments

Comments
 (0)