Add new 1.8 chat features

This commit is contained in:
BlackHole 2015-01-08 00:59:23 +01:00 committed by Thinkofdeath
parent e556fd7150
commit fa3678bcdd
4 changed files with 23 additions and 2 deletions

View File

@ -48,6 +48,12 @@ public abstract class BaseComponent
* obfuscated * obfuscated
*/ */
private Boolean obfuscated; private Boolean obfuscated;
/**
* The text to insert into the chat when this component (and child
* components) are clicked while pressing the shift key
*/
@Getter
private String insertion;
/** /**
* Appended components that inherit this component's formatting and events * Appended components that inherit this component's formatting and events
@ -76,6 +82,7 @@ public abstract class BaseComponent
setUnderlined( old.isUnderlinedRaw() ); setUnderlined( old.isUnderlinedRaw() );
setStrikethrough( old.isStrikethroughRaw() ); setStrikethrough( old.isStrikethroughRaw() );
setObfuscated( old.isObfuscatedRaw() ); setObfuscated( old.isObfuscatedRaw() );
setInsertion( old.getInsertion() );
setClickEvent( old.getClickEvent() ); setClickEvent( old.getClickEvent() );
setHoverEvent( old.getHoverEvent() ); setHoverEvent( old.getHoverEvent() );
if ( old.getExtra() != null ) if ( old.getExtra() != null )

View File

@ -45,6 +45,11 @@ public final class ClickEvent
* {@link net.md_5.bungee.api.chat.ClickEvent#value} into the players * {@link net.md_5.bungee.api.chat.ClickEvent#value} into the players
* text box * text box
*/ */
SUGGEST_COMMAND SUGGEST_COMMAND,
/**
* Change to the page number given by
* {@link net.md_5.bungee.api.chat.ClickEvent#value} in a book
*/
CHANGE_PAGE
} }
} }

View File

@ -18,6 +18,7 @@ final public class HoverEvent
SHOW_TEXT, SHOW_TEXT,
SHOW_ACHIEVEMENT, SHOW_ACHIEVEMENT,
SHOW_ITEM SHOW_ITEM,
SHOW_ENTITY
} }
} }

View File

@ -41,6 +41,10 @@ public class BaseComponentSerializer
{ {
component.setObfuscated( object.get( "obfuscated" ).getAsBoolean() ); component.setObfuscated( object.get( "obfuscated" ).getAsBoolean() );
} }
if ( object.has( "insertion" ) )
{
component.setInsertion( object.get( "insertion" ).getAsString() );
}
if ( object.has( "extra" ) ) if ( object.has( "extra" ) )
{ {
component.setExtra( Arrays.<BaseComponent>asList( context.<BaseComponent[]>deserialize( object.get( "extra" ), BaseComponent[].class ) ) ); component.setExtra( Arrays.<BaseComponent>asList( context.<BaseComponent[]>deserialize( object.get( "extra" ), BaseComponent[].class ) ) );
@ -108,6 +112,10 @@ public class BaseComponentSerializer
{ {
object.addProperty( "obfuscated", component.isObfuscatedRaw() ); object.addProperty( "obfuscated", component.isObfuscatedRaw() );
} }
if ( component.getInsertion() != null )
{
object.addProperty( "insertion", component.getInsertion() );
}
if ( component.getExtra() != null ) if ( component.getExtra() != null )
{ {