diff --git a/api/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java b/api/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java index f004a3303..c94299f5b 100644 --- a/api/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java +++ b/api/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java @@ -277,7 +277,8 @@ public abstract class BaseComponent { return color != null || bold != null || italic != null || underlined != null || - strikethrough != null || obfuscated != null; + strikethrough != null || obfuscated != null || + hoverEvent != null || clickEvent != null; } public String toPlainText() @@ -320,6 +321,6 @@ public abstract class BaseComponent @Override public String toString() { - return String.format( "BaseComponent{color=%s, bold=%b, italic=%b, underlined=%b, strikethrough=%b, obfuscated=%b}", getColor().getName(), isBold(), isItalic(), isUnderlined(), isStrikethrough(), isObfuscated() ); + return String.format( "BaseComponent{color=%s, bold=%b, italic=%b, underlined=%b, strikethrough=%b, obfuscated=%b, clickEvent=%s, hoverEvent=%s}", getColor().getName(), isBold(), isItalic(), isUnderlined(), isStrikethrough(), isObfuscated(), getClickEvent(), getHoverEvent() ); } } diff --git a/api/src/main/java/net/md_5/bungee/api/chat/ClickEvent.java b/api/src/main/java/net/md_5/bungee/api/chat/ClickEvent.java index 3d0dd90b9..e412b23c4 100644 --- a/api/src/main/java/net/md_5/bungee/api/chat/ClickEvent.java +++ b/api/src/main/java/net/md_5/bungee/api/chat/ClickEvent.java @@ -22,4 +22,9 @@ public class ClickEvent RUN_COMMAND, SUGGEST_COMMAND } + + @Override + public String toString() { + return String.format( "ClickEvent{action=%s, value=%s}", action, value ); + } } diff --git a/api/src/main/java/net/md_5/bungee/api/chat/HoverEvent.java b/api/src/main/java/net/md_5/bungee/api/chat/HoverEvent.java index 8252a9546..125eaede4 100644 --- a/api/src/main/java/net/md_5/bungee/api/chat/HoverEvent.java +++ b/api/src/main/java/net/md_5/bungee/api/chat/HoverEvent.java @@ -42,4 +42,9 @@ public class HoverEvent SHOW_ACHIEVEMENT, SHOW_ITEM } + + @Override + public String toString() { + return String.format( "HoverEvent{action=%s, value=%s}", action, value ); + } } diff --git a/proxy/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java b/proxy/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java index f8d436ce1..626895706 100644 --- a/proxy/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java +++ b/proxy/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java @@ -41,7 +41,7 @@ public class BaseComponentSerializer } if ( object.has( "extra" ) ) { - component.setExtra( Arrays.asList( (BaseComponent[]) context.deserialize( object.get( "extra" ), BaseComponent[].class ) ) ); + component.setExtra( Arrays.asList( context.deserialize( object.get( "extra" ), BaseComponent[].class ) ) ); } //Events @@ -57,14 +57,8 @@ public class BaseComponentSerializer JsonObject event = object.getAsJsonObject( "hoverEvent" ); HoverEvent hoverEvent = new HoverEvent(); hoverEvent.setAction( HoverEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase() ) ); - Object res = context.deserialize( event.get( "value" ), BaseComponent.class ); - if ( res instanceof String ) - { - hoverEvent.setValue( (String) res ); - } else - { - hoverEvent.setValue( (BaseComponent) res ); - } + BaseComponent res = context.deserialize( event.get( "value" ), BaseComponent.class ); + hoverEvent.setValue( res ); component.setHoverEvent( hoverEvent ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandAlertRaw.java b/proxy/src/main/java/net/md_5/bungee/command/CommandAlertRaw.java index 5467d73ae..6e5ab23f3 100644 --- a/proxy/src/main/java/net/md_5/bungee/command/CommandAlertRaw.java +++ b/proxy/src/main/java/net/md_5/bungee/command/CommandAlertRaw.java @@ -9,6 +9,8 @@ import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.chat.ComponentSerializer; +import java.util.Arrays; + public class CommandAlertRaw extends Command { @@ -27,9 +29,11 @@ public class CommandAlertRaw extends Command { String message = Joiner.on(' ').join( args ); - try { + try + { ProxyServer.getInstance().broadcast( ComponentSerializer.parse( message ) ); - } catch ( Exception e ) { + } catch ( Exception e ) + { TextComponent error = new TextComponent( "An error occurred while parsing your message. (Hover for details)" ); error.setColor( ChatColor.RED ); error.setUnderlined( true );