Fix events not working when no formatting is used
This commit is contained in:
@@ -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.<BaseComponent>asList( context.<BaseComponent[]>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 );
|
||||
}
|
||||
}
|
||||
|
@@ -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 );
|
||||
|
Reference in New Issue
Block a user