Correctly replace color codes after replacing PlaceholderAPI placeholder

A user reported that user/group prefixes may containt color codes like `&e` which are not
replaced in the end to be rendered correctly

I believe the responsible plugin should take care of that but apparently there are multiple...
So we just replace them in the end ^^
This commit is contained in:
Christian Koop 2023-08-18 09:52:30 +02:00
parent f22ac073f7
commit 2e37efefd4
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3

View File

@ -3,25 +3,25 @@ package com.craftaro.skyblock.placeholder;
import com.craftaro.skyblock.SkyBlock;
import com.craftaro.skyblock.manager.Manager;
import com.craftaro.skyblock.placeholder.hook.PlaceholderAPI;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
public class PlaceholderManager extends Manager {
private boolean placeholderAPIEnabled = false;
private final PlaceholderAPI skyBlockPlaceholderAPI;
private final boolean placeholderAPIEnabled;
public PlaceholderManager(SkyBlock plugin) {
super(plugin);
this.skyBlockPlaceholderAPI = new PlaceholderAPI(this.plugin);
PluginManager pluginManager = plugin.getServer().getPluginManager();
if (pluginManager.getPlugin("PlaceholderAPI") != null) {
this.placeholderAPIEnabled = true;
}
PluginManager pluginManager = this.plugin.getServer().getPluginManager();
this.placeholderAPIEnabled = pluginManager.getPlugin("PlaceholderAPI") != null;
}
public void registerPlaceholders() {
if (this.placeholderAPIEnabled) {
new PlaceholderAPI(this.plugin).register();
this.skyBlockPlaceholderAPI.register();
}
}
@ -34,6 +34,7 @@ public class PlaceholderManager extends Manager {
if (this.placeholderAPIEnabled) {
retValue = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, message);
retValue = ChatColor.translateAlternateColorCodes('&', retValue);
}
return retValue;
}