Skip to content

Commit 321b7e5

Browse files
committed
Improve readme
1 parent e29672a commit 321b7e5

File tree

1 file changed

+9
-108
lines changed

1 file changed

+9
-108
lines changed

readme.md

+9-108
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,17 @@
1-
# adventure [![License](https://img.shields.io/github/license/KyoriPowered/adventure.svg)](https://github.com/KyoriPowered/adventure/blob/master/license.txt) ![build](https://github.com/KyoriPowered/adventure/workflows/build/badge.svg?branch=master)
1+
# adventure
22

3-
A serverside user interface library for Minecraft.
3+
![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/KyoriPowered/adventure/build/master) [![MIT License](https://img.shields.io/badge/license-MIT-blue)](license.txt) [![Maven Central](https://img.shields.io/maven-central/v/net.kyori/adventure-api?label=stable)](https://search.maven.org/search?q=g:net.kyori%20AND%20a:adventure*) ![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/net.kyori/adventure-api?label=dev&server=https%3A%2F%2Foss.sonatype.org)
44

5-
#### Artifacts
5+
A serverside user interface library for *Minecraft: Java Edition*
66

7-
There are various artifacts:
7+
See the [documentation](https://docs.adventure.kyori.net/) for usage and dependency information for this project and associated libraries.
88

9-
* `adventure-api` is the core project - you will always want to import this.
10-
* `adventure-text-serializer-gson` is a GSON-based JSON serializer.
11-
* `adventure-text-serializer-legacy` is a legacy character text serializer.
12-
* `adventure-text-serializer-plain` is a plain text serializer.
9+
### Contributing
1310

14-
#### Importing text into your project
11+
We appreciate contributions of any type. For any new features or typo-fix/style changes, please open an issue or come talk to us in our [Discord] first so we make sure you're going in the right direction for the project.
1512

16-
* Maven
17-
```xml
18-
<dependency>
19-
<groupId>net.kyori</groupId>
20-
<artifactId>adventure-api</artifactId>
21-
<version>4.0.0-SNAPSHOT</version>
22-
</dependency>
23-
```
24-
* Gradle
25-
```gradle
26-
repositories {
27-
mavenCentral()
28-
}
13+
All the adventure projects are built with Gradle, require at least JDK 8, and use a common checkstyle configuration. Please make sure all tests pass, license headers are updated, and checkstyle passes to help us review your contribution.
2914

30-
dependencies {
31-
compile 'net.kyori:adventure-api:4.0.0-SNAPSHOT'
32-
}
33-
```
15+
`adventure` is released under the terms of the [MIT License](license.txt).
3416

35-
### Example usage
36-
37-
#### Creating components
38-
39-
```java
40-
// Creates a line of text saying "You're a Bunny! Press <key> to jump!", with some colouring and styling.
41-
final TextComponent textComponent = TextComponent.of("You're a ")
42-
.color(NamedTextColor.GRAY)
43-
.append(TextComponent.of("Bunny").color(NamedTextColor.LIGHT_PURPLE))
44-
.append(TextComponent.of("! Press "))
45-
.append(
46-
KeybindComponent.of("key.jump")
47-
.color(NamedTextColor.LIGHT_PURPLE)
48-
.decoration(TextDecoration.BOLD, true)
49-
)
50-
.append(TextComponent.of(" to jump!"));
51-
// now you can send `textComponent` to something, such as a client
52-
```
53-
54-
You can also use a builder, which is mutable, and creates one final component with the children.
55-
```java
56-
// Creates a line of text saying "You're a Bunny! Press <key> to jump!", with some colouring and styling.
57-
final TextComponent textComponent2 = TextComponent.builder().content("You're a ")
58-
.color(NamedTextColor.GRAY)
59-
.append(TextComponent.builder("Bunny").color(NamedTextColor.LIGHT_PURPLE).build())
60-
.append(TextComponent.of("! Press "))
61-
.append(
62-
KeybindComponent.builder("key.jump")
63-
.color(NamedTextColor.LIGHT_PURPLE)
64-
.decoration(TextDecoration.BOLD, true)
65-
.build()
66-
)
67-
.append(TextComponent.of(" to jump!"))
68-
.build();
69-
// now you can send `textComponent2` to something, such as a client
70-
```
71-
72-
#### Serializing and deserializing components
73-
74-
Serialization to JSON, legacy and plain representations is also supported.
75-
76-
```java
77-
// Creates a text component
78-
final TextComponent textComponent = TextComponent.of("Hello ")
79-
.color(NamedTextColor.GOLD)
80-
.append(
81-
TextComponent.of("world")
82-
.color(NamedTextColor.AQUA).
83-
decoration(TextDecoration.BOLD, true)
84-
)
85-
.append(TextComponent.of("!").color(NamedTextColor.RED));
86-
87-
// Converts textComponent to the JSON form used for serialization by Minecraft.
88-
String json = GsonComponentSerializer.INSTANCE.serialize(textComponent);
89-
90-
// Converts textComponent to a legacy string - "&6Hello &b&lworld&c!"
91-
String legacy = LegacyComponentSerializer.legacy().serialize(textComponent, '&');
92-
93-
// Converts textComponent to a plain string - "Hello world!"
94-
String plain = PlainComponentSerializer.INSTANCE.serialize(textComponent);
95-
```
96-
97-
The same is of course also possible in reverse for deserialization.
98-
99-
```java
100-
// Converts JSON in the form used for serialization by Minecraft to a Component
101-
Component component = GsonComponentSerializer.INSTANCE.deserialize(json);
102-
103-
// Converts a legacy string (using formatting codes) to a TextComponent
104-
TextComponent component = LegacyComponentSerializer.legacy().deserialize("&6Hello &b&lworld&c!", '&');
105-
106-
// Converts a plain string to a TextComponent
107-
TextComponent component = PlainComponentSerializer.INSTANCE.deserialize("Hello world!");
108-
```
109-
110-
#### Using components within your application
111-
112-
The way you use components within your application will of course vary depending on what you're aiming to achieve.
113-
114-
However, the most common task is likely to be sending a component to some sort of Minecraft client. The method for doing this will depend on the platform your program is running on, however it is likely to involve serializing the component to Minecraft's JSON format, and then sending the JSON through another method provided by the platform.
115-
116-
The text library is platform agnostic and therefore doesn't provide any way to send components to clients. However, some platform adapters (which make this easy!) can be found in the [adventure-platform](https://github.com/KyoriPowered/adventure-platform) project.
17+
[Discord]: https://discord.gg/MMfhJ8F

0 commit comments

Comments
 (0)