https://github.com/by1337/btcpapi
https://github.com/by1337/btcpapi
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/by1337/btcpapi
- Owner: By1337
- License: mit
- Created: 2024-03-15T21:23:04.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-06-02T15:15:29.000Z (12 months ago)
- Last Synced: 2025-02-04T14:45:48.168Z (4 months ago)
- Language: Java
- Size: 181 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BTCPApi
BTCPApi is a simple API for communication between a server and a client via TCP. This library was primarily created for data synchronization on Minecraft servers.
## Synchronization Architecture
All synchronization is built on the following system:
`client-plugin` -> `BTCP-plugin` -> `BTCP-server` -> `server-plugin`
## Installation
To use BTCPApi in your project, add the following dependencies to your `pom.xml`:
```xml
by1337
https://repo.by1337.space/repository/maven-releases/
org.by1337.tcpapi.api
BTCP-Api
1.0
provided
org.by1337.tcpapi.client
BTcpClient
1.0
provided
org.by1337.tcpapi.server
BTcpServer
1.0
provided
```
## Usage Examples
### Server
```java
ServerChannelStream stream = ServerManager.getChannelStreamManager().registerChannelStream(new SpacedNameKey("myPlugin:channel"), MyChannelListenerImpl);
for (Client client : stream.getAllClients()) {
stream.sendTo(client, new PacketPingRequest());
}
```### Client
```java
ClientChannelStream stream = Manager.getChannelStreamManager().registerChannelStream(new SpacedNameKey("myPlugin:channel"), MyChannelStreamPacketReaderImpl);
stream.register().lock(10_000);
if (stream.getStatus() != ChannelStatus.OPENED){
throw new IllegalStateException("Failed to establish connection with the TCP server!");
}
stream.write(new PacketPingRequest());
```## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.