diff --git a/src/main/java/com/alttd/destro174/custommotd/CustomMOTD.java b/src/main/java/com/alttd/destro174/custommotd/CustomMOTD.java index 97a55e5..eed37ef 100644 --- a/src/main/java/com/alttd/destro174/custommotd/CustomMOTD.java +++ b/src/main/java/com/alttd/destro174/custommotd/CustomMOTD.java @@ -2,13 +2,15 @@ package com.alttd.destro174.custommotd; import java.util.ArrayList; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import com.alttd.destro174.custommotd.commands.custommotdCommand; import com.alttd.destro174.custommotd.listener.PapiPingListener; import com.alttd.destro174.custommotd.listener.PingListener; import com.alttd.destro174.custommotd.storage.MOTDConfig; +import net.md_5.bungee.api.ChatColor; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -26,11 +28,24 @@ public class CustomMOTD extends JavaPlugin { public static CachedServerIcon icon; public boolean useproxyonlinecount; + private Pattern PATTERN = Pattern.compile("\\{&#[0-9a-fA-F]{6}\\}"); + private Pattern GRADIENT = Pattern.compile("\\{&#[0-9a-fA-F]{6}>\\}[^\\{]*\\{&#[0-9a-fA-F]{6}<\\}"); public List colorList(List list){ List lines = new ArrayList(); for (String s : list) { + Matcher matcher = PATTERN.matcher(s); + while(matcher.find()) { + /* + val hexcode = m.group() + val fixed = hexcode.substring(2, 8) + */ + String hexcode = matcher.group(); + String color = hexcode.substring(2, 9); + s = s.replace(matcher.group(), ChatColor.of(color) + ""); + matcher = PATTERN.matcher(s); + } s = s.replace("%version%", Bukkit.getMinecraftVersion()); // 1.16 addon lines.add(ChatColor.translateAlternateColorCodes('&', s)); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 338e0f0..aa4545f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,6 +2,7 @@ name: CustomMOTD main: com.alttd.destro174.custommotd.CustomMOTD version: 1.0 author: destro174 +api-version: 1.16 softdepend: [PlaceholderAPI] commands: custommotd: