Skip to content

Commit 19c4347

Browse files
committed
[U] Clarify readme
1 parent eb7a192 commit 19c4347

File tree

1 file changed

+176
-26
lines changed

1 file changed

+176
-26
lines changed

README.md

Lines changed: 176 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,63 +23,76 @@ MCPM requires Java 19, which can be installed [here](https://www.oracle.com/java
2323

2424
MCPM runs in two environments:
2525

26+
- The **In-Game** environment, where you can configure your server in-game. (Recommended)
2627
- The **CLI** environment, where you can search, download, update and configure plugins from the command line.
27-
- The **In-Game** environment, where you can configure your server in-game.
2828

29-
To access the CLI environment on a Unix machine, you can use the `./mcpm` shortcut in the root directory.
30-
31-
```shell
32-
mcpm search JedCore # Look for plugins named JedCore
33-
mcpm install JedCore # Install it to our local directory!
34-
```
35-
36-
On a Windows machine, I recommend executing the shortcut via a bash emulator (Git Bash),
37-
launching the app yourself using `java`, or investigating the scripts in the /tools folder (run.py).
29+
### In-Game Environment
3830

3931
The In-Game environment is more involved and requires a server with our MCPM plugin.
4032

41-
You can quickly set up a test server using the `tools/start_server.py` script.
33+
To install MCPM as a plugin on an existing Bukkit-API Minecraft server (e.g. Spigot / Paper / Purpur / Pufferfish), you can go to [GitHub Releases](https://github.com/CSC207-2022F-UofT/mcpm/releases), download the latest version's jar, drag it into the `plugins` folder of your server, and restart the server.
34+
35+
However, if you are someone grading the course project, you probably don't have an existing minecraft server. You can easily set up a testing Minecraft server using the `tools/start_server.py` script on **Unix** (Linux / macOS).
4236
This script will automatically download the proper JDK to build and run the server environment.
37+
If you are using **Windows**, please run this script in the Windows Subsystem for Linux (WSL) environment.
4338

4439
```shell
4540
pip install -r requirements.txt
46-
python -m tools.start_server
41+
python -m tools.start_server
4742
```
4843

4944
When in-game, use the `/mcpm ...` slash command to start configuring plugins.
5045

5146
For example, if you wanted to search for plugins named `JedCore`, type `/mcpm search JedCore` in chat.
5247

53-
# Getting Help
48+
### CLI Environment
5449

55-
If you need a reminder of what mcpm provides, you can use the `-h` or `--help` argument to learn more.
50+
The CLI environment provides easy access across directories without having to install MCPM to a server. However, CLI usage provides a reduced set of features because hot reloading requires the server JVM environment. To access the CLI environment on a **Unix** machine, you can use the `./mcpm` shortcut in the root directory.
5651

52+
```shell
53+
mcpm search JedCore # Look for plugins named JedCore
54+
mcpm install JedCore # Install it to our local directory!
5755
```
58-
> mcpm --help
5956

60-
usage: mcpm [-h] {echo,export} ...
57+
On a Windows machine, I recommend running MCPM in the minecraft server environment. Alternatively, you can setup Windows Subsystem for Linux (WSL) to run everything as if you're using Linux.
58+
59+
# Getting Help
60+
61+
If you need a reminder of what mcpm provides, you can type in `mcpm` without arguments or use the `mcpm help` command.
6162

62-
positional arguments:
63-
echo: This is a dummy echo command that...
64-
export: This command allows you to export...
65-
66-
named arguments:
67-
-h, --help show this help message and exit
63+
```
64+
> mcpm help
65+
66+
mcpm: Minecraft Plugin Package Manager
67+
/mcpm export - Export plugin configuration
68+
/mcpm import - Import a plugins config from a previous export
69+
/mcpm list - List installed plugins
70+
/mcpm search - Search for a plugin in the database
71+
/mcpm mirror - Select a source (mirror) to download plugins from
72+
/mcpm info - Show the info of an installed plugin
73+
/mcpm install - Download and install a plugin from the database
74+
/mcpm refresh - Refresh cached plugin database
75+
/mcpm uninstall - Uninstall a plugin from file system
76+
/mcpm update - Updates plugins to the latest version.
77+
/mcpm load - Load a plugin in the plugins folder
78+
/mcpm reload - Reload a currently loaded plugin
79+
/mcpm unload - Unload a currently loaded plugin
80+
To view the help message of a command, use /mcpm <command> -h
6881
```
6982

7083
You can also learn more about the options that each subcommand provides by passing `-h` to them!
7184

7285
```
7386
> mcpm export --help
7487
75-
usage: mcpm export [-h] [-c {true,false}] outfile
88+
usage: mcpm export [-h] [{pastebin,file,literal}] [out]
7689
7790
positional arguments:
78-
outfile
91+
{pastebin,file,literal}
92+
out
7993
8094
named arguments:
81-
-h, --help show this help message and exit
82-
-c {true,false}, --cache {true,false}
95+
-h, --help
8396
```
8497

8598
# Search
@@ -201,3 +214,140 @@ mcpm export # export to a url
201214
mcpm export file plugins.txt # Export a list of all currently installed plugins into a file called plugins.txt.
202215
mcpm import file plugins.txt # Import (install) every plugin contained in the plugins.txt file.
203216
```
217+
218+
## MCPRS - Plugin Repository Server
219+
220+
The downloadable Spigot plugins and their meta info are stored on our server, hosted in Toronto 🇨🇦. If you live far from Canada, please consider switching to one of the mirrors below:
221+
222+
**North America** 🇺🇸
223+
224+
| Mirror URL (HTTPS) | Hosted By | Provider | Location | Speed | Update |
225+
|----------------------|-----------|-------------|---------------|----------|--------|
226+
| mcprs.hydev.org | HyDEV | OVH Hosting | 🇨🇦 Montreal | 100 Mbps | 1 day |
227+
| mcprs-bell.hydev.org | HyDEV | Bell Canada | 🇨🇦 Toronto | 750 Mbps | 1 day |
228+
229+
**Europe** 🇪🇺
230+
231+
| Mirror URL (HTTPS) | Hosted By | Provider | Location | Speed | Update |
232+
|---------------------|-----------|------------|-----------------|----------|--------|
233+
| mcprs-lux.hydev.org | HyDEV | GCore Labs | 🇱🇺 Luxembourg | 200 Mbps | 1 day |
234+
235+
**Asia**
236+
237+
| Mirror URL (HTTPS) | Hosted By | Provider | Location | Speed | Update |
238+
|-----------------------|-----------|----------|------------|----------|--------|
239+
| mcprs-tokyo.hydev.org | HyDEV | Vultr | 🇯🇵 Tokyo | 200 Mbps | 1 day |
240+
241+
If you want to contribute your network traffic by setting up a mirror, feel free to check out [How to set up a mirror](#How to set up a mirror)
242+
243+
### How to set up a mirror
244+
245+
The MCPRS server is hosted with a plain file server that supports both http and rsync. The official server is hosted using Nginx, but any file server with such compatibility would work. You can follow one of the approaches below to set up a mirror.
246+
247+
After setting up a mirror, if you want to add it to our mirror list, you can submit a pull request to this repo editing the [mirrorlist.yml](mirrorlist.yml) file.
248+
249+
#### Setup Mirror using Docker Compose
250+
251+
For convenience, we created a docker image so that you can set up a mirror using Docker. It will automatically set up:
252+
253+
1. `mcprs-sync`: Script to automatically sync updates every 24 hours (configurable)
254+
2. `mcprs-rsyncd`: rsync server
255+
3. `mcprs-nginx`: HTTP server (without SSL). This is only recommended if you don't have any other HTTP services set up
256+
257+
You need to install docker and docker-compose, then you need to run:
258+
259+
```bash
260+
git clone https://github.com/CSC207-2022F-UofT/mcpm
261+
cd mcpm/tools/mirror
262+
263+
# Then, you should review or edit the docker-compose.yml script. After that:
264+
265+
sudo mkdir -p /data/mcprs
266+
267+
# If you want to start everything (including nginx):
268+
sudo docker-compose up -d
269+
270+
# Or if you want to start sync and rsyncd but want to use your own HTTP server, do:
271+
sudo docker-compose up mcprs-sync mcprs-rsyncd -d
272+
```
273+
274+
Note: If `docker-compose` says command not found, try `docker compose` instead.
275+
276+
#### Setup Mirror Manually
277+
278+
You can sync all files from an existing mirror by using `rsync`, run rsync automatically using `crontab` or systemd timer, and hosting the synchronized local directory using `nginx`.
279+
280+
```bash
281+
# Use rsync to sync
282+
alias rsync1="rsync -rlptH --info=progress2 --safe-links --delete-delay --delay-updates --timeout=600 --contimeout=60 --no-motd"
283+
rsync1 "SOURCE_URL" "LOCAL_DIR"
284+
```
285+
286+
```nginx.conf
287+
# /etc/nginx/conf.d/mcprs.conf
288+
# Make sure to include this sub-config in your /etc/nginx/nginx.conf
289+
# You can do "include /etc/nginx/conf.d/*.conf;"
290+
# After testing the http server works, you can use certbot to obtain a HTTPS certificate
291+
server
292+
{
293+
listen 443 ssl;
294+
listen [::]:443 ssl;
295+
server_name mcprs.example.com; # TODO: Change this to your domain
296+
297+
root LOCAL_DIR; # TODO: Change this to your filesystem location
298+
299+
location / {
300+
autoindex on;
301+
}
302+
}
303+
304+
# HTTPS Redirect
305+
server
306+
{
307+
listen 80 default_server;
308+
listen [::]:80 default_server;
309+
server_name default;
310+
return 301 https://$host$request_uri;
311+
}
312+
```
313+
314+
```rsyncd.conf
315+
# /etc/rsyncd.conf
316+
uid = nobody
317+
gid = nobody
318+
use chroot = no
319+
max connections = 4
320+
syslog facility = local5
321+
pid file = /run/rsyncd.pid
322+
323+
[mcprs]
324+
path = /ws/mcpm/.mcpm
325+
comment = MCPM Plugin Repository Server
326+
```
327+
328+
### How does the server work?
329+
330+
Server file/endpoint structure:
331+
332+
`/db` : Database sync
333+
`/db/core.json` : Core database (plain text)
334+
`/db/core.zst` : Core database (compressed)
335+
`/pkgs` : List of packages
336+
`/pkgs/spiget` : Raw Spiget packages indexed by resource ids and version ids
337+
`/pkgs/spiget/{resource-id}` : One Spiget resource
338+
`/pkgs/spiget/{resource-id}/{version-id}` : One Spiget version
339+
`/pkgs/spiget/{resource-id}/{version-id}/release.jar` : Jar published by the developer
340+
`/pkgs/spiget/{resource-id}/{version-id}/plugin.yml` : Meta info
341+
`/pkgs/links` : Generated symbolic links indexed by names and version names
342+
`/pkgs/links/{name}` : One package
343+
`/pkgs/links/{name}/{version}` : One version
344+
`/pkgs/links/{name}/{version}/release.jar` : Prebuilt jar for the version of a package
345+
`/pkgs/links/{name}/{version}/plugin.yml` : Meta info for the version of a package
346+
347+
Internal server file structure:
348+
349+
`/crawler` : Crawler cache / data storage
350+
`/crawler/spiget` : Spiget crawler
351+
`/crawler/spiget/resources.json` : List of all resources on SpigotMC
352+
`/crawler/spiget/backups/resources.{timestamp}.json` : Older resources
353+
`/cralwer/spiget/versions/{resource_id}.json` : Resource versions info

0 commit comments

Comments
 (0)