Skip to content

Implement changes from v1.9.5 into development branch of v1.10 #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class MultiChat extends Plugin implements Listener {
public static final String[] ALLOWED_VERSIONS = new String[] {

LATEST_VERSION,
"1.9.5",
"1.9.4",
"1.9.3",
"1.9.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import net.milkbowl.vault.chat.Chat;
import xyz.olivermartin.multichat.bungee.MultiChatUtil;
import xyz.olivermartin.multichat.local.common.LocalConsoleLogger;
import xyz.olivermartin.multichat.local.common.LocalMetaManager;
import xyz.olivermartin.multichat.local.common.MultiChatLocal;
import xyz.olivermartin.multichat.local.spigot.hooks.LocalSpigotVaultHook;
Expand Down Expand Up @@ -72,22 +73,40 @@ public String getWorld(UUID uuid) {
@Override
public String getDisplayName(UUID uuid) {

LocalConsoleLogger logger = MultiChatLocal.getInstance().getConsoleLogger();

Player player = Bukkit.getPlayer(uuid);

if (player == null) return "";

// If MultiChat is setting the display name...
if (MultiChatLocal.getInstance().getDataStore().isSetDisplayName()) {

logger.debug("[LocalSpigotMetaManager] We are setting the display name!");

String displayNameFormat = MultiChatLocal.getInstance().getDataStore().getDisplayNameFormatLastVal();

logger.debug("[LocalSpigotMetaManager] Format = " + displayNameFormat);
logger.debug("[LocalSpigotMetaManager] Format (using & only) = " + displayNameFormat.replaceAll("(?i)�(?=[a-f,0-9,k-o,r,x])", "&"));

// TODO This stuff could be refactored as it is duplicated between Spigot and Sponge
displayNameFormat = displayNameFormat.replaceAll("%NICK%", getNick(uuid));
displayNameFormat = displayNameFormat.replaceAll("%NAME%", player.getName());
displayNameFormat = displayNameFormat.replaceAll("%PREFIX%", getPrefix(uuid));
displayNameFormat = displayNameFormat.replaceAll("%SUFFIX%", getSuffix(uuid));

logger.debug("[LocalSpigotMetaManager] Format with placeholders = " + displayNameFormat);
logger.debug("[LocalSpigotMetaManager] Format with placeholders (using & only) = " + displayNameFormat.replaceAll("(?i)�(?=[a-f,0-9,k-o,r,x])", "&"));

displayNameFormat = MultiChatUtil.reformatRGB(displayNameFormat);
displayNameFormat = displayNameFormat.replaceAll("&(?=[a-f,0-9,k-o,r,x])", "�");

logger.debug("[LocalSpigotMetaManager] Format after reformatting RGB = " + displayNameFormat);
logger.debug("[LocalSpigotMetaManager] Format after reformatting RGB (using & only) = " + displayNameFormat.replaceAll("(?i)�(?=[a-f,0-9,k-o,r,x])", "&"));

displayNameFormat = displayNameFormat.replaceAll("(?i)&(?=[a-f,0-9,k-o,r,x])", "�");

logger.debug("[LocalSpigotMetaManager] FINAL = " + displayNameFormat);
logger.debug("[LocalSpigotMetaManager] FINAL (using & only) = " + displayNameFormat.replaceAll("(?i)�(?=[a-f,0-9,k-o,r,x])", "&"));

// LEGACY HACK
if (MultiChatLocal.getInstance().getDataStore().isLegacy()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.UUID;

import xyz.olivermartin.multichat.bungee.MultiChatUtil;
import xyz.olivermartin.multichat.local.common.LocalPlaceholderManager;
import xyz.olivermartin.multichat.local.common.MultiChatLocalPlatform;

Expand All @@ -14,6 +15,9 @@ public LocalSpigotPlaceholderManager() {
@Override
public String buildChatFormat(UUID uuid, String format) {

// Reformat any hex codes in the format
format = MultiChatUtil.reformatRGB(format);

// RESPECT OTHER PLUGIN'S DISPLAY NAMES FIRST! (Allows for factions etc.)
format = format.replace("%DISPLAYNAME%", "%1$s");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public String getDisplayName(UUID uuid) {
displayNameFormat = displayNameFormat.replaceAll("%PREFIX%", getPrefix(uuid));
displayNameFormat = displayNameFormat.replaceAll("%SUFFIX%", getSuffix(uuid));
displayNameFormat = MultiChatUtil.reformatRGB(displayNameFormat);
displayNameFormat = displayNameFormat.replaceAll("&(?=[a-f,0-9,k-o,r,x])", "�");
displayNameFormat = displayNameFormat.replaceAll("(?i)&(?=[a-f,0-9,k-o,r,x])", "�");

displayNameFormat = MultiChatUtil.approximateHexCodes(displayNameFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.UUID;

import xyz.olivermartin.multichat.bungee.MultiChatUtil;
import xyz.olivermartin.multichat.local.common.LocalPlaceholderManager;
import xyz.olivermartin.multichat.local.common.MultiChatLocalPlatform;

Expand All @@ -13,7 +14,11 @@ public LocalSpongePlaceholderManager() {

@Override
public String buildChatFormat(UUID uuid, String format) {
return processMultiChatPlaceholders(uuid, format).replaceAll("&(?=[a-f,0-9,k-o,r])", "�");
// Reformat any hex codes in the format
format = MultiChatUtil.reformatRGB(format);
format = processMultiChatPlaceholders(uuid, format).replaceAll("(?i)&(?=[a-f,0-9,k-o,r,x])", "�");
format = MultiChatUtil.approximateHexCodes(format);
return format;
}

}