Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/asintotoo/colorlib

A Color API for Minecraft Spigot Plugins
https://github.com/asintotoo/colorlib

api color colors hexcode hexcolor java library message minecraft minecraft-api minecraft-library minecraft-plugin paper-plugin papermc spigot spigot-api spigot-plugin spigotmc

Last synced: about 2 hours ago
JSON representation

A Color API for Minecraft Spigot Plugins

Awesome Lists containing this project

README

        

## ColorLib - A Color API for Minecraft Spigot Plugins

How to include the API with Maven
```xml


jitpack.io
https://jitpack.io


com.github.Asintotoo
ColorLib
1.0.0
compile

```

**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*
```xml



org.apache.maven.plugins
maven-shade-plugin
3.1.0


package

shade






```

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

To add a *Gradient* use the tag:
```java
ColorLib.setColors("This is a Gradient Text");
```
![image](https://github.com/Asintotoo/ColorLib/assets/166311378/25021f09-8f48-4354-8494-0d4fbbc1917a)

To add a *Rainbow* text use the tag:
```java
ColorLib.setColors("This is a Rainbow Text");
```
![image](https://github.com/Asintotoo/ColorLib/assets/166311378/53d4c569-b6bf-4e55-8dc8-b41360341852)
The number after RAINBOW represents the saturation
```java
ColorLib.setColors("This is a Rainbow Text");
```
![image](https://github.com/Asintotoo/ColorLib/assets/166311378/776687d8-4b23-40d5-9b21-b8fd80ccb98d)

To set a simple *Solid* color use the tag:
```java
ColorLib.setColors("This is a Solid Text");
```
![image](https://github.com/Asintotoo/ColorLib/assets/166311378/0bead61c-1f73-43f5-b519-ee371aba98d1)

**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:
```java
ColorLib.setColors("&5This is a Simple Text");
```
![image](https://github.com/Asintotoo/ColorLib/assets/166311378/4a56bf6e-9fb8-4b2d-a19f-4200303060af)

# 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:
```java
ColorLib.setColorsAndPlaceholders(Bukkit.getPlayer("Maggiollo"), "Ciao %player_name%");
```
![image](https://github.com/Asintotoo/ColorLib/assets/166311378/0abd3564-92ef-45ee-afdb-68261ac17547)

Get a processed text given a YamlConfiguration path:
```java
ColorLib.getColoredStringFromConfig((YamlConfiguration) plugin.getConfig(), "messages.example");
```
this will format the following text:
```yml
messages:
example: "This is an Example"
```

Get a processed text given a YamlConfiguration path and insert all PlaceholderAPI's placeholders refering to a given player:
```java
ColorLib.getColoredStringFromConfigWithPlaceholders((YamlConfiguration) plugin.getConfig(), Bukkit.getPlayer("Maggiollo"), "messages.example-papi");
```
this will format the following text replacing %player_name% with "Maggiollo":
```yml
messages:
example-papi: "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](https://www.spigotmc.org/resources/placeholderapi.6245/)