mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Merge branch 'master' of https://github.com/GeyserMC/Geyser into crash-fix
# Conflicts: # connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
This commit is contained in:
parent
def12b0b8d
commit
2e0f41afea
1 changed files with 40 additions and 0 deletions
|
|
@ -0,0 +1,40 @@
|
|||
package org.geysermc.connector.thread;
|
||||
|
||||
import com.github.steveice10.mc.protocol.MinecraftConstants;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.mc.protocol.data.SubProtocol;
|
||||
import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo;
|
||||
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoHandler;
|
||||
import com.github.steveice10.packetlib.Client;
|
||||
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
|
||||
public class PingPassthroughThread implements Runnable {
|
||||
|
||||
private GeyserConnector connector;
|
||||
|
||||
public PingPassthroughThread(GeyserConnector connector) {
|
||||
this.connector = connector;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private ServerStatusInfo info;
|
||||
|
||||
private Client client;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
this.client = new Client(connector.getConfig().getRemote().getAddress(), connector.getConfig().getRemote().getPort(), new MinecraftProtocol(SubProtocol.STATUS), new TcpSessionFactory());
|
||||
this.client.getSession().setFlag(MinecraftConstants.SERVER_INFO_HANDLER_KEY, (ServerInfoHandler) (session, info) -> {
|
||||
this.info = info;
|
||||
this.client.getSession().disconnect(null);
|
||||
});
|
||||
|
||||
client.getSession().connect();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue