Skip to content

Asintotoo/ColorLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

ColorLib - A Color API for Minecraft Spigot Plugins

How to include the API with Maven

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.github.Asintotoo</groupId>
        <artifactId>ColorLib</artifactId>
        <version>1.0.0</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

Note: ColorLib uses external Libraries that requires Shading in order to be used in your Minecraft Plugin, please include the following in your pom.xml

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

Usage

The Main Java method to process a String is ColorLib.setColors("your message here");

To add a Gradient use the tag:

ColorLib.setColors("<GRADIENT:FF0000>This is a Gradient Text</GRADIENT:00FF00>");

image

To add a Rainbow text use the tag:

ColorLib.setColors("<RAINBOW:1>This is a Rainbow Text</RAINBOW>");

image The number after RAINBOW represents the saturation

ColorLib.setColors("<RAINBOW:50>This is a Rainbow Text</RAINBOW>");

image

To set a simple Solid color use the tag:

ColorLib.setColors("<SOLID:aabbcc>This is a Solid Text");

image

Note: If your server is running a version before 1.16 the resulting color will be the nearest supported one (This also applies to gradient)

Normal Chat Color Codes works too:

ColorLib.setColors("&5This is a Simple Text");

image

Advanced Usage

The API comes with some additional method that you may want to use:

Get a processed text with the addition of inserting all PlaceholderAPI's placeholders refering to a given player:

ColorLib.setColorsAndPlaceholders(Bukkit.getPlayer("Maggiollo"), "<GRADIENT:FF0000>Ciao %player_name%</GRADIENT:0000FF>");

image

Get a processed text given a YamlConfiguration path:

ColorLib.getColoredStringFromConfig((YamlConfiguration) plugin.getConfig(), "messages.example");

this will format the following text:

messages:
  example: "<SOLID:00aaff>This is an Example"

Get a processed text given a YamlConfiguration path and insert all PlaceholderAPI's placeholders refering to a given player:

ColorLib.getColoredStringFromConfigWithPlaceholders((YamlConfiguration) plugin.getConfig(), Bukkit.getPlayer("Maggiollo"), "messages.example-papi");

this will format the following text replacing %player_name% with "Maggiollo":

messages:
  example-papi: "<SOLID:00aa55>Hello %player_name%"

Note: All the method using the "Player" class are also compatible with the "OfflinePlayer" class.

Note: All the methods that use PlaceholderAPI's Placeholders requires PlaceholderAPI to be installed on the server, you can download it from here