mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 19:45:21 +01:00
Sanity check for queued messages
This commit is contained in:
parent
4213c4cce5
commit
3529d6a229
@ -277,12 +277,13 @@ public final class EntityPackets extends EntityRewriter<Protocol1_19To1_18_2> {
|
||||
displayPreviewPacket.write(Type.BOOLEAN, false);
|
||||
displayPreviewPacket.send(Protocol1_19To1_18_2.class);
|
||||
|
||||
final QueuedMessagesStorage messagesStorage = wrapper.user().remove(QueuedMessagesStorage.class);
|
||||
if (messagesStorage == null) {
|
||||
final QueuedMessagesStorage messagesStorage = wrapper.user().get(QueuedMessagesStorage.class);
|
||||
if (messagesStorage.hasSent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Queue<QueuedMessagesStorage.Message> messages = messagesStorage.messages();
|
||||
messagesStorage.setSent();
|
||||
if (messages.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -19,18 +19,27 @@ package com.viaversion.viaversion.protocols.protocol1_19to1_18_2.storage;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Queue;
|
||||
|
||||
public final class QueuedMessagesStorage implements StorableObject {
|
||||
|
||||
private final Queue<Message> messages = new ArrayDeque<>();
|
||||
private Queue<Message> messages = new ArrayDeque<>();
|
||||
|
||||
public Queue<Message> messages() {
|
||||
public @Nullable Queue<Message> messages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public boolean hasSent() {
|
||||
return messages == null;
|
||||
}
|
||||
|
||||
public void setSent() {
|
||||
messages = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clearOnServerSwitch() {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user