|
| 1 | +# sanctuary [](https://github.com/Picoseconds/sanctuary/graphs/commit-activity) [](https://github.com/microsoft/TypeScript/) |
| 2 | +Sanctuary is a private server implementation for the game MooMoo.io. |
| 3 | + |
| 4 | +## Features |
| 5 | +See [Issue #16](https://github.com/Picoseconds/sanctuary/issues/16) for a list of current features supported. |
| 6 | + |
| 7 | +## Getting started |
| 8 | +1. Clone the repo |
| 9 | +``` |
| 10 | +git clone https://github.com/Picoseconds/sanctuary.git |
| 11 | +``` |
| 12 | +2. Compile with `npm run build` **OR** `yarn build` depending on your package manager of choice. |
| 13 | +3. Run the server with `npm start`/`yarn start` |
| 14 | + |
| 15 | +## Project Scope |
| 16 | +The goal of the Sanctuary project is to create a customizable, modular private server for MooMoo.io. This means that some features will be implemented differently to support configuration using environment variables. |
| 17 | + |
| 18 | +See [Environment Variables](#environment-variables). |
| 19 | + |
| 20 | +### Environment variables |
| 21 | +| Variable name | Effect | |
| 22 | +| ------------------------ | ------------------------------------------------------------------------------------------------------------------------- | |
| 23 | +| PORT | The port that the server binds on, defaults to 3000. | |
| 24 | +| MAX_CPS | The CPS cap to use, defaults to 25. | |
| 25 | +| PLAYER_NEARBY_RADIUS | The radius that players can see other players in. | |
| 26 | +| GAMEOBJECT_NEARBY_RADIUS | The radius that players can see structures (this includes trees, bushes and all other naturally generated structures) in. | |
| 27 | +| MODERATOR_PASSWORD | See [Password Login System](#password-login-system) | |
| 28 | + |
| 29 | +This project utilises .env files with the `dotenv` module for configuration. Simply make a file named `.env` in the root of the cloned repo, and populate it with environment variables. |
| 30 | + |
| 31 | +A .env file is similar to a Unix shell file, and uses the same syntax for assigning environment variables. |
| 32 | +Sample .env file: |
| 33 | +```bash |
| 34 | +PORT=8080 |
| 35 | +MAX_CPS=20 |
| 36 | +MODERATOR_PASSWORD=password123 |
| 37 | +``` |
| 38 | + |
| 39 | +## Moderation Commands |
| 40 | +| Command | Use | |
| 41 | +| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | |
| 42 | +| set \<player id> \<health/food/wood/stone/kills/xp/gold> \<number> | Sets the specified numerical attribute of a player to the specified number. | |
| 43 | +| tp \<destination player id> | Teleports you to the player specified. | |
| 44 | +| invisible | Toggles invisibility. You can see yourself, but others cannot see you. | |
| 45 | +| invincible | Toggles invincibility. | |
| 46 | +| promote \<player id> | Makes someone else a moderator. | |
| 47 | +| ban \<player id> | Bans someone by IP address. Moderators cannot be banned. | |
| 48 | +| kick \<player id> | Kicks a user. | |
| 49 | +| broadcast \<message> | Displays a message in the top left of everyone's screen (including yours). | |
| 50 | +| restart | Stops the server. | |
| 51 | +| speed \<speed multiplier> | Changes your speed. | |
| 52 | +| weaponVariant \<ruby/gold/diamond/normal> [player id (defaults to yourself)] | Changes the variant of the currently selected weapon of the player. | |
| 53 | +| login \<password> | See [Password Login System](#password-login-system) | |
| 54 | + |
| 55 | +Commands can be called from the terminal that Sanctuary is run from, and from chat. |
| 56 | + |
| 57 | +While Sanctuary doesn't enforce this with chat commands, with the normal MooMoo.io client, chat has a 15 character limit. |
| 58 | +When called from chat, commands must be prefixed with a `/` (slash) to differentiate them from normal chat. |
| 59 | + |
| 60 | +The player ID can be found from the API, or by the number beside the player's name. |
| 61 | + |
| 62 | +## Password Login System |
| 63 | +Sanctuary provides an additional login system for cases where not all moderators can be fully trusted. In this scheme, a password is used. The password is set with the environment variable `MODERATOR_PASSWORD`. |
| 64 | +Admins utilize the `/login` command to log in. A major problem with this system's current implementation is that these temporary "admins" are able to use `/promote` to become permanent admins, so this system is not quite ready for production. |
| 65 | + |
| 66 | +## REST API |
| 67 | +Sanctuary implements a rudimentary REST API, with only two endpoints: |
| 68 | +### `/api/v1/players` |
| 69 | +Lists the currently connected clients. Output takes the following format (as a TypeScript type): |
| 70 | +```ts |
| 71 | +{ |
| 72 | + 'type': 'success' | 'error', |
| 73 | + 'clients': { playerName: string = 'unknown', playerID: number = -1, clientIPHash: string }[] | undefined, |
| 74 | + 'message': string | undefined |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +### `/api/v1/playerCount` |
| 79 | +Reports the amount of currently connected clients. Output takes the following format (as a TypeScript type): |
| 80 | +```ts |
| 81 | +{ |
| 82 | + 'type': 'success' | 'error', |
| 83 | + 'playerCount': number | undefined, |
| 84 | + 'message': string | undefined |
| 85 | +} |
| 86 | +``` |
0 commit comments