3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 15:00:11 +01:00

Fix disconnect message formatting

Dieser Commit ist enthalten in:
Camotoy 2021-09-21 14:34:17 -04:00
Ursprung 22b962731c
Commit e0ae4c1b85
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
5 geänderte Dateien mit 25 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -140,17 +140,17 @@ public class GeyserSession implements CommandSender {
private final SessionPlayerEntity playerEntity; private final SessionPlayerEntity playerEntity;
private AdvancementsCache advancementsCache; private final AdvancementsCache advancementsCache;
private BookEditCache bookEditCache; private final BookEditCache bookEditCache;
private ChunkCache chunkCache; private final ChunkCache chunkCache;
private EntityCache entityCache; private final EntityCache entityCache;
private EntityEffectCache effectCache; private final EntityEffectCache effectCache;
private final FormCache formCache; private final FormCache formCache;
private final LodestoneCache lodestoneCache; private final LodestoneCache lodestoneCache;
private final PistonCache pistonCache; private final PistonCache pistonCache;
private final PreferencesCache preferencesCache; private final PreferencesCache preferencesCache;
private final TagCache tagCache; private final TagCache tagCache;
private WorldCache worldCache; private final WorldCache worldCache;
private final Int2ObjectMap<TeleportCache> teleportMap = new Int2ObjectOpenHashMap<>(); private final Int2ObjectMap<TeleportCache> teleportMap = new Int2ObjectOpenHashMap<>();
@ -884,16 +884,9 @@ public class GeyserSession implements CommandSender {
} }
if (tickThread != null) { if (tickThread != null) {
tickThread.cancel(true); tickThread.cancel(false);
} }
this.advancementsCache = null;
this.bookEditCache = null;
this.chunkCache = null;
this.entityCache = null;
this.effectCache = null;
this.worldCache = null;
closed = true; closed = true;
} }

Datei anzeigen

@ -31,4 +31,11 @@ public abstract class PacketTranslator<T> {
public abstract void translate(GeyserSession session, T packet); public abstract void translate(GeyserSession session, T packet);
/**
* Determines if this packet should be handled in the session's event loop. This should generally be true -
* only when the packet has to be executed immediately should it be false.
*/
public boolean shouldExecuteInEventLoop() {
return true;
}
} }

Datei anzeigen

@ -90,7 +90,7 @@ public class PacketTranslatorRegistry<T> {
PacketTranslator<P> translator = (PacketTranslator<P>) translators.get(clazz); PacketTranslator<P> translator = (PacketTranslator<P>) translators.get(clazz);
if (translator != null) { if (translator != null) {
EventLoop eventLoop = session.getEventLoop(); EventLoop eventLoop = session.getEventLoop();
if (eventLoop.inEventLoop()) { if (!translator.shouldExecuteInEventLoop() || eventLoop.inEventLoop()) {
translate0(session, translator, packet); translate0(session, translator, packet);
} else { } else {
eventLoop.execute(() -> translate0(session, translator, packet)); eventLoop.execute(() -> translate0(session, translator, packet));

Datei anzeigen

@ -38,4 +38,9 @@ public class JavaDisconnectPacket extends PacketTranslator<ServerDisconnectPacke
public void translate(GeyserSession session, ServerDisconnectPacket packet) { public void translate(GeyserSession session, ServerDisconnectPacket packet) {
session.disconnect(MessageTranslator.convertMessage(packet.getReason(), session.getLocale())); session.disconnect(MessageTranslator.convertMessage(packet.getReason(), session.getLocale()));
} }
@Override
public boolean shouldExecuteInEventLoop() {
return false;
}
} }

Datei anzeigen

@ -39,4 +39,9 @@ public class JavaLoginDisconnectTranslator extends PacketTranslator<LoginDisconn
// The client doesn't manually get disconnected so we have to do it ourselves // The client doesn't manually get disconnected so we have to do it ourselves
session.disconnect(MessageTranslator.convertMessage(packet.getReason(), session.getLocale())); session.disconnect(MessageTranslator.convertMessage(packet.getReason(), session.getLocale()));
} }
@Override
public boolean shouldExecuteInEventLoop() {
return false;
}
} }