Skip to content

Commit 49cf438

Browse files
456devzlataovceLulu13022002
authored
feat: Vanilla data files + some formatting changes (#570)
* vanilla data files + some formatting changes * Apply review suggestions Co-authored-by: zlataovce <[email protected]> * punctuation * Update src/config/paper/banned-ips-single.yml Co-authored-by: Lulu13022002 <[email protected]> * Update src/content/docs/paper/admin/reference/configuration/vanilla-data-files.mdx Co-authored-by: Lulu13022002 <[email protected]> * feat: modify ConfigNode for JSON schemas --------- Co-authored-by: zlataovce <[email protected]> Co-authored-by: Lulu13022002 <[email protected]>
1 parent 39390e3 commit 49cf438

File tree

14 files changed

+256
-41
lines changed

14 files changed

+256
-41
lines changed

astro.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export default defineConfig({
8686
"paper/reference/spigot-configuration",
8787
"paper/reference/bukkit-commands-configuration",
8888
"paper/reference/server-properties",
89+
"paper/reference/vanilla-data-files",
8990
],
9091
},
9192
"paper/reference/paper-plugins",

src/components/ConfigNode.astro

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,29 @@
22
import { render } from "../utils/markdown";
33
import type { Data } from "../utils/config";
44
5+
type Language = "yaml" | "json" | "properties";
6+
57
interface Props {
68
data: Data;
7-
separator?: string;
9+
lang?: Language; // defaults to "yaml"
810
11+
child?: boolean;
912
path?: string[];
1013
}
1114
12-
let { data, separator, path } = Astro.props;
15+
let { data, lang, child, path } = Astro.props;
1316
path = path ?? [];
1417
15-
const root = path.length === 0;
18+
const json = lang === "json";
19+
const separator = lang === "properties" ? "=" : ": ";
1620
1721
interface Default {
1822
value: string;
1923
inline: boolean;
2024
}
2125
const formatDefault = (value?: string): Default => {
2226
if (!value) value = "";
23-
if (value.length > 2 && value.match(/^\[.+]$/)) {
27+
if (!json && value.length > 2 && value.match(/^\[.+]$/)) {
2428
return {
2529
value: value
2630
.substring(1, value.length - 1)
@@ -35,40 +39,45 @@ const formatDefault = (value?: string): Default => {
3539
};
3640
---
3741

38-
<div class:list={["not-content", "node", root && "node-root"]}>
42+
<div class:list={["not-content", "node", json && "node-json", child || "node-root"]}>
43+
{json && <p class="muted">{"{"}</p>}
3944
{
40-
Object.entries(data).map(([key, value]) => {
41-
const displayKey = key.replace(/_+$/, ""); // remove trailing underscores, used for duplicating keys
45+
Object.entries(data).map(([key, rawValue], i, entries) => {
46+
let displayKey = key.replace(/_+$/, ""); // remove trailing underscores, used for duplicating keys
47+
if (json) displayKey = `"${displayKey}"`;
48+
4249
const childPath = [...path, key.replace(/-/g, "_")];
50+
const hasComma = json && i !== (entries.length - 1);
4351

44-
const def = formatDefault(value.default);
52+
const { value, inline } = formatDefault(rawValue.default);
4553
return (
4654
<div>
47-
{"message" in value ? (
55+
{"message" in rawValue ? (
4856
<div
49-
class="block message"
50-
style={value.color ? `border-color: ${value.color}` : undefined}
51-
set:html={render(value.message)}
57+
class:list={["block", "message", rawValue.inline && "message-inline"]}
58+
style={rawValue.color ? `border-color: ${rawValue.color}` : undefined}
59+
set:html={render(rawValue.message)}
5260
/>
53-
) : "description" in value ? (
61+
) : "description" in rawValue ? (
5462
<details id={childPath.join("_")}>
5563
<summary class="line notranslate" translate="no">
56-
<span class="key">{displayKey}{separator ?? ": "}</span>{
57-
def.inline
58-
? (<span class="value">{def.value}</span><a class="link" href={`#${childPath.join("_")}`}>#</a>)
59-
: (<a class="link" href={`#${childPath.join("_")}`}>#</a><p class="value">{def.value}</p>)
64+
<span class="key">{displayKey}{separator}</span>{
65+
inline
66+
? (<span class="value">{value}</span><>{hasComma && <span class="muted">,</span>}</><a class="link" href={`#${childPath.join("_")}`}>#</a>)
67+
: (<a class="link" href={`#${childPath.join("_")}`}>#</a><p class="value">{value}</p><>{hasComma && <span class="muted">,</span>}</>)
6068
}
6169
</summary>
62-
<div class="block" set:html={render(value.description)} />
70+
<div class="block" set:html={render(rawValue.description)} />
6371
</details>
6472
) : (
65-
<span class="key notranslate" translate="no">{displayKey}:</span>
66-
<Astro.self data={value} path={childPath} {separator} />
73+
<span class="key notranslate" translate="no">{displayKey}{separator}</span>
74+
<Astro.self child data={rawValue} path={childPath} {lang} />
6775
)}
6876
</div>
6977
);
7078
})
7179
}
80+
{json && <p class="muted">{"}"}</p>}
7281
</div>
7382

7483
<style>
@@ -78,6 +87,14 @@ const formatDefault = (value?: string): Default => {
7887
font-family: var(--__sl-font-mono);
7988
}
8089

90+
.node-json {
91+
padding-left: 0;
92+
}
93+
94+
.node-json > div {
95+
padding-left: 1.25rem;
96+
}
97+
8198
.node-root {
8299
padding: 1rem;
83100
background-color: var(--sl-color-gray-6);
@@ -90,14 +107,13 @@ const formatDefault = (value?: string): Default => {
90107
}
91108

92109
.key {
93-
white-space: pre;
110+
white-space: pre-wrap;
94111
color: var(--sl-color-text-accent);
95112
}
96113

97114
.value {
98115
white-space: pre-wrap;
99116
color: var(--sl-color-text);
100-
padding-right: 0.5rem;
101117
}
102118

103119
.block {
@@ -109,14 +125,28 @@ const formatDefault = (value?: string): Default => {
109125
color: var(--sl-color-white);
110126
background-color: var(--sl-color-gray-5);
111127
border-left: 5px solid var(--sl-color-bg-accent);
128+
white-space: pre-wrap;
112129
}
113130

114131
.message {
115132
margin-left: 0;
116133
}
117134

135+
.message-inline {
136+
margin: 0;
137+
padding: 0;
138+
color: var(--sl-color-gray-3);
139+
background-color: unset;
140+
border-left: none;
141+
}
142+
143+
.muted {
144+
color: var(--sl-color-gray-3);
145+
}
146+
118147
.link {
119148
opacity: 0;
149+
padding-left: 0.5rem;
120150
transition: opacity 0.2s ease;
121151
}
122152

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
header:
2+
message: This is a single entry in the root array found in banned-ips.json.
3+
ip:
4+
description: |
5+
The IP address representing the banned user.
6+
7+
For IPv4 the expected format is "x.x.x.x",
8+
9+
For IPv6 the expected format follows [RFC5952 Section 4](https://datatracker.ietf.org/doc/html/rfc5952#section-4),
10+
11+
For anything else, "\<unknown>" may be present (but its use is discouraged).
12+
default: "an IPv4 or IPv6 address"
13+
created:
14+
description: |
15+
A timestamp of when the user was banned.
16+
The expected format is "yyyy-MM-dd HH:mm:ss Z".
17+
default: the ban creation time
18+
source:
19+
description: A string representing the source of the ban.
20+
default: '"(Unknown)"'
21+
expires:
22+
description: |
23+
A timestamp of when the ban expires, or "forever" if it does not expire.
24+
25+
The expected format is "yyyy-MM-dd HH:mm:ss Z".
26+
default: '"forever"'
27+
reason:
28+
description: The reason for the ban.
29+
default: '"Banned by an operator."'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
header:
2+
message: This is a single entry in the root array found in banned-players.json.
3+
uuid:
4+
description: The UUID representing the banned user.
5+
default: the UUID of the banned user
6+
name:
7+
description: The name of the banned user.
8+
default: the name of the banned user
9+
created:
10+
description: |
11+
A timestamp of when the user was banned.
12+
The expected format is "yyyy-MM-dd HH:mm:ss Z".
13+
default: the ban creation time
14+
source:
15+
description: A string representing the source of the ban.
16+
default: '"(Unknown)"'
17+
expires:
18+
description: |
19+
A timestamp of when the ban expires, or "forever" if it does not expire.
20+
21+
The expected format is "yyyy-MM-dd HH:mm:ss Z".
22+
default: '"forever"'
23+
reason:
24+
description: The reason for the ban.
25+
default: '"Banned by an operator."'

src/config/paper/eula.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
header:
2+
message: |
3+
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).
4+
#\<date\>
5+
inline: true
6+
eula:
7+
default: "false"
8+
description: >-
9+
Whether to accept the Minecraft EULA.
10+
This must be set to "true" to run the server.

src/config/paper/ops-single.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
header:
2+
message: This is a single entry in the root array found in ops.json.
3+
uuid:
4+
description: The UUID representing the operator.
5+
default: the UUID of the operator
6+
name:
7+
description: The name of the operator.
8+
default: the name of the operator
9+
level:
10+
description: |
11+
The level of the operator permissions.
12+
13+
The expected format is an integer between 0 and 4.
14+
default: "0"
15+
16+
bypassesPlayerLimit:
17+
description: Whether this operator bypasses the player limit.
18+
default: "false"

src/config/paper/paper-global.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ unsupported-settings:
461461
inline-docs-warning:
462462
color: red
463463
message: >-
464-
**Unsupported settings**<br />
464+
**Unsupported settings**
465+
465466
The following settings are provided by Paper but are not officially
466467
supported. Use them at your own risk and they may be removed at any time.
467468
allow-headless-pistons:

src/config/paper/paper-world-defaults.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,8 @@ unsupported-settings:
10421042
inline-docs-warning:
10431043
color: red
10441044
message: >-
1045-
**Unsupported settings**<br />
1045+
**Unsupported settings**
1046+
10461047
The following settings are provided by Paper but are not officially
10471048
supported. Use them at your own risk and they may be removed at any time.
10481049
disable-world-ticking-when-empty:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
header:
2+
message: This is a single entry in the root array found in whitelist.json.
3+
uuid:
4+
description: The UUID of the player on the whitelist.
5+
default: the UUID of the player on the whitelist
6+
name:
7+
description: The name of the player on the whitelist.
8+
default: the name of the player on the whitelist

src/content/docs/paper/admin/how-to/vanilla.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Unfortunately, it currently is not possible to get a 100% Vanilla experience in
3232

3333
:::
3434
## server.properties
35-
<ConfigNode data={filterVanilla(parse(ServerPropertiesYML))} separator="=" />
35+
<ConfigNode data={filterVanilla(parse(ServerPropertiesYML))} lang="properties" />
3636

3737
## paper-world-defaults.yml
3838
<ConfigNode data={filterVanilla(parse(PaperWorldDefaultsYML))} />

0 commit comments

Comments
 (0)