diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index df45c9d43..ea48ad40e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -29,7 +29,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 cache: npm - name: Setup Pages uses: actions/configure-pages@v5 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index af6568d7b..25f8444ee 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -53,9 +53,10 @@ jobs: - run: cargo test --verbose build_release: name: Build project in release - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ubuntu-latest, windows-latest, macos-latest] toolchain: - stable @@ -65,6 +66,11 @@ jobs: - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} - run: cargo build --verbose --release + - name: Export executable + uses: actions/upload-artifact@v4 + with: + name: pumpkin-${{ matrix.os }} + path: target/${{ matrix.target }}/release/pumpkin* clippy_release: name: Run lints in release mode runs-on: ubuntu-latest @@ -77,5 +83,5 @@ jobs: - uses: actions/checkout@v4 - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} - - - run: cargo clippy --release --all-targets --all-features --no-default-features -- -D warnings \ No newline at end of file + + - run: cargo clippy --release --all-targets --all-features --no-default-features -- -D warnings diff --git a/pumpkin/src/client/authentication.rs b/pumpkin/src/client/authentication.rs index 195dfa2ae..ade959cc3 100644 --- a/pumpkin/src/client/authentication.rs +++ b/pumpkin/src/client/authentication.rs @@ -50,7 +50,7 @@ pub struct GameProfile { /// 2. Mojang's servers verify the client's credentials and add the player to the their Servers /// 3. Now our server will send a Request to the Session servers and check if the Player has joined the Session Server . /// -/// **Note:** This process helps prevent unauthorized access to the server and ensures that only legitimate Minecraft accounts can connect. +/// See pub async fn authenticate( username: &str, server_hash: &str, diff --git a/pumpkin/src/client/mod.rs b/pumpkin/src/client/mod.rs index 2fcd008a9..47ed87e9c 100644 --- a/pumpkin/src/client/mod.rs +++ b/pumpkin/src/client/mod.rs @@ -362,22 +362,19 @@ impl Client { /// Close connection when an error occurs or when the Client closed the connection pub async fn poll(&self, event: &Event) { if event.is_readable() { - let mut received_data = vec![0; 4096]; - let mut bytes_read = 0; + let mut received_data = vec![]; + let mut buf = [0; 4096]; loop { let connection = self.connection.clone(); let mut connection = connection.lock(); - match connection.read(&mut received_data[bytes_read..]) { + match connection.read(&mut buf) { Ok(0) => { // Reading 0 bytes means the other side has closed the // connection or is done writing, then so are we. self.close(); break; } - Ok(n) => { - bytes_read += n; - received_data.extend(&vec![0; n]); - } + Ok(n) => received_data.extend(&buf[..n]), // Would block "errors" are the OS's way of saying that the // connection is not actually ready to perform this I/O operation. Err(ref err) if would_block(err) => break, @@ -387,9 +384,9 @@ impl Client { } } - if bytes_read != 0 { + if received_data.len() != 0 { let mut dec = self.dec.lock(); - dec.queue_slice(&received_data[..bytes_read]); + dec.queue_slice(&received_data); match dec.decode() { Ok(packet) => { if let Some(packet) = packet {