Skip to content
Lenni0451 edited this page Jan 4, 2023 · 2 revisions

Identifier

The Identifier is an unique id used by minecraft.
You can create one using the of or the tryOf method.
Identifiers can only contain a few chars:
Path: [_\-a-z.]
Value: [_\-a-z/.]

Identifier.of

Identifier id = Identifier.of("test:data");
Identifier id = Identifier.of("test", "data");

The Identifier.of() methods may throw an IllegalArgumentException if the path/value contain illegal chars.

Identifier.tryOf

Identifier id = Identifier.tryOf("test:data");

The Identifier.tryOf() method returns null if the path/value contain illegal chars.

TextFormatting

The TextFormatting class contains all formattings used by minecraft.
It is also a wrapper for rgb colors which can be used since minecraft 1.16.

TextFormatting.parse

To create a TextFormatting you can use the parse method:

TextFormatting formatting = TextFormatting.parse("#FF0000"); //Red (r: 255, g: 0, b: 0)

The parse method also accepts the name of a vanilla formatting (ignore case):

TextFormatting formatting = TextFormatting.parse("red"); //Red (§c)

It returns null if the string is neither a rgb color nor a vanilla formatting.

TextFormatting.getByName

If you just want to get the vanilla formatting you can use the getByName method:

TextFormatting formatting = TextFormatting.getByName("red"); //Red (§c)

It also returns null if the name is not a vanilla formatting.

Clone this wiki locally