From c29676e4fc8a109c0466b6cd6f30d96f19ab34f9 Mon Sep 17 00:00:00 2001 From: Jonas Konrad Date: Sat, 15 Mar 2014 19:56:19 +0100 Subject: [PATCH 1/2] Fix NPE when converting invalid color character from legacy text --- api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java b/api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java index 529ea2bbe..c4dbb640b 100644 --- a/api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java +++ b/api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java @@ -42,6 +42,8 @@ public class TextComponent extends BaseComponent { i++; c = message.charAt( i ); + ChatColor format = ChatColor.getByChar( c ); + if ( format == null ) continue; if ( c >= 'A' && c <= 'Z' ) { c += 32; @@ -54,7 +56,6 @@ public class TextComponent extends BaseComponent builder = new StringBuilder(); components.add( old ); } - ChatColor format = ChatColor.getByChar( c ); switch ( format ) { case BOLD: From 5ae2e24c8467568578574cfe3888a362cd9ec0b4 Mon Sep 17 00:00:00 2001 From: Jonas Konrad Date: Sat, 15 Mar 2014 20:19:48 +0100 Subject: [PATCH 2/2] Fix uppercase color codes --- api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java b/api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java index c4dbb640b..393394eef 100644 --- a/api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java +++ b/api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java @@ -42,12 +42,12 @@ public class TextComponent extends BaseComponent { i++; c = message.charAt( i ); - ChatColor format = ChatColor.getByChar( c ); - if ( format == null ) continue; if ( c >= 'A' && c <= 'Z' ) { c += 32; } + ChatColor format = ChatColor.getByChar( c ); + if ( format == null ) continue; if ( builder.length() > 0 ) { TextComponent old = component;