add api version - fix legacy support
This commit is contained in:
parent
a1bfac4cd6
commit
110caa9d3f
|
|
@ -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<String> colorList(List<String> list){
|
||||
List<String> lines = new ArrayList<String>();
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user