Metadata-Version: 2.3
Name: nebulous.py
Version: 1.0.0
Summary: A Python library for utilizing the Nebulous.io UDP protocol.
Project-URL: Documentation, https://github.com/yntha/nebulous.py#readme
Project-URL: Issues, https://github.com/yntha/nebulous.py/issues
Project-URL: Source, https://github.com/yntha/nebulous.py
Author-email: yntha <126660548+yntha@users.noreply.github.com>
License-Expression: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.12
Requires-Dist: multiprocess>=0.70.16
Requires-Dist: pydatastreams>=1.2.6
Requires-Dist: requests>=2.32.3
Description-Content-Type: text/markdown

# nebulous.py

[![PyPI - Version](https://img.shields.io/pypi/v/nebulous.py.svg)](https://pypi.org/project/nebulous.py)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/nebulous.py.svg)](https://pypi.org/project/nebulous.py)

-----

**Table of Contents**

- [Installation](#installation)
- [License](#license)
- [Usage](#usage)

## Installation
1. Install [git](https://git-scm.com/downloads)
2. Install [`java-random`](https://github.com/MostAwesomeDude/java-random): `python -m pip install --user git+https://github.com/MostAwesomeDude/java-random`
    - NOTE: This is a required step, as the `java-random` package on pypi is outdated and broken.
3. Install `nebulous.py`: `python -m pip install --user nebulous.py`

## Usage
From [`test_connect.py`](tests/test_connect.py):
```python
import time

from nebulous.game.account import ServerRegions
from nebulous.game.models.client import Client, ClientCallbacks
from nebulous.game.packets import ConnectRequest3, ConnectResult2, Disconnect, KeepAlive


TEST_TICKET = ""


class TestCallbacks(ClientCallbacks):
    def on_connect(self, client: Client, packet: ConnectRequest3) -> ConnectRequest3:
        print("Connected to server")
        return packet

    def on_disconnect(self, client: Client, packet: Disconnect) -> Disconnect:
        print("Disconnected from server")
        return packet

    def on_keep_alive(self, client: Client, packet: KeepAlive) -> KeepAlive:
        print("Sending keep alive packet")
        return packet

    def on_connect_result(self, client: Client, packet: ConnectResult2) -> ConnectResult2:
        print(f"Received connection result: {packet.result}")
        return packet


def test_client():
    client = Client(TEST_TICKET, ServerRegions.US_EAST, callbacks=TestCallbacks())

    client.start()

    # disconnect after 3 seconds.
    # can also use client.run_forever() to keep the client running indefinitely
    # until ctrl+c is pressed.
    time.sleep(3)

    client.stop()


if __name__ == "__main__":
    test_client()
```

## License

`nebulous.py` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
