bukkitstr/README.md

109 lines
3.7 KiB
Markdown

# BukkitstrPlugin
BukkitstrPlugin is a Minecraft plugin that integrates with the Nostr relay to authenticate players. Players must authenticate by signing a valid Nostr event before they can move in the game.
## Demo
<video height="480" width="270" controls src="https://v.nostr.build/5XxsgV03wlo1iCPW.mp4"></video>
## Features
- **WebSocket Integration**: Connects to a Nostr relay using WebSockets.
- **Player Authentication**: Players must authenticate with their Minecraft username via a Nostr event.
- **Movement Lock**: Prevents players from moving until they are authenticated.
- **Real-time Messaging**: Sends and receives messages from the Nostr relay in real-time.
## Prerequisites
- **Java 8 or higher**
- **Maven** (for building the plugin)
- **Spigot/Paper** server (Minecraft 1.20 or higher)
- You must sign a kind 30078 to store your username/pubkey
- "d" "bukkitstr"
- "minecraft" "Your Minecraft User Name"
- "nostr" "Your PUBkey hex"
## Installation
1. **Clone the repository**:
```sh
git clone https://git.vanderwarker.family/nostr/bukkitstr.git
cd bukkitstr
```
2. **Configure the plugin**:
Make sure to replace `wss://your-nostr-relay-url` in the `BukkitstrPlugin.java` file with your actual Nostr relay WebSocket URL.
3. **Build the plugin**:
```sh
mvn clean package
```
4. **Copy the plugin JAR**:
Copy the generated `bukkitstr-plugin-1.0-SNAPSHOT.jar` file from the `target` directory to your Minecraft server's `plugins` directory.
5. **Start your server**:
Start your Minecraft server and check the console for any errors. The plugin should initialize and connect to the Nostr relay.
## Usage
### Authentication Command
Players need to use the `/auth` command to start the authentication process. The plugin will wait for a Nostr event containing the player's Minecraft username in the `d` tag content.
```sh
/auth
```
### Sign Event
Next, you need to sign a event kind "13378008" and the "d" tag to be your Minecraft username.
Using [nostril](https://github.com/jb55/nostril) is quite easy.
```sh
nostril --kind 13378008 --tag "d" "MinecraftUsername"
```
Then send to the relay you've specified in src/../BukkitstrPlugin.java
### Player Authentication Process
1. **Connect to the Nostr relay**: The plugin connects to the specified Nostr relay when the server starts.
2. **Send Authentication Request**: The plugin sends an initial request to the Nostr relay to listen for authentication events.
3. **Wait for Nostr Event**: When a player uses the `/auth` command, the plugin waits for a Nostr event containing the player's username in the `d` tag.
4. **Authenticate Player**: If the received Nostr event's `d` tag content matches the player's username, the player is authenticated and can move freely. Otherwise, they will receive an authentication failure message.
## Developer Information
### Source Code
The main source code is located in the `src/main/java/family/vanderwarker/bukkitstr/BukkitstrPlugin.java` file.
### Dependencies
Ensure the following dependencies are added to your `pom.xml`:
```xml
<dependencies>
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.3</version>
</dependency>
</dependencies>
```
## Acknowledgments
- Thanks to the SpigotMC community for their documentation and support.
- Thanks to the Nostr community for their innovative protocol.
- Thanks to [npub1826v365he5ty69lk3xgvzqrwy8587vdfrxnsz0k09khzustf8r7s6j7t95](nostr:npub1826v365he5ty69lk3xgvzqrwy8587vdfrxnsz0k09khzustf8r7s6j7t95)
- Thanks to ChatGPT 4.o