mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2025-01-22 21:41:28 +01:00
Added Hex Color Support.
This commit is contained in:
parent
2ec314f7fe
commit
ba90084c4a
6
pom.xml
6
pom.xml
@ -48,12 +48,6 @@
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<groupId>net.md-5</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
|
@ -17,14 +17,26 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Methods {
|
||||
|
||||
public static Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("CrazyAuctions");
|
||||
private static FileManager fileManager = FileManager.getInstance();
|
||||
|
||||
public static String color(String msg) {
|
||||
return ChatColor.translateAlternateColorCodes('&', msg);
|
||||
public final static Pattern HEX_PATTERN = Pattern.compile("#[a-fA-F0-9]{6}");
|
||||
|
||||
public static String color(String message) {
|
||||
if (Version.isNewer(Version.v1_15_R1)) {
|
||||
Matcher matcher = HEX_PATTERN.matcher(message);
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
matcher.appendReplacement(buffer, net.md_5.bungee.api.ChatColor.of(matcher.group()).toString());
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', message);
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
|
@ -14,8 +14,7 @@ public enum Version {
|
||||
v1_13_R2(1132),
|
||||
v1_14_R1(1141),
|
||||
v1_15_R1(1151),
|
||||
v1_16_R1(1161),
|
||||
v1_16_R2(1162),
|
||||
v1_16_R1(1161), v1_16_R2(1162), v1_16_R3(1163),
|
||||
TOO_NEW(-2);
|
||||
|
||||
private static Version currentVersion;
|
||||
|
Loading…
Reference in New Issue
Block a user