BlueBridge icon indicating copy to clipboard operation
BlueBridge copied to clipboard

Flagname with colors

Open Lauwy222 opened this issue 1 year ago • 1 comments

Hey,

I'm currently using protectionstones and bluemap. I am using this flag in the BlueBridgeWG: ${flag:ps-name} But it will also show the color/markup. image What can I do to remove these?

Lauwy222 avatar Jun 13 '24 13:06 Lauwy222

Currently nothing except maybe if Protectionstones has a different flag for the raw flag without formatting. Since those are legacy color codes with a non standard symbol ('&' instead of '§') I don't think I'll specifically add support for this. However, if I do ever continue actively working on this plugin, I was planning on adding support for recursive replacements and some utility functions like regex replacements in placeholder values etc. So you might be able to work your way around this in the future and I'll definitely keep this issue in mind when I implement something like that, to make sure situations like this one can be resolved using those features.

For now, if you really need this to work and know your way around Java a bit, you could change the final return statement in line 195 in RegionStringLookup.java to something like this:

//Add this to the existing imports at the top of the file
import org.bukkit.ChatColor;

//[...]

//Replace line 195 with the following:
String flagValueString = flagValue.toString();
if("ps-name".equals(flagName)){
    //Uses Bukkit API to translate from & to § codes and then removes all formatting
    flagValueString = ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', flagValueString));
}
return BlueBridgeUtils.escapeHtml(flagValueString);

Just clone this repo, change the code in that file and recompile using ./gradlew build in the repo's root directory. That would be a pretty simple fix for your case but as it's very hardcoded and specific, I can't release this as a new version right now.

Mark-225 avatar Jun 15 '24 17:06 Mark-225