Skip to content

Commit f1430e8

Browse files
committed
Add Adventure docs
1 parent 6f952d7 commit f1430e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3588
-16
lines changed

.typos.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[files]
22
extend-exclude = [
3-
"public/d2" # D2 output shouldn't be checked
3+
"public/d2", # D2 output shouldn't be checked
4+
"src/content/docs/adventure/minimessage/format.mdx", # This file contains british spelling because of tag aliases
5+
"src/content/docs/adventure/community-libraries.mdx" # This file contains project names which might get flagged by typos
46
]
57

68
[default]

astro.config.ts

Lines changed: 93 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ import d2 from "astro-d2";
44
import { defineConfig } from "astro/config";
55
import starlightLinksValidator from "starlight-links-validator";
66
import starlightSidebarTopics from "starlight-sidebar-topics";
7+
import miniMessageHighlight from "./src/assets/mm.tmLanguage.json";
78
import codeConstantsPlugin from "./src/utils/remark/code_const";
89
import javadocPlugin from "./src/utils/remark/javadoc";
910
import {
11+
LATEST_ADVENTURE_ANSI_RELEASE,
12+
LATEST_ADVENTURE_API_RELEASE,
13+
LATEST_ADVENTURE_PLATFORM_RELEASE,
1014
LATEST_MC_RELEASE,
1115
LATEST_PAPER_RELEASE,
1216
LATEST_USERDEV_RELEASE,
@@ -323,19 +327,88 @@ export default defineConfig({
323327
},
324328
],
325329
},
330+
331+
{
332+
id: "adventure",
333+
label: "Adventure",
334+
link: "/adventure/",
335+
icon: "adventure",
336+
items: [
337+
"adventure/getting-started",
338+
"adventure/community-libraries",
339+
"adventure/faq",
340+
"adventure/audiences",
341+
"adventure/text",
342+
{
343+
label: "Text Serializers",
344+
items: [
345+
"adventure/serializer/json",
346+
"adventure/serializer/gson",
347+
"adventure/serializer/legacy",
348+
"adventure/serializer/plain",
349+
{
350+
label: "MiniMessage",
351+
items: [
352+
"adventure/minimessage/format",
353+
"adventure/minimessage/api",
354+
"adventure/minimessage/dynamic-replacements",
355+
"adventure/minimessage/translator",
356+
],
357+
},
358+
"adventure/serializer/ansi",
359+
],
360+
},
361+
"adventure/bossbar",
362+
"adventure/sound",
363+
"adventure/titles",
364+
"adventure/book",
365+
"adventure/tablist",
366+
"adventure/resource-pack",
367+
{
368+
label: "MiniMessage",
369+
items: [
370+
"adventure/minimessage/format",
371+
"adventure/minimessage/api",
372+
"adventure/minimessage/dynamic-replacements",
373+
"adventure/minimessage/translator",
374+
],
375+
},
376+
"adventure/localization",
377+
{
378+
label: "Platforms",
379+
items: [
380+
"adventure/platform/native",
381+
"adventure/platform/bukkit",
382+
"adventure/platform/bungeecord",
383+
"adventure/platform/spongeapi",
384+
"adventure/platform/modded",
385+
"adventure/platform/fabric",
386+
"adventure/platform/neoforge",
387+
"adventure/platform/viaversion",
388+
"adventure/platform/implementing",
389+
],
390+
},
391+
{
392+
label: "Migrating to Adventure from other APIs",
393+
items: ["adventure/migration/bungeecord-chat-api", "adventure/migration/text-3.x"],
394+
},
395+
{
396+
label: "Version History",
397+
items: [
398+
"adventure/version-history/adventure",
399+
"adventure/version-history/adventure-platform",
400+
"adventure/version-history/adventure-platform-fabric",
401+
],
402+
},
403+
],
404+
},
326405
{
327406
id: "waterfall",
328407
label: "Waterfall",
329408
link: "/waterfall/",
330409
icon: "waterfall",
331410
items: ["waterfall/getting-started", "waterfall/configuration"],
332411
},
333-
{
334-
id: "adventure",
335-
label: "Adventure",
336-
link: "https://docs.advntr.dev/",
337-
icon: "adventure",
338-
},
339412
{
340413
id: "misc",
341414
label: "Miscellaneous",
@@ -392,6 +465,14 @@ export default defineConfig({
392465
"/velocity/dev/api",
393466
],
394467
folia: ["/folia/admin", "/folia/admin/reference"],
468+
adventure: [
469+
"/adventure/serializer",
470+
"/adventure/minimessage",
471+
"/adventure/platform",
472+
"/adventure/migration",
473+
"/adventure/contributing",
474+
"/adventure/version-history",
475+
],
395476
waterfall: ["/waterfall"],
396477
misc: ["/misc", "/misc/tools"],
397478
},
@@ -403,6 +484,9 @@ export default defineConfig({
403484
extractFileNameFromCode: false,
404485
},
405486
emitExternalStylesheet: false,
487+
shiki: {
488+
langs: [miniMessageHighlight],
489+
},
406490
},
407491
}),
408492
svelte(),
@@ -434,6 +518,9 @@ export default defineConfig({
434518
LATEST_PAPER_RELEASE,
435519
LATEST_VELOCITY_RELEASE,
436520
LATEST_USERDEV_RELEASE,
521+
LATEST_ADVENTURE_API_RELEASE,
522+
LATEST_ADVENTURE_PLATFORM_RELEASE,
523+
LATEST_ADVENTURE_ANSI_RELEASE,
437524
},
438525
},
439526
],

src/assets/mm.tmLanguage.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3+
"name": "mm",
4+
"patterns": [
5+
{
6+
"name": "meta.tag.mm",
7+
"begin": "(<)(/?|!?)([a-zA-Z0-9_#]+)",
8+
"beginCaptures": {
9+
"1": { "name": "constant.language.tag.mm" },
10+
"2": { "name": "constant.language.tag.mm" },
11+
"3": { "name": "constant.language.tag.mm" }
12+
},
13+
"end": "(>)",
14+
"endCaptures": {
15+
"1": { "name": "constant.language.tag.mm" }
16+
},
17+
"patterns": [
18+
{
19+
"name": "string.quoted.single.argument.mm",
20+
"match": "(:)'([^']*)'",
21+
"captures": {
22+
"1": { "name": "constant.language.tag.mm" },
23+
"2": { "name": "string.quoted.single.argument.mm" }
24+
}
25+
},
26+
{
27+
"name": "string.quoted.double.argument.mm",
28+
"match": "(:)\"([^\"]*)\"",
29+
"captures": {
30+
"1": { "name": "constant.language.tag.mm" },
31+
"2": { "name": "string.quoted.double.argument.mm" }
32+
}
33+
},
34+
{
35+
"name": "variable.language.argument.mm",
36+
"match": "(:)([^:\\s\"'>]+(?:\\[[^\\]]*\\])?)",
37+
"captures": {
38+
"1": { "name": "constant.language.tag.mm" },
39+
"2": { "name": "variable.language.argument.mm" }
40+
}
41+
}
42+
]
43+
}
44+
],
45+
"repository": {},
46+
"scopeName": "text.mm"
47+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
import { fetchRelease } from "../../utils/releases";
3+
import { render } from "../../utils/markdown";
4+
5+
interface Props {
6+
repo: string;
7+
}
8+
9+
const props: Props = Astro.props;
10+
const data = await fetchRelease(props.repo);
11+
---
12+
13+
{
14+
data.map(async (release) => (
15+
<div>
16+
<a class="title" href={`#release-${release.tag}`}>
17+
<h2 id={`release-${release.tag}`}>{release.name}</h2>
18+
</a>
19+
<p class="released">
20+
Released on{" "}
21+
<time datetime={release.published}>
22+
{new Date(release.published).toLocaleDateString("en", {
23+
dateStyle: "medium",
24+
timeZone: "UTC",
25+
})}
26+
</time>{" "}
27+
- <a href={release.url}>GitHub</a>
28+
</p>
29+
<p set:html={await render(release.body)} />
30+
<br />
31+
</div>
32+
))
33+
}
34+
35+
<style>
36+
.title {
37+
color: var(--sl-color-white);
38+
text-decoration: none;
39+
}
40+
41+
.released {
42+
font-style: italic;
43+
}
44+
</style>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
import { Tabs, TabItem, Code } from "@astrojs/starlight/components";
3+
import {
4+
LATEST_ADVENTURE_API_RELEASE,
5+
LATEST_ADVENTURE_PLATFORM_RELEASE,
6+
LATEST_ADVENTURE_ANSI_RELEASE,
7+
} from "/src/utils/versions";
8+
9+
interface Props {
10+
artifact: string;
11+
project: string;
12+
}
13+
14+
const props: Props = Astro.props;
15+
16+
function getVersion(): string {
17+
switch (props.project) {
18+
case "api":
19+
return LATEST_ADVENTURE_API_RELEASE;
20+
case "platform":
21+
return LATEST_ADVENTURE_PLATFORM_RELEASE;
22+
case "ansi":
23+
return LATEST_ADVENTURE_ANSI_RELEASE;
24+
}
25+
26+
return "LATEST";
27+
}
28+
29+
const version = getVersion();
30+
const mavenCoordinatesString = `net.kyori:${props.artifact}:${version}`;
31+
32+
const mavenDependency = `
33+
<dependency>
34+
<groupId>net.kyori</groupId>
35+
<artifactId>${props.artifact}</artifactId>
36+
<version>${version}</version>
37+
</dependency>
38+
`;
39+
40+
const gradleGroovyDependency = `
41+
repositories {
42+
mavenCentral()
43+
}
44+
45+
dependencies {
46+
implementation "${mavenCoordinatesString}"
47+
}
48+
`;
49+
50+
const gradleKotlinDependency = `
51+
repositories {
52+
mavenCentral()
53+
}
54+
55+
dependencies {
56+
implementation("${mavenCoordinatesString}")
57+
}
58+
`;
59+
---
60+
61+
<p>Declaring the dependency:</p>
62+
63+
<Tabs syncKey="build-system">
64+
<TabItem label="Maven">
65+
<Code lang="xml" code={mavenDependency} />
66+
</TabItem>
67+
<TabItem label="Gradle (Groovy)">
68+
<Code lang="groovy" code={gradleGroovyDependency} />
69+
</TabItem>
70+
<TabItem label="Gradle (Kotlin)">
71+
<Code lang="kotlin" code={gradleKotlinDependency} />
72+
</TabItem>
73+
</Tabs>
74+
75+
<p>
76+
Need development/snapshot builds? <a href="./snapshot-reference">Using Snapshot Builds</a>
77+
</p>
871 KB
Loading
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Audiences
3+
description: A guide to Adventure Audiences.
4+
---
5+
6+
An audience, at its core, is a grouping of 0 or more viewers of some content.
7+
The concept of an audience is where Adventure makes its most clear break from
8+
other Minecraft platforms.
9+
10+
As an API, `Audience` is designed to be a universal interface for any player,
11+
command sender, console, or otherwise who can receive text, titles, boss bars,
12+
and other Minecraft media. This allows extending audiences to cover more than
13+
one individual receiver - possible "audiences" could include a team, server,
14+
world, or all players that satisfy some predicate (such as having a certain
15+
permission). The universal interface also allows reducing boilerplate by
16+
gracefully degrading functionality if it is not applicable. For instance, it
17+
does not make much sense to send a boss bar to a command sender, and you can't
18+
send titles to Minecraft 1.7 clients.
19+
20+
You will normally get audience instances from one of the [Platforms](/adventure/platform).
21+
The Adventure API includes two audience implementations itself: one that does not
22+
support any action (and thus does nothing). `Audience.empty()`, and one that
23+
forwards an action to each member in the audience, `Audience.audience()` and related
24+
methods, along with the `ForwardingAudience` that implements the forwarding logic
25+
for you.
26+
27+
Most users using will primarily use this API to show content created by other parts
28+
of the API.
29+
30+
## Pointers
31+
32+
Audiences can also provide arbitrary information, such as display name or UUID.
33+
This is done using the pointer system.
34+
35+
Examples:
36+
37+
```java
38+
// get the uuid from an audience member, returning an Optional<UUID>
39+
audience.get(Identity.UUID);
40+
41+
// get the display name, returning a default
42+
audience.getOrDefault(Identity.DISPLAY_NAME, Component.text("no display name!"));
43+
```

0 commit comments

Comments
 (0)