From 88d9b081fa001a4117946fc58a446b94b1588f85 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 30 Jan 2022 11:55:52 +1300 Subject: [PATCH] Convert between spigot colorcodes and my own... --- .../libraryaddict/disguise/disguisetypes/Disguise.java | 4 ++++ .../disguise/disguisetypes/FlagWatcher.java | 2 ++ .../disguise/disguisetypes/PlayerDisguise.java | 7 ++++--- .../disguise/utilities/DisguiseUtilities.java | 10 +++++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java index fc6b7495..321db731 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -144,6 +144,10 @@ public abstract class Disguise { name = new String[0]; } + for (int i = 0; i < name.length; i++) { + name[i] = DisguiseUtilities.getHexedColors(name[i]); + } + name = DisguiseUtilities.reverse(name); String[] oldName = multiName; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index bb8c0aec..f411a32e 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -539,6 +539,8 @@ public class FlagWatcher { name = name.substring(1); } + name = DisguiseUtilities.getHexedColors(name); + String customName = getCustomName(); if (Objects.equals(customName, name)) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java index ab2b2a99..712d6c35 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java @@ -147,10 +147,9 @@ public class PlayerDisguise extends TargetedDisguise { */ public String getProfileName() { return isUpsideDown() ? "Dinnerbone" : - isDeadmau5Ears() ? "deadmau5" : hasScoreboardName() ? getScoreboardName().getPlayer() : getName().isEmpty() ? "§r" : getName(); + isDeadmau5Ears() ? "deadmau5" : hasScoreboardName() ? getScoreboardName().getPlayer() : getName().isEmpty() ? "§r" : getName(); } - public boolean isNameVisible() { return nameVisible; } @@ -291,10 +290,12 @@ public class PlayerDisguise extends TargetedDisguise { } if (DisguiseConfig.isCopyPlayerTeamInfo() && (DisguiseConfig.getPlayerNameType() == DisguiseConfig.PlayerNameType.TEAMS || - DisguiseConfig.getPlayerNameType() == DisguiseConfig.PlayerNameType.ARMORSTANDS)) { + DisguiseConfig.getPlayerNameType() == DisguiseConfig.PlayerNameType.ARMORSTANDS)) { name = DisguiseUtilities.getDisplayName(name); } + name = DisguiseUtilities.getHexedColors(name); + if (name.equals(playerName)) { return; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index da582b7b..b0b3e576 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -289,7 +289,15 @@ public class DisguiseUtilities { name = team.getPrefix() + team.getColor() + player.getName() + team.getSuffix(); } - return name.replaceAll("§x§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])", "<#$1$2$3$4$5$6>"); + return getHexedColors(name); + } + + public static String getHexedColors(String string) { + if (string == null) { + return string; + } + + return string.replaceAll("§x§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])", "<#$1$2$3$4$5$6>"); } public static String getDisplayName(String playerName) {