Skip to content

Commit c4ec549

Browse files
committed
fix: oversights, re-add vanilla guide
1 parent b2865a5 commit c4ec549

4 files changed

Lines changed: 65 additions & 17 deletions

File tree

src/components/ConfigNode.astro

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
---
22
import { render } from "../utils/markdown";
3-
4-
interface LeafData {
5-
description: string;
6-
default?: string;
7-
}
8-
9-
interface MessageData {
10-
message: string;
11-
color?: string;
12-
}
13-
14-
type Data = { [key: string]: Data } | LeafData | MessageData;
3+
import type { Data } from "../utils/config";
154
165
interface Props {
176
data: Data;
@@ -49,7 +38,7 @@ const formatDefault = (value?: string): Default => {
4938
<div class:list={["not-content", "node", root && "node-root"]}>
5039
{
5140
Object.entries(data).map(([key, value]) => {
52-
const displayKey = key.replace(/^_+/, ""); // remove leading underscores, used for duplicating keys
41+
const displayKey = key.replace(/_+$/, ""); // remove trailing underscores, used for duplicating keys
5342
const childPath = [...path, key.replace(/-/g, "_")];
5443

5544
const def = formatDefault(value.default);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,12 @@ tick-rates:
10391039
Sets the sensor tick rate of an entity. -1 uses Vanilla. See timings
10401040
for the names. Might change between updates!
10411041
unsupported-settings:
1042+
inline-docs-warning:
1043+
color: red
1044+
message: >-
1045+
**Unsupported settings**<br />
1046+
The following settings are provided by Paper but are not officially
1047+
supported. Use them at your own risk and they may be removed at any time.
10421048
disable-world-ticking-when-empty:
10431049
vanilla: "true"
10441050
default: "false"

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ description: This page lists all changes that result in a different experience t
44
slug: paper/vanilla
55
---
66

7+
import ConfigNode from "/src/components/ConfigNode.astro";
8+
import { filterVanilla } from "/src/utils/config";
9+
import { parse } from "yaml";
10+
11+
import ServerPropertiesYML from "/src/config/paper/server-properties.yml?raw";
12+
import PaperWorldDefaultsYML from "/src/config/paper/paper-world-defaults.yml?raw";
13+
import PaperGlobalYML from "/src/config/paper/paper-global.yml?raw";
14+
import SpigotYML from "/src/config/paper/spigot.yml?raw";
15+
716
Due to the way the Bukkit API is implemented in Paper, the gameplay experience between Vanilla and Paper can have inconsistencies.
817
This can be furthered by efforts to fix bugs present in Vanilla Minecraft.
918
Whilst many people may not notice the inconsistencies, there are situations where they become problematic.
@@ -23,16 +32,16 @@ Unfortunately, it currently is not possible to get a 100% Vanilla experience in
2332

2433
:::
2534
## server.properties
26-
{/* <ConfigDocBlock data={ServerProperties} showVanillaValues={true}/> */}
35+
<ConfigNode data={filterVanilla(parse(ServerPropertiesYML))} separator="=" />
2736

2837
## paper-world-defaults.yml
29-
{/* <ConfigDocBlock data={VanillaWorldDefaults} showVanillaValues={true}/> */}
38+
<ConfigNode data={filterVanilla(parse(PaperWorldDefaultsYML))} />
3039

3140
## paper-global.yml
32-
{/* <ConfigDocBlock data={VanillaGlobalDefaults} showVanillaValues={true}/> */}
41+
<ConfigNode data={filterVanilla(parse(PaperGlobalYML))} />
3342

3443
## spigot.yml
35-
{/* <ConfigDocBlock data={SpigotChanges} showVanillaValues={true}/> */}
44+
<ConfigNode data={filterVanilla(parse(SpigotYML))} />
3645

3746
## Further considerations
3847

src/utils/config.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
export interface LeafData {
2+
description: string;
3+
default?: string;
4+
}
5+
6+
export interface MessageData {
7+
message: string;
8+
color?: string;
9+
}
10+
11+
export type Data = { [key: string]: Data } | LeafData | MessageData;
12+
13+
interface VanillaLeafData extends LeafData {
14+
vanilla?: string;
15+
}
16+
17+
type VanillaData = { [key: string]: Data } | VanillaLeafData | MessageData;
18+
19+
// replaces "default" values with "vanilla" values, removes them if no "vanilla" value is defined
20+
export const filterVanilla = (input: VanillaData): Data | null => {
21+
if ("message" in input) {
22+
return input; // MessageData
23+
}
24+
25+
if ("description" in input) {
26+
const leaf = input as LeafData;
27+
if ("vanilla" in leaf) {
28+
leaf.default = (leaf as VanillaLeafData).vanilla!;
29+
return leaf;
30+
}
31+
32+
return null; // remove key
33+
}
34+
35+
const result: { [key: string]: Data } = {};
36+
for (const key in input) {
37+
const converted = filterVanilla(input[key]);
38+
if (converted !== null) {
39+
result[key] = converted;
40+
}
41+
}
42+
43+
return Object.keys(result).length > 0 ? result : null;
44+
};

0 commit comments

Comments
 (0)