com.github.steveice10.packetlib.Client Java Examples

The following examples show how to use com.github.steveice10.packetlib.Client. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Bot.java    From LambdaAttack with MIT License 6 votes vote down vote up
public void connect(String host, int port) {
    Client client = new Client(host, port, account.getProtocol(), new TcpSessionFactory(proxy));
    this.session = client.getSession();

    switch (account.getGameVersion()) {
        case VERSION_1_11:
            client.getSession().addListener(new SessionListener111(options, this));
            break;
        case VERSION_1_12:
            client.getSession().addListener(new SessionListener112(options, this));
            break;
        case VERSION_1_14:
            client.getSession().addListener(new SessionListener114(options, this));
            break;
        case VERSION_1_15:
            client.getSession().addListener(new SessionListener115(options, this));
            break;
        default:
            throw new IllegalStateException("Unknown session listener");
    }

    client.getSession().connect();
}
 
Example #2
Source File: GeyserLegacyPingPassthrough.java    From Geyser with MIT License 5 votes vote down vote up
@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.pingInfo = new GeyserPingInfo(info.getDescription().getFullText(), info.getPlayerInfo().getOnlinePlayers(), info.getPlayerInfo().getMaxPlayers());
            this.client.getSession().disconnect(null);
        });

        client.getSession().connect();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
Example #3
Source File: TestProtocol.java    From PacketLib with MIT License 4 votes vote down vote up
@Override
public void newClientSession(Client client, Session session) {
    session.addListener(new ClientSessionListener());
}
 
Example #4
Source File: TcpSessionFactory.java    From PacketLib with MIT License 4 votes vote down vote up
@Override
public Session createClientSession(final Client client) {
    return new TcpClientSession(client.getHost(), client.getPort(), client.getPacketProtocol(), client, this.clientProxy);
}
 
Example #5
Source File: TcpClientSession.java    From PacketLib with MIT License 4 votes vote down vote up
public TcpClientSession(String host, int port, PacketProtocol protocol, Client client, ProxyInfo proxy) {
    super(host, port, protocol);
    this.client = client;
    this.proxy = proxy;
}
 
Example #6
Source File: PacketProtocol.java    From PacketLib with MIT License 2 votes vote down vote up
/**
 * Called when a client session is created with this protocol.
 *
 * @param client  The client that the session belongs to.
 * @param session The created session.
 */
public abstract void newClientSession(Client client, Session session);