Initial commit
This commit is contained in:
commit
10729c2702
17
Containerfile
Normal file
17
Containerfile
Normal file
@ -0,0 +1,17 @@
|
||||
FROM python:3.13-slim
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the current directory contents into the container at /app
|
||||
COPY minecraft-plugin-proxy.py /app
|
||||
COPY requirements.txt /app
|
||||
|
||||
# Install any needed packages specified in requirements.txt
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Make port 8000 available to the world outside this container.
|
||||
EXPOSE 8000
|
||||
|
||||
# Serve the API
|
||||
CMD ['fastapi', 'run', '--port', '8000', '/app/minecraft-plugin-proxy.py']
|
||||
28
README.md
Normal file
28
README.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Minecraft Plugin Proxy
|
||||
|
||||
Are you a Minecraft sysadmin using a containerized setup? Are you sick of dealing with plugins that don't support downloading the latest version via REST API? Then this is the project for you!
|
||||
|
||||
This project is a proxy server that will find the latest version of a plugin and redirect you to the download link.
|
||||
|
||||
All of the plugins have custom hard-coded logic that will find the latest version of the plugin and redirect you to the download link.
|
||||
|
||||
## Usage
|
||||
|
||||
Include the minecraft-plugin-proxy as a service in your compose unit:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
minecraft-plugin-proxy:
|
||||
image: ghcr.io/epicshepich/minecraft-plugin-proxy:latest
|
||||
```
|
||||
|
||||
Services in your compose unit can access the proxy server at `http://minecraft-plugin-proxy:8080` with the following query parameters:
|
||||
|
||||
|
||||
## Endpoints
|
||||
|
||||
The following endpoints are currently available:
|
||||
|
||||
- `/viabackwards/velocity`: ViaBackwards for the Velocity proxy container.
|
||||
- `/luckperms/{server_type}`: LuckPerms for the specified server type (e.g. `bukkit`, `bungeecord`, `velocity`).
|
||||
- `/tribufu-velocityrcon`: Tribufu's VelocityRcon plugin for the Velocity proxy container.
|
||||
3
build.sh
Normal file
3
build.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
podman build -t minecraft-plugin-proxy:latest -t minecraft-plugin-proxy:$(cat ./.version) .
|
||||
43
minecraft-plugin-proxy.py
Normal file
43
minecraft-plugin-proxy.py
Normal file
@ -0,0 +1,43 @@
|
||||
'''
|
||||
A proxy built on FastAPI to find the most recent version of a Minecraft plugin.
|
||||
'''
|
||||
|
||||
import requests
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import RedirectResponse
|
||||
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
api = FastAPI()
|
||||
|
||||
@api.get('/viabackwards/velocity')
|
||||
async def viabackwards_velocity():
|
||||
|
||||
latest_release = requests.get(
|
||||
'https://hangar.papermc.io/api/v1/projects/ViaVersion/ViaBackwards/latestrelease'
|
||||
).text.strip()
|
||||
return RedirectResponse(
|
||||
f'https://hangar.papermc.io/api/v1/projects/ViaVersion/ViaBackwards/versions/{latest_release}/Velocity/download'
|
||||
)
|
||||
|
||||
@api.get('/luckperms/{server_type}')
|
||||
async def luckperms_velocity(server_type):
|
||||
|
||||
luckperms_metadata = requests.get('https://metadata.luckperms.net/data/all').json()
|
||||
|
||||
return RedirectResponse(
|
||||
luckperms_metadata['downloads'][server_type]
|
||||
)
|
||||
|
||||
|
||||
@api.get('/tribufu-velocityrcon')
|
||||
async def tribufu_velocityrcon():
|
||||
|
||||
velocityrcon_metadata = requests.get('https://mvn.tribufu.com/releases/com/tribufu/Tribufu-VelocityRcon/maven-metadata.xml').text
|
||||
|
||||
root = ET.fromstring(velocityrcon_metadata)
|
||||
version = root.find('.//versioning/latest').text
|
||||
|
||||
return RedirectResponse(
|
||||
f'https://mvn.tribufu.com/releases/com/tribufu/Tribufu-VelocityRcon/{version}/Tribufu-VelocityRcon-{version}.jar'
|
||||
)
|
||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
requests
|
||||
fastapi[standard]
|
||||
Loading…
x
Reference in New Issue
Block a user