summaryrefslogtreecommitdiff
path: root/x
diff options
context:
space:
mode:
Diffstat (limited to 'x')
-rwxr-xr-xx234
1 files changed, 133 insertions, 101 deletions
diff --git a/x b/x
index a52964c..aa9a210 100755
--- a/x
+++ b/x
@@ -2,70 +2,107 @@
set -e
+DC_PAPER="docker compose -f docker/paper/compose.yaml"
DC_VELOCITY="docker compose -f docker/velocity/compose.yaml"
DC_FOLIA="docker compose -f docker/folia/compose.yaml"
+GRADLE_EXTRA_ARGS=""
+
help() {
cat <<EOF
-Usage: ./x <command> [options]
-
-Velocity environment (Paper s1 + s2 + Velocity proxy):
- start Build Paper+Velocity and start all containers
- start-s1 Build Paper and start only s1 container
- restart Restart s1, s2 and velocity containers
- stop Stop velocity environment
- clean Stop velocity environment and remove volumes
- rcon [server] Open rcon-cli for server container (default: s1)
- Available servers: s1, s2
- logs [server] Show server container logs (default: s1)
- Available servers: s1, s2
- vlogs Show velocity proxy container logs
-
-Folia environment (single Folia server):
- folia start Build Paper and start Folia server
- folia restart Restart Folia server
- folia stop Stop Folia server
- folia clean Stop Folia server and remove volumes
- folia rcon Open rcon-cli for Folia server
- folia logs Show Folia server logs
-
-General:
- help Show this help message
+Usage: ./x <action> <platform> [--stable]
+
+Actions:
+ start Build and start containers
+ stop Stop containers
+ log Show container logs
+ clean Stop containers and remove volumes
+ rcon Open rcon-cli console (velocity: ./x rcon velocity [s1|s2])
+ help Show this help message
+
+Platforms:
+ paper Single Paper server (localhost:25565)
+ velocity Velocity proxy + Paper s1 & s2 (localhost:25577)
+ folia Single Folia server (localhost:25565)
+
+Options:
+ --stable Build as stable release (default: nightly)
+
+Examples:
+ ./x start paper Build nightly and start Paper server
+ ./x start velocity Build nightly and start Velocity environment
+ ./x start folia Build nightly and start Folia server
+ ./x start paper --stable Build stable and start Paper server
+ ./x log velocity Show Velocity environment logs
+ ./x rcon paper Open rcon-cli for Paper server
+ ./x stop velocity Stop Velocity environment
+ ./x clean folia Stop Folia and remove volumes
EOF
}
+setup_nightly() {
+ SHORT_HASH=$(git rev-parse --short HEAD)
+ GRADLE_EXTRA_ARGS="-Pversion=1.0.0-nightly.${SHORT_HASH} -PisNightly=true"
+ echo "==> Nightly build: 1.0.0-nightly.${SHORT_HASH}"
+}
+
ensure_plugin_dir() {
mkdir -p "$1"
}
-# --- Folia commands ---
-folia_cmd() {
- case "${1:-}" in
- start)
- ./gradlew :platform-paper:clean :platform-paper:shadowJar
+# Parse --stable flag (only setup build for actions that need it)
+ACTION="${1:-}"
+PLATFORM="${2:-}"
+
+if [[ "$ACTION" == "start" ]]; then
+ STABLE=false
+ for arg in "$@"; do
+ if [[ "$arg" == "--stable" ]]; then
+ STABLE=true
+ fi
+ done
+
+ if [[ "$STABLE" == "false" ]]; then
+ setup_nightly
+ else
+ echo "==> Stable build"
+ fi
+fi
+
+# --- Actions per platform ---
+
+do_start() {
+ case "$1" in
+ paper)
+ ./gradlew :platform-paper:clean :platform-paper:shadowJar $GRADLE_EXTRA_ARGS
+ ensure_plugin_dir docker/paper/plugins
+ rm -f docker/paper/plugins/*.jar
+ cp platform-paper/build/libs/*.jar docker/paper/plugins/
+ $DC_PAPER up
+ ;;
+ velocity)
+ ./gradlew :platform-paper:clean :platform-paper:shadowJar :platform-velocity:clean :platform-velocity:shadowJar $GRADLE_EXTRA_ARGS
+ ensure_plugin_dir docker/velocity/plugins-paper-s1
+ ensure_plugin_dir docker/velocity/plugins-paper-s2
+ ensure_plugin_dir docker/velocity/plugins-velocity
+ rm -f docker/velocity/plugins-paper-s1/*.jar
+ rm -f docker/velocity/plugins-paper-s2/*.jar
+ rm -f docker/velocity/plugins-velocity/*.jar
+ cp platform-paper/build/libs/*.jar docker/velocity/plugins-paper-s1/
+ cp platform-paper/build/libs/*.jar docker/velocity/plugins-paper-s2/
+ cp platform-velocity/build/libs/*.jar docker/velocity/plugins-velocity/
+ $DC_VELOCITY up
+ ;;
+ folia)
+ ./gradlew :platform-paper:clean :platform-paper:shadowJar $GRADLE_EXTRA_ARGS
ensure_plugin_dir docker/folia/plugins
rm -f docker/folia/plugins/*.jar
cp platform-paper/build/libs/*.jar docker/folia/plugins/
$DC_FOLIA up
;;
- restart)
- $DC_FOLIA restart folia
- ;;
- stop)
- $DC_FOLIA down
- ;;
- clean)
- $DC_FOLIA down -v
- ;;
- rcon)
- $DC_FOLIA exec folia rcon-cli
- ;;
- logs)
- $DC_FOLIA logs -f folia
- ;;
*)
- echo "Unknown folia command: ${1:-}"
+ echo "Unknown platform: ${1:-}"
echo ""
help
exit 1
@@ -73,64 +110,59 @@ folia_cmd() {
esac
}
+do_stop() {
+ case "$1" in
+ paper) $DC_PAPER down ;;
+ velocity) $DC_VELOCITY down ;;
+ folia) $DC_FOLIA down ;;
+ *) echo "Unknown platform: ${1:-}"; exit 1 ;;
+ esac
+}
+
+do_log() {
+ case "$1" in
+ paper) $DC_PAPER logs -f paper ;;
+ velocity) $DC_VELOCITY logs -f ;;
+ folia) $DC_FOLIA logs -f folia ;;
+ *) echo "Unknown platform: ${1:-}"; exit 1 ;;
+ esac
+}
+
+do_clean() {
+ case "$1" in
+ paper) $DC_PAPER down -v ;;
+ velocity) $DC_VELOCITY down -v ;;
+ folia) $DC_FOLIA down -v ;;
+ *) echo "Unknown platform: ${1:-}"; exit 1 ;;
+ esac
+}
+
+do_rcon() {
+ case "$1" in
+ paper) $DC_PAPER exec paper rcon-cli ;;
+ velocity)
+ local server="${2:-s1}"
+ if [[ "$server" != "s1" && "$server" != "s2" ]]; then
+ echo "Error: Invalid server '$server'. Available: s1, s2"
+ exit 1
+ fi
+ $DC_VELOCITY exec "$server" rcon-cli
+ ;;
+ folia) $DC_FOLIA exec folia rcon-cli ;;
+ *) echo "Unknown platform: ${1:-}"; exit 1 ;;
+ esac
+}
+
# --- Main ---
-case "${1:-}" in
- folia)
- folia_cmd "${2:-}"
- ;;
- start)
- ./gradlew :platform-paper:clean :platform-paper:shadowJar :platform-velocity:clean :platform-velocity:shadowJar
- ensure_plugin_dir docker/velocity/plugins-paper-s1
- ensure_plugin_dir docker/velocity/plugins-paper-s2
- ensure_plugin_dir docker/velocity/plugins-velocity
- rm -f docker/velocity/plugins-paper-s1/*.jar
- rm -f docker/velocity/plugins-paper-s2/*.jar
- rm -f docker/velocity/plugins-velocity/*.jar
- cp platform-paper/build/libs/*.jar docker/velocity/plugins-paper-s1/
- cp platform-paper/build/libs/*.jar docker/velocity/plugins-paper-s2/
- cp platform-velocity/build/libs/*.jar docker/velocity/plugins-velocity/
- $DC_VELOCITY up
- ;;
- start-s1)
- ./gradlew :platform-paper:clean :platform-paper:shadowJar
- ensure_plugin_dir docker/velocity/plugins-paper-s1
- rm -f docker/velocity/plugins-paper-s1/*.jar
- cp platform-paper/build/libs/*.jar docker/velocity/plugins-paper-s1/
- $DC_VELOCITY up s1
- ;;
- restart)
- $DC_VELOCITY restart s1 s2 velocity
- ;;
- stop)
- $DC_VELOCITY down
- ;;
- clean)
- $DC_VELOCITY down -v
- ;;
- rcon)
- SERVER="${2:-s1}"
- if [[ "$SERVER" != "s1" && "$SERVER" != "s2" ]]; then
- echo "Error: Invalid server '$SERVER'. Available servers: s1, s2"
- exit 1
- fi
- $DC_VELOCITY exec "$SERVER" rcon-cli
- ;;
- logs)
- SERVER="${2:-s1}"
- if [[ "$SERVER" != "s1" && "$SERVER" != "s2" ]]; then
- echo "Error: Invalid server '$SERVER'. Available servers: s1, s2"
- exit 1
- fi
- $DC_VELOCITY logs -f "$SERVER"
- ;;
- vlogs)
- $DC_VELOCITY logs -f velocity
- ;;
- help|"")
- help
- ;;
+case "$ACTION" in
+ start) do_start "$PLATFORM" ;;
+ stop) do_stop "$PLATFORM" ;;
+ log) do_log "$PLATFORM" ;;
+ clean) do_clean "$PLATFORM" ;;
+ rcon) do_rcon "$PLATFORM" "${3:-}" ;;
+ help|"") help ;;
*)
- echo "Unknown command: $1"
+ echo "Unknown action: $ACTION"
echo ""
help
exit 1