## CrossCraft Public Server Alpha ##

This is the official C++ server for CrossCraft Online (compatible with client version 0.0.13a_01).
It replaces the previous Python server with a faster, native implementation.

## How to start the server ##

Windows:

Double-click "start server.bat" or run in Command Prompt:
CrossCraftServer.exe

Linux / macOS:

Open a terminal in the server folder and run:
./CrossCraftServer

The server will create default configuration files on first launch.

## How to connect to your server ##

To run a private server, set isPublic to false in the properties.
Players can join by opening the following address in their browser:
https://crosscraftweb.ddns.net/play.jsp?ip=<YOUR IP>&port=<SERVER PORT>

If the server runs on the same computer as the client, use `localhost` or `127.0.0.1` as the IP.

To allow friends over the internet to connect, you need to forward the port (default 25565)
in your router or use a VPN tool like Radmin VPN / Hamachi.

## Server configuration ##

All settings are stored in `server.properties`. The server will generate this file with defaults
if it does not exist. Important options:

* server-name         Name shown in the server list
* motd                Description
* port                TCP port to listen on (default: 25565)
* max-players         Maximum number of players (1-128)
* public              Set to 'true' to list your server on the CrossCraft website
* verify-names        Set to 'true' to require a valid CrossCraft account
* max-connections     Maximum connections per IP address (default: 3)

## Admin commands ##

Add your username to `admins.txt` (one per line) or use `/op <name>` from the console to become an operator.

Ingame, ops can use these commands:
  /op <name>          Ops a player.
  /deop <name>        De-ops a player.
  /kick <name> [reason]  Kicks a player (optional reason).
  /ban <name>         Bans a player.
  /unban <name>       Pardons a banned player.
  /banip <name>       Bans a player by IP. Unban manually in banned-ip.txt.
  /say <message>      Broadcasts a message to all players.
  /setspawn           Sets the current location as the spawn point for new players.
  /tp <name>          Teleports you to the named player.
  /solid              Toggles between normal and unbreakable stone placement.

Most commands can also be typed directly into the server console (stdin).

## Ban management ##

- Banned usernames are stored in `banned.txt`
- Banned IP addresses are stored in `banned-ip.txt`
- To lift a ban, edit the corresponding file and restart the server.

## Additional files ##

- `admins.txt`          List of operators (one username per line)
- `banned.txt`          Banned usernames
- `banned-ip.txt`       Banned IP addresses
- `players.txt`         Log of player connections
- `externalurl.txt`     Contains the direct join link generated by the heartbeat

## Changelog:

Version 1.6.5

+ Possibly fixed a server bug where it wouldn't let anyone join after running for a long time

Version 1.6.4

+ Significantly reduced idle CPU usage by optimizing the server loop and network polling

Version 1.6.3

+ Fix mutex in Network.cpp
+ Added ignore SIGPIPE on Unix

Version 1.6.2

+ Added try-catch in threads

Version 1.6.1

+ /say command fixed
+ Fixed level data request

Version 1.6

+ Rewrote the entire server in C++ for better performance and stability
+ Fixed falling phantom blocks on client
+ Added /op, /deop, /kick, /ban, /unban, /banip, /say, /setspawn, /tp, /solid commands
+ Server console input (stdin) for admin commands
+ Public server listing via heartbeat (with unique salt)
+ Automatic externalurl.txt generation
+ Session verification against CrossCraft accounts (verify-names)
+ Configurable max-connections per IP
+ Level saving and loading
+ GZip compressed level transmission
+ Cross-platform support (Windows, Linux, macOS)

Version 1.5

+ Fixed block removal when placing a sponge near the level border.

Version 1.4

+ Added more new blocks from 0.0.10a

Version 1.3

+ Added sponge logic

Version 1.2

+ Added teleport command

Version 1.1

+ Added Player List on TAB (Client-side)
+ Added /setspawn command for admins
+ Added /op, /deop, /unban commands for admins
+ Added server-side name verification (verify-names)
+ Added logged-in.txt to show current players
+ The server now generates externalurl.txt with the direct join link
+ Added basic anti-packet-spam protection
+ Improved configuration file handling