From 3bcadfac09dfd19c63c52f2ebaf0c52963f3e8b5 Mon Sep 17 00:00:00 2001 From: TheAlan404 Date: Sat, 18 Nov 2023 23:21:51 +0300 Subject: [PATCH] rustup update, schemas --- hotreload.schema.json | 31 ++++ network.schema.json | 38 +++++ servertoml.schema.json | 304 +++++++++++++++++++++++----------- src/core/worlds.rs | 4 +- src/model/downloadable/mod.rs | 1 - src/model/servertype/mod.rs | 1 - 6 files changed, 281 insertions(+), 98 deletions(-) create mode 100644 hotreload.schema.json create mode 100644 network.schema.json diff --git a/hotreload.schema.json b/hotreload.schema.json new file mode 100644 index 0000000..d77468c --- /dev/null +++ b/hotreload.schema.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "hotreload.toml", + "description": "mcman hotreload.toml schema", + "type": "object", + "properties": { + "files": { + "type": "array", + "items": { + "type": "object", + "properties": { + "path": { "type": "string" }, + "action": { + "oneOf": [ + { + "const": "reload" + }, + { + "const": "restart" + }, + { + "type": "string", + "pattern": "/.*" + } + ] + } + } + } + } + } +} diff --git a/network.schema.json b/network.schema.json new file mode 100644 index 0000000..a5a3b50 --- /dev/null +++ b/network.schema.json @@ -0,0 +1,38 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "network.toml schema", + "description": "Schema for mcman's network.toml file", + "type": "object", + "properties": { + "name": { + "description": "Name of the network", + "type": "string" + }, + "proxy": { + "description": "The proxy server's name", + "type": "string" + }, + "port": { + "type": "integer", + "default": 25565 + }, + "servers": { + "description": "Table of servers", + "type": "object", + "additionalProperties": { + "port": { + "type": "integer", + "default": 25565 + }, + "ip_address": { + "description": "Optional server ip address", + "type": "string" + } + } + }, + "variables": { + "description": "Variables shared between all servers", + "type": "object" + } + } +} diff --git a/servertoml.schema.json b/servertoml.schema.json index fa56a9c..f6e4ba6 100644 --- a/servertoml.schema.json +++ b/servertoml.schema.json @@ -1,7 +1,138 @@ { - "$schema": "http://json-schema.org/schema", + "$schema": "http://json-schema.org/draft-07/schema", "$id": "https://raw.githubusercontent.com/ParadigmMC/mcman/main/servertoml.schema.json", "definitions": { + "ServerType": { + "anyOf": [ + { + "type": "object", + "anyOf": [ + { + "properties": { + "type": { + "const": "papermc" + }, + "project": { + "type": "string", + "enum": [ + "paper", + "velocity", + "waterfall" + ] + }, + "build": { + "type": "string", + "default": "latest" + } + } + }, + { + "properties": { + "type": { + "const": "purpur" + }, + "build": { + "type": "string", + "default": "latest" + } + } + }, + { + "properties": { + "type": { + "anyOf": [ + { + "const": "quilt" + }, + { + "const": "fabric" + } + ] + }, + "loader": { + "description": "The loader version", + "type": "string", + "default": "latest" + }, + "installer": { + "description": "The installer version", + "type": "string", + "default": "latest" + } + }, + "required": ["loader"] + }, + { + "properties": { + "type": { + "anyOf": [ + { + "const": "neoforge" + }, + { + "const": "forge" + } + ] + }, + "loader": { + "description": "The loader version", + "type": "string", + "default": "latest" + } + }, + "required": ["loader"] + }, + { + "properties": { + "type": { + "const": "buildtools" + }, + "software": { + "enum": [ + "spigot", + "craftbukkit", + "none" + ], + "default": "spigot" + }, + "args": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + { + "properties": { + "type": { + "anyOf": [ + { + "const": "paper" + }, + { + "const": "velocity" + }, + { + "const": "waterfall" + }, + { + "const": "bungeecord" + }, + { + "const": "vanilla" + } + ] + } + } + } + ] + }, + { + "$ref": "#/definitions/Downloadable" + } + ] + }, "Downloadable": { "type": "object", "anyOf": [ @@ -41,9 +172,11 @@ "type": "string" }, "version": { - "type": "string" + "type": "string", + "default": "latest" } - } + }, + "required": ["id"] }, { "properties": { @@ -63,26 +196,8 @@ "version": { "type": "string" } - } - }, - { - "properties": { - "type": { - "const": "papermc" - }, - "project": { - "type": "string", - "enum": [ - "paper", - "velocity", - "waterfall" - ] - }, - "build": { - "type": "string", - "default": "latest" - } - } + }, + "required": ["id"] }, { "description": "Download from Spigot Resources", @@ -92,8 +207,10 @@ }, "id": { "type": "string" - } - } + }, + "version": { "type": "string", "default": "latest" } + }, + "required": ["id"] }, { "description": "Download from Github Releases", @@ -112,7 +229,8 @@ "type": "string", "default": "first" } - } + }, + "required": ["repo"] }, { "description": "Download from jenkins", @@ -137,71 +255,30 @@ } }, { + "description": "Download from a Maven repository", "properties": { "type": { - "const": "purpur" + "const": "maven" }, - "build": { - "type": "string", - "default": "latest" - } - } - }, - { - "properties": { - "type": { - "anyOf": [ - { "const": "quilt" }, - { "const": "fabric" } - ] + "url": { + "type": "string" }, - "loader": { - "description": "The loader version", - "type": "string", - "default": "latest" + "group": { + "type": "string" }, - "installer": { - "description": "The installer version", + "artifact": { + "type": "string" + }, + "version": { "type": "string", "default": "latest" - } - } - }, - { - "properties": { - "type": { - "const": "buildtools" }, - "args": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - { - "properties": { - "type": { - "anyOf": [ - { - "const": "paper" - }, - { - "const": "velocity" - }, - { - "const": "waterfall" - }, - { - "const": "bungeecord" - }, - { - "const": "vanilla" - } - ] + "filename": { + "type": "string", + "default": "artifact" } - } + }, + "required": ["url", "group", "artifact"] } ] } @@ -220,19 +297,20 @@ }, "jar": { "description": "The server jar to use", - "$ref": "#/definitions/Downloadable" + "$ref": "#/definitions/ServerType" }, "launcher": { "type": "object", "description": "Config properties for generating launch scripts", "properties": { - "aikars_flags": { - "type": "boolean", - "description": "Uses aikar's flags on the launch scripts" - }, - "proxy_flags": { - "type": "boolean", - "description": "Uses proxy-optimized flags on the launch scripts" + "preset_flags": { + "description": "Preset flags for launch scripts", + "enum": [ + "aikars", + "proxy", + "none" + ], + "default": "none" }, "nogui": { "type": "boolean", @@ -261,6 +339,11 @@ "properties": { "type": "object", "description": "The -Dsomething=something properties to add to the launcher scripts" + }, + "java_version": { + "type": "string", + "description": "Java version hint", + "examples": ["17", "16", "8"] } } }, @@ -284,7 +367,11 @@ "items": { "type": "array", "items": { - "allOf": [{ "$ref": "#/definitions/Downloadable" }], + "allOf": [ + { + "$ref": "#/definitions/Downloadable" + } + ], "properties": { "optional": { "type": "boolean", @@ -305,6 +392,10 @@ "type": "object", "description": "A world", "properties": { + "download": { + "description": "Where to download the world, if missing", + "$ref": "#/definitions/Downloadable" + }, "datapacks": { "type": "array", "items": { @@ -317,7 +408,15 @@ }, "variables": { "type": "object", - "description": "Variables to use in bootstrapping" + "description": "Variables to use in bootstrapping", + "properties": { + "MODPACK_NAME": { "type": "string" }, + "MODPACK_DESCRIPTION": { "type": "string" }, + "MODPACK_VERSION": { "type": "string" }, + "MODPACK_SUMMARY": { "type": "string" }, + "MODPACK_AUTHOR": { "type": "string" }, + "MOTD": { "type": "string" } + } }, "markdown": { "type": "object", @@ -330,7 +429,9 @@ "type": "string", "description": "Path to a markdown file" }, - "default": ["README.md"] + "default": [ + "README.md" + ] }, "auto_update": { "type": "boolean", @@ -338,6 +439,21 @@ "default": false } } + }, + "options": { + "description": "Extra optional options", + "type": "object", + "properties": { + "upload_to_mclogs": { + "description": "If enabled, uploads logs to https://mclo.gs if server stops/crashes when using `run`/`dev` commands", + "type": "boolean" + }, + "bootstrap_exts": { + "description": "Extra file extensions to boostrap", + "type": "array", + "items": { "type": "string" } + } + } } } -} \ No newline at end of file +} diff --git a/src/core/worlds.rs b/src/core/worlds.rs index 58867fb..258b8ed 100644 --- a/src/core/worlds.rs +++ b/src/core/worlds.rs @@ -78,7 +78,7 @@ impl<'a> BuildContext<'a> { unzip(&path, &self.output_dir.join(name))?; - spinner.finish_with_message(format!("Unzipped world successfully")); + spinner.finish_with_message("Unzipped world successfully".to_string()); } } @@ -88,7 +88,7 @@ impl<'a> BuildContext<'a> { self.process_datapacks(progress_bar, name, world) .await - .context(format!("Processing datapacks"))?; + .context("Processing datapacks")?; } Ok(()) diff --git a/src/model/downloadable/mod.rs b/src/model/downloadable/mod.rs index be4aadb..1c2260e 100644 --- a/src/model/downloadable/mod.rs +++ b/src/model/downloadable/mod.rs @@ -69,7 +69,6 @@ pub enum Downloadable { Maven { url: String, group: String, - #[serde(default = "first")] artifact: String, #[serde(default = "latest")] version: String, diff --git a/src/model/servertype/mod.rs b/src/model/servertype/mod.rs index f6488ab..d54baf4 100644 --- a/src/model/servertype/mod.rs +++ b/src/model/servertype/mod.rs @@ -52,7 +52,6 @@ pub enum ServerType { installer: String, }, - #[serde(alias = "neoforged")] NeoForge { #[serde(default = "latest")] loader: String,