-
-
Notifications
You must be signed in to change notification settings - Fork 1
5: Introduction to the API methods and such
The colors that the methods require are String objects, and can be either an RGB hex string, "rainbow", "random", or a custom color animation's name added via datapack. If you want to use RGB values, there is the ColorUtils class which can handle conversions and checks to see if a given something is actually a color or not.
Most likely you will be using the #setColor(target, color)
method, which is valid both for EntityTypes and Entities. The color is a String as described above. To set a global/default color, use #setDefaultColor(color)
or #setGlobalColor(color)
(they do the same thing). You can also find methods that let you set a rainbow or random color directly, like #setRainbowColor(target)
From version 3.2.0, you can also use #setColorFor(target, color, colorViewer)
where only the specified player will be able to see that custom color on an entity.
To get the color of a target, simply do the same thing as above, but using .getColor
To remove or clear a color you can use #clearColor(target, useDefault)
where target is again an Entity or EntityType, and useDefault if set to true will not reset the target's color back to white but to the color used as a default/global color.
To clear the global color use #clearDefaultColor()
.
You can also manage the settings of overrideTeamColor
, typeOverEntity
, globalOverEverything
etc, with the getters and setters as explained in the javadoc.
There also are some methods that let you check if a target has a custom color or not.
The synching is done automaticly by the API everytime you use the methods. This is done by using CardinalComponentsAPI NBT synching feature