Skip to content

Commit

Permalink
Merge pull request #128 from MultiChat/v19
Browse files Browse the repository at this point in the history
MultiChat v1.9.5 - Fix RGB codes not working when set in MultiChat formats
  • Loading branch information
OllieMartin authored Jul 20, 2020
2 parents e4015c7 + 6188ae7 commit c321ce7
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 19 deletions.
2 changes: 1 addition & 1 deletion multichat/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.olivermartin.multichat</groupId>
<artifactId>multichat</artifactId>
<version>1.9.4</version>
<version>1.9.5</version>
<build>
<plugins>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion multichat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>xyz.olivermartin.multichat</groupId>
<artifactId>multichat</artifactId>
<version>1.9.4</version>
<version>1.9.5</version>

<repositories>

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
*/
public class MultiChat extends Plugin implements Listener {

public static final String LATEST_VERSION = "1.9.4";
public static final String LATEST_VERSION = "1.9.5";

public static final String[] ALLOWED_VERSIONS = new String[] {

LATEST_VERSION,
"1.9.4",
"1.9.3",
"1.9.2",
"1.9.1",
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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import xyz.olivermartin.multichat.local.sponge.listeners.communication.LocalSpongePlayerChannelListener;
import xyz.olivermartin.multichat.local.sponge.listeners.communication.LocalSpongePlayerMetaListener;

@Plugin(id = "multichat", name = "MultiChat", version = "1.9.4", dependencies = { @Dependency(id = "placeholderapi", optional = true) })
@Plugin(id = "multichat", name = "MultiChat", version = "1.9.5", dependencies = { @Dependency(id = "placeholderapi", optional = true) })
public class MultiChatLocalSpongePlugin {

@Inject
Expand Down
2 changes: 1 addition & 1 deletion multichat/src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: MultiChat
main: xyz.olivermartin.multichat.bungee.MultiChat
version: 1.9.4
version: 1.9.5
author: Revilo410
api-version: 1.16
softdepends: [PremiumVanish]
2 changes: 1 addition & 1 deletion multichat/src/main/resources/chatcontrol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

##################
# DON'T EDIT #
version: "1.9.4" #
version: "1.9.5" #
##################

# 1. Chat Control Rules
Expand Down
2 changes: 1 addition & 1 deletion multichat/src/main/resources/chatcontrol_fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

##################
# NE PAS EDITER #
version: "1.9.4" #
version: "1.9.5" #
##################

# French Translation by Nogapra - Thank you !
Expand Down
2 changes: 1 addition & 1 deletion multichat/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

##################
# DON'T EDIT #
version: "1.9.4" #
version: "1.9.5" #
##################

# 1. General
Expand Down
2 changes: 1 addition & 1 deletion multichat/src/main/resources/config_fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

##################
# NE PAS EDITER #
version: "1.9.4" #
version: "1.9.5" #
##################

# French Translation by Nogapra - Thank you !
Expand Down
2 changes: 1 addition & 1 deletion multichat/src/main/resources/joinmessages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

##################
# DON'T EDIT #
version: "1.9.4" #
version: "1.9.5" #
##################

############################################################
Expand Down
2 changes: 1 addition & 1 deletion multichat/src/main/resources/joinmessages_fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

##################
# Ne pas éditer #
version: "1.9.4" #
version: "1.9.5" #
##################

# French Translation by Nogapra - Thank you!
Expand Down
2 changes: 1 addition & 1 deletion multichat/src/main/resources/localconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

##################
# DON'T EDIT #
version: "1.9.4" #
version: "1.9.5" #
##################

# 1. Global Chat Settings
Expand Down
2 changes: 1 addition & 1 deletion multichat/src/main/resources/localconfig_fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

##################
# NE PAS EDITER #
version: "1.9.4" #
version: "1.9.5" #
##################

# French Translation by Nogapra - Thank you !
Expand Down
2 changes: 1 addition & 1 deletion multichat/src/main/resources/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

##################
# DON'T EDIT #
version: "1.9.4" #
version: "1.9.5" #
##################

############################################################
Expand Down
2 changes: 1 addition & 1 deletion multichat/src/main/resources/messages_fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

##################
# DON'T EDIT #
version: "1.9.4" #
version: "1.9.5" #
##################

# French Translation by Nogapra - Thank you!
Expand Down
2 changes: 1 addition & 1 deletion multichat/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: MultiChat
version: 1.9.4
version: 1.9.5
author: Revilo410
main: xyz.olivermartin.multichat.local.spigot.MultiChatLocalSpigotPlugin
softdepend: [Vault,PlaceholderAPI]
Expand Down

0 comments on commit c321ce7

Please sign in to comment.