-
-
Notifications
You must be signed in to change notification settings - Fork 3
Core
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 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 id = Identifier.tryOf("test:data");
The Identifier.tryOf()
method returns null if the path/value contain illegal chars.
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.
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.
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.