Fixed bug with the json algorithm

Prefixes and suffixes containing just color codes would break hex colors

Added new examples to the config and defaultconfig files
This commit is contained in:
Aust1n46 2020-07-30 17:40:03 -05:00
parent 664c71bb86
commit f072821244
4 changed files with 66 additions and 58 deletions

View File

@ -294,7 +294,22 @@ enable_factions_channel: false
# Use '' or "" around format, example: '[&2global&f] {vault_prefix} {player_displayname}&2:'
# You must have prefixes and suffixes set in a Vault compatible permissions plugin to avoid errors
# Use "" as the prefix or suffix to have none
#Set chatcolor to 'None' to have a group based chat color! Don't forget to put a suffix or other placeholder at the end of the format!
channels:
GroupChatColorExample:
color: '#706C1E'
chatcolor: 'None'
mutable: true
filter: true
autojoin: true
default: false
distance: 0
cooldown: 0
bungeecord: false
alias: ge
permissions: None
format: '&f[#706C1EGroupColorChat&f] {vault_prefix} {player_displayname}#706C1E:{vault_suffix}'
HexExample:
color: '#ff0000'
chatcolor: '#ff0000'
@ -307,7 +322,20 @@ channels:
bungeecord: false
alias: he
permissions: None
format: '&f[&x&f&f&0&0&0&0Hex&f] {vault_prefix} {player_displayname}&x&f&f&0&0&0&0:'
format: '&f[#ff0000Hex&f] {vault_prefix} {player_displayname}#ff0000:'
BungeeExample:
color: gold
chatcolor: gold
mutable: true
filter: true
autojoin: true
default: false
distance: 0
cooldown: 3
bungeecord: true
alias: be
permissions: None
format: '&f[&6Network&f] {vault_prefix} {player_displayname}&6:'
Global:
color: dark_green
chatcolor: dark_green
@ -334,19 +362,6 @@ channels:
alias: st
permissions: staffchannel
format: '&f[&aStaff&f] {vault_prefix} {player_displayname}&a:'
Admin:
color: red
chatcolor: red
mutable: false
filter: false
autojoin: true
default: false
distance: 0
cooldown: 0
bungeecord: false
alias: a
permissions: adminchannel
format: '&f[&cAdmin&f] {vault_prefix} {player_displayname}&c:'
Donator:
color: light_purple
chatcolor: light_purple
@ -398,17 +413,4 @@ channels:
bungeecord: false
alias: l
permissions: None
format: '&f[&eLocal&f] {vault_prefix} {player_displayname}&e:'
Network:
color: gold
chatcolor: gold
mutable: true
filter: true
autojoin: true
default: false
distance: 0
cooldown: 60
bungeecord: true
alias: n
permissions: None
format: '&f[&6Network&f] {vault_prefix} {player_displayname}&6:'
format: '&f[&eLocal&f] {vault_prefix} {player_displayname}&e:'

View File

@ -46,6 +46,8 @@ nicknames:
nickname-in-tablist: true
# {player} : player sending command
# {command} : command typed
commandspy:
format: '&6{player}: {command}'
worldeditcommands: true
@ -292,7 +294,22 @@ enable_factions_channel: false
# Use '' or "" around format, example: '[&2global&f] {vault_prefix} {player_displayname}&2:'
# You must have prefixes and suffixes set in a Vault compatible permissions plugin to avoid errors
# Use "" as the prefix or suffix to have none
#Set chatcolor to 'None' to have a group based chat color! Don't forget to put a suffix or other placeholder at the end of the format!
channels:
GroupChatColorExample:
color: '#706C1E'
chatcolor: 'None'
mutable: true
filter: true
autojoin: true
default: false
distance: 0
cooldown: 0
bungeecord: false
alias: ge
permissions: None
format: '&f[#706C1EGroupColorChat&f] {vault_prefix} {player_displayname}#706C1E:{vault_suffix}'
HexExample:
color: '#ff0000'
chatcolor: '#ff0000'
@ -305,7 +322,20 @@ channels:
bungeecord: false
alias: he
permissions: None
format: '&f[&x&f&f&0&0&0&0Hex&f] {vault_prefix} {player_displayname}&x&f&f&0&0&0&0:'
format: '&f[#ff0000Hex&f] {vault_prefix} {player_displayname}#ff0000:'
BungeeExample:
color: gold
chatcolor: gold
mutable: true
filter: true
autojoin: true
default: false
distance: 0
cooldown: 3
bungeecord: true
alias: be
permissions: None
format: '&f[&6Network&f] {vault_prefix} {player_displayname}&6:'
Global:
color: dark_green
chatcolor: dark_green
@ -332,19 +362,6 @@ channels:
alias: st
permissions: staffchannel
format: '&f[&aStaff&f] {vault_prefix} {player_displayname}&a:'
Admin:
color: red
chatcolor: red
mutable: false
filter: false
autojoin: true
default: false
distance: 0
cooldown: 0
bungeecord: false
alias: a
permissions: adminchannel
format: '&f[&cAdmin&f] {vault_prefix} {player_displayname}&c:'
Donator:
color: light_purple
chatcolor: light_purple
@ -396,17 +413,4 @@ channels:
bungeecord: false
alias: l
permissions: None
format: '&f[&eLocal&f] {vault_prefix} {player_displayname}&e:'
Network:
color: gold
chatcolor: gold
mutable: true
filter: true
autojoin: true
default: false
distance: 0
cooldown: 60
bungeecord: true
alias: n
permissions: None
format: '&f[&6Network&f] {vault_prefix} {player_displayname}&6:'
format: '&f[&eLocal&f] {vault_prefix} {player_displayname}&e:'

View File

@ -464,6 +464,7 @@ public class ChatListener implements Listener {
String globalJSON = Format.convertToJson(mcp, format, chat);
String consoleChat = format + chat;
System.out.println(consoleChat);
String message = consoleChat.replaceAll("(§([a-z0-9]))", "");
int hash = message.hashCode();

View File

@ -43,10 +43,11 @@ public class Format {
try {
prefix = FormatStringAll(MineverseChat.chat.getPlayerPrefix(sender.getPlayer()));
suffix = FormatStringAll(MineverseChat.chat.getPlayerSuffix(sender.getPlayer()));
if(suffix.equals("")) {
//Don't apply JSON if the prefix or suffix is just a color code
if(suffix.isEmpty() || (suffix.length() == 2 && suffix.substring(1).matches("[0-9a-fA-F"))) {
suffix = "venturechat_no_suffix_code";
}
if(prefix.equals("")) {
if(prefix.isEmpty() || (prefix.length() == 2 && prefix.substring(1).matches("[0-9a-fA-F"))) {
prefix = "venturechat_no_prefix_code";
}
}