Add hex support using &#abcabc
This commit is contained in:
parent
01cf995914
commit
3fb325b0e1
@ -796,7 +796,7 @@ public class DisguiseConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (requireMessage != null) {
|
if (requireMessage != null) {
|
||||||
requireMessage = ChatColor.translateAlternateColorCodes('&', requireMessage);
|
requireMessage = DisguiseUtilities.translateAlternateColorCodes(requireMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
ModdedEntity entity = new ModdedEntity(null, name, living, mod, version, requireMessage, 0);
|
ModdedEntity entity = new ModdedEntity(null, name, living, mod, version, requireMessage, 0);
|
||||||
|
@ -224,7 +224,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||||||
name = name.replace("%complex%", DisguiseUtilities.getDisplayName(player));
|
name = name.replace("%complex%", DisguiseUtilities.getDisplayName(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ChatColor.translateAlternateColorCodes('&', name);
|
return DisguiseUtilities.translateAlternateColorCodes(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArrayList<String> getAllowedDisguises(DisguisePermissions permissions) {
|
protected ArrayList<String> getAllowedDisguises(DisguisePermissions permissions) {
|
||||||
|
@ -109,6 +109,6 @@ public class DisguiseEntityInteraction implements LibsEntityInteract {
|
|||||||
name = name.replace("%complex%", DisguiseUtilities.getDisplayName(player));
|
name = name.replace("%complex%", DisguiseUtilities.getDisplayName(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ChatColor.translateAlternateColorCodes('&', name);
|
return DisguiseUtilities.translateAlternateColorCodes(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2444,6 +2444,16 @@ public class DisguiseUtilities {
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String translateAlternateColorCodes(String string) {
|
||||||
|
string = DisguiseUtilities.translateAlternateColorCodes(string);
|
||||||
|
|
||||||
|
if (NmsVersion.v1_16.isSupported()) {
|
||||||
|
return string.replaceAll("&(?=#[0-9a-fA-F]{6})", ChatColor.COLOR_CHAR + "");
|
||||||
|
}
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modification of TextComponent.fromLegacyText
|
* Modification of TextComponent.fromLegacyText
|
||||||
*/
|
*/
|
||||||
@ -2461,23 +2471,20 @@ public class DisguiseUtilities {
|
|||||||
char c = message.charAt(i);
|
char c = message.charAt(i);
|
||||||
TextComponent old;
|
TextComponent old;
|
||||||
|
|
||||||
if (c == ChatColor.COLOR_CHAR || (c == '<' && i + 9 < message.length() && NmsVersion.v1_16.isSupported() &&
|
if (c == ChatColor.COLOR_CHAR && i + 1 >= message.length()) {
|
||||||
Pattern.matches("<#[0-9a-fA-F]{6}>", message.substring(i, i + 9)))) {
|
break;
|
||||||
// If normal color char
|
}
|
||||||
if (c == ChatColor.COLOR_CHAR) {
|
|
||||||
++i;
|
|
||||||
|
|
||||||
if (i >= message.length()) {
|
if (c == ChatColor.COLOR_CHAR || (NmsVersion.v1_16.isSupported() && c == '<' && i + 9 < message.length() &&
|
||||||
break;
|
Pattern.matches("<#[0-9a-fA-F]{6}>", message.substring(i, i + 9)))) {
|
||||||
}
|
i++;
|
||||||
}
|
|
||||||
|
|
||||||
net.md_5.bungee.api.ChatColor format;
|
net.md_5.bungee.api.ChatColor format;
|
||||||
|
|
||||||
if (c != ChatColor.COLOR_CHAR) {
|
if (c != ChatColor.COLOR_CHAR || (message.length() - i >= 7 && Pattern.matches("#[0-9a-fA-F]{6}", message.substring(i, i + 7)))) {
|
||||||
format = net.md_5.bungee.api.ChatColor.of(message.substring(i + 1, i + 8));
|
format = net.md_5.bungee.api.ChatColor.of(message.substring(i, i + 7));
|
||||||
|
|
||||||
i += 8;
|
i += c == ChatColor.COLOR_CHAR ? 7 : 8;
|
||||||
} else {
|
} else {
|
||||||
c = message.charAt(i);
|
c = message.charAt(i);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities.params.types.base;
|
package me.libraryaddict.disguise.utilities.params.types.base;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ public class ParamInfoString extends ParamInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object fromString(String string) {
|
protected Object fromString(String string) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return DisguiseUtilities.translateAlternateColorCodes(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -744,7 +744,7 @@ public class DisguiseParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct the player disguise
|
// Construct the player disguise
|
||||||
disguise = new PlayerDisguise(ChatColor.translateAlternateColorCodes('&', args[1]));
|
disguise = new PlayerDisguise(DisguiseUtilities.translateAlternateColorCodes(args[1]));
|
||||||
|
|
||||||
if (!customName) {
|
if (!customName) {
|
||||||
name = ((PlayerDisguise) disguise).getName();
|
name = ((PlayerDisguise) disguise).getName();
|
||||||
|
@ -96,7 +96,7 @@ public enum TranslateType {
|
|||||||
DisguiseUtilities.getLogger()
|
DisguiseUtilities.getLogger()
|
||||||
.severe("Translation for " + name() + " has a null value for the key '" + key + "'");
|
.severe("Translation for " + name() + " has a null value for the key '" + key + "'");
|
||||||
} else {
|
} else {
|
||||||
String newKey = ChatColor.translateAlternateColorCodes('&', key);
|
String newKey = DisguiseUtilities.translateAlternateColorCodes(key);
|
||||||
|
|
||||||
if (translated.containsKey(newKey)) {
|
if (translated.containsKey(newKey)) {
|
||||||
if (dupes++ < 5) {
|
if (dupes++ < 5) {
|
||||||
@ -115,7 +115,7 @@ public enum TranslateType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
translated.put(newKey, ChatColor.translateAlternateColorCodes('&', value));
|
translated.put(newKey, DisguiseUtilities.translateAlternateColorCodes(value));
|
||||||
|
|
||||||
if (!newKey.equals(translated.get(newKey))) {
|
if (!newKey.equals(translated.get(newKey))) {
|
||||||
diff++;
|
diff++;
|
||||||
|
Loading…
Reference in New Issue
Block a user