From 93ba9b3a3e3d00d6f2e7c4643c7c019df20c2b29 Mon Sep 17 00:00:00 2001 From: kosgan10 Date: Mon, 30 Dec 2013 15:36:35 +0200 Subject: [PATCH 1/5] Fix errors for console --- .../md_5/bungee/command/CommandAlertRaw.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) 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 0c9ac0e5..0ffb2d2c 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 @@ -1,16 +1,15 @@ package net.md_5.bungee.command; -import com.google.common.base.Joiner; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.chat.ComponentSerializer; -import java.util.Arrays; +import com.google.common.base.Joiner; public class CommandAlertRaw extends Command { @@ -35,12 +34,18 @@ public class CommandAlertRaw extends Command ProxyServer.getInstance().broadcast( ComponentSerializer.parse( message ) ); } catch ( Exception e ) { - sender.sendMessage( - new ComponentBuilder( "An error occurred while parsing your message. (Hover for details)" ). - color( ChatColor.RED ).underlined( true ). - event( new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new ComponentBuilder( e.getMessage() ).color( ChatColor.RED ).create() ) ). - create() ); + if ( sender instanceof ProxiedPlayer ) + { + sender.sendMessage( + new ComponentBuilder( "An error occurred while parsing your message. (Hover for details)" ). + color( ChatColor.RED ).underlined( true ). + event( new HoverEvent( HoverEvent.Action.SHOW_TEXT, + new ComponentBuilder( e.getMessage() ).color( ChatColor.RED ).create() ) ). + create() ); + } else + { + sender.sendMessage(ChatColor.RED + "An error occurred while parsing your message. " + e.getMessage()); + } } } } From d3159fe6caa0c6501b4e7c257daff7f5ea6ff9e2 Mon Sep 17 00:00:00 2001 From: kosgan10 Date: Mon, 30 Dec 2013 15:38:13 +0200 Subject: [PATCH 2/5] Fix imports --- .../main/java/net/md_5/bungee/command/CommandAlertRaw.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 0ffb2d2c..0ea55c2a 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 @@ -1,15 +1,17 @@ package net.md_5.bungee.command; +import com.google.common.base.Joiner; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.chat.ComponentSerializer; -import com.google.common.base.Joiner; +import java.util.Arrays; public class CommandAlertRaw extends Command { From 6c795a25ffa72a3974019937ef279774ee2b3ad0 Mon Sep 17 00:00:00 2001 From: kosgan10 Date: Mon, 30 Dec 2013 15:43:58 +0200 Subject: [PATCH 3/5] Change message to use ComponentBuilder --- .../src/main/java/net/md_5/bungee/command/CommandAlertRaw.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0ea55c2a..6e4028da 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 @@ -46,7 +46,7 @@ public class CommandAlertRaw extends Command create() ); } else { - sender.sendMessage(ChatColor.RED + "An error occurred while parsing your message. " + e.getMessage()); + sender.sendMessage(new ComponentBuilder( "An error occurred while parsing your message: " ).color( ChatColor.RED ).append( e.getMessage() ).create() ); } } } From f3766bc10bc735931413bba831f25ce282452deb Mon Sep 17 00:00:00 2001 From: kosgan10 Date: Mon, 30 Dec 2013 18:07:30 +0200 Subject: [PATCH 4/5] Fix hover messages for players --- .../java/net/md_5/bungee/command/CommandAlertRaw.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 6e4028da..18c610c1 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 @@ -1,17 +1,15 @@ package net.md_5.bungee.command; -import com.google.common.base.Joiner; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.chat.ComponentSerializer; -import java.util.Arrays; +import com.google.common.base.Joiner; public class CommandAlertRaw extends Command { @@ -36,13 +34,18 @@ public class CommandAlertRaw extends Command ProxyServer.getInstance().broadcast( ComponentSerializer.parse( message ) ); } catch ( Exception e ) { + Throwable error = e; + while ( error.getCause() != null ) + { + error = error.getCause(); + } if ( sender instanceof ProxiedPlayer ) { sender.sendMessage( new ComponentBuilder( "An error occurred while parsing your message. (Hover for details)" ). color( ChatColor.RED ).underlined( true ). event( new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new ComponentBuilder( e.getMessage() ).color( ChatColor.RED ).create() ) ). + new ComponentBuilder( error.getMessage() ).color( ChatColor.RED ).create() ) ). create() ); } else { From 5e57356e6af3aa5b50470edcde7f7ca175cb132d Mon Sep 17 00:00:00 2001 From: kosgan10 Date: Mon, 30 Dec 2013 18:10:39 +0200 Subject: [PATCH 5/5] Change Exception > Throwable --- .../src/main/java/net/md_5/bungee/command/CommandAlertRaw.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 18c610c1..f1c66936 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 @@ -49,7 +49,7 @@ public class CommandAlertRaw extends Command create() ); } else { - sender.sendMessage(new ComponentBuilder( "An error occurred while parsing your message: " ).color( ChatColor.RED ).append( e.getMessage() ).create() ); + sender.sendMessage(new ComponentBuilder( "An error occurred while parsing your message: " ).color( ChatColor.RED ).append( error.getMessage() ).create() ); } } }