Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Sanity check for queued messages
Dieser Commit ist enthalten in:
Ursprung
4213c4cce5
Commit
3529d6a229
@ -277,12 +277,13 @@ public final class EntityPackets extends EntityRewriter<Protocol1_19To1_18_2> {
|
|||||||
displayPreviewPacket.write(Type.BOOLEAN, false);
|
displayPreviewPacket.write(Type.BOOLEAN, false);
|
||||||
displayPreviewPacket.send(Protocol1_19To1_18_2.class);
|
displayPreviewPacket.send(Protocol1_19To1_18_2.class);
|
||||||
|
|
||||||
final QueuedMessagesStorage messagesStorage = wrapper.user().remove(QueuedMessagesStorage.class);
|
final QueuedMessagesStorage messagesStorage = wrapper.user().get(QueuedMessagesStorage.class);
|
||||||
if (messagesStorage == null) {
|
if (messagesStorage.hasSent()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Queue<QueuedMessagesStorage.Message> messages = messagesStorage.messages();
|
final Queue<QueuedMessagesStorage.Message> messages = messagesStorage.messages();
|
||||||
|
messagesStorage.setSent();
|
||||||
if (messages.isEmpty()) {
|
if (messages.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -19,18 +19,27 @@ package com.viaversion.viaversion.protocols.protocol1_19to1_18_2.storage;
|
|||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
public final class QueuedMessagesStorage implements StorableObject {
|
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;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasSent() {
|
||||||
|
return messages == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSent() {
|
||||||
|
messages = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean clearOnServerSwitch() {
|
public boolean clearOnServerSwitch() {
|
||||||
return false;
|
return false;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren