mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix disconnect message formatting
This commit is contained in:
parent
22b962731c
commit
e0ae4c1b85
5 changed files with 25 additions and 15 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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));
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue