mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Add SessionInitialize event (#3691)
* Add SessionInitialize event * Move to using GeyserConnection instead of BedrockServerSession * Remove redundent re-expose * Rename geyserSession to just session
This commit is contained in:
parent
f39e689b83
commit
2ac7eb83c0
2 changed files with 44 additions and 1 deletions
|
@ -32,6 +32,8 @@ import org.cloudburstmc.protocol.bedrock.BedrockPeer;
|
|||
import org.cloudburstmc.protocol.bedrock.BedrockServerSession;
|
||||
import org.cloudburstmc.protocol.bedrock.netty.initializer.BedrockServerInitializer;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.event.bedrock.SessionInitializeEvent;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserPreInitializeEvent;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -49,7 +51,9 @@ public class GeyserServerInitializer extends BedrockServerInitializer {
|
|||
public void initSession(@Nonnull BedrockServerSession bedrockServerSession) {
|
||||
try {
|
||||
bedrockServerSession.setLogging(true);
|
||||
bedrockServerSession.setPacketHandler(new UpstreamPacketHandler(this.geyser, new GeyserSession(this.geyser, bedrockServerSession, this.eventLoopGroup.next())));
|
||||
GeyserSession session = new GeyserSession(this.geyser, bedrockServerSession, this.eventLoopGroup.next());
|
||||
bedrockServerSession.setPacketHandler(new UpstreamPacketHandler(this.geyser, session));
|
||||
this.geyser.eventBus().fire(new SessionInitializeEvent(session));
|
||||
} catch (Throwable e) {
|
||||
// Error must be caught or it will be swallowed
|
||||
this.geyser.getLogger().error("Error occurred while initializing player!", e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue