Fix events not working when no formatting is used
This commit is contained in:
parent
60e2e6bfa4
commit
0040955204
@ -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() );
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
|
Loading…
Reference in New Issue
Block a user