From fa3678bcdddb2ddbe19e27674498d84cf64270bc Mon Sep 17 00:00:00 2001 From: BlackHole Date: Thu, 8 Jan 2015 00:59:23 +0100 Subject: [PATCH] Add new 1.8 chat features --- .../main/java/net/md_5/bungee/api/chat/BaseComponent.java | 7 +++++++ .../main/java/net/md_5/bungee/api/chat/ClickEvent.java | 7 ++++++- .../main/java/net/md_5/bungee/api/chat/HoverEvent.java | 3 ++- .../net/md_5/bungee/chat/BaseComponentSerializer.java | 8 ++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/chat/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java b/chat/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java index 4ae1654d..cbb48b08 100644 --- a/chat/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java +++ b/chat/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java @@ -48,6 +48,12 @@ public abstract class BaseComponent * 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 @@ -76,6 +82,7 @@ public abstract class BaseComponent setUnderlined( old.isUnderlinedRaw() ); setStrikethrough( old.isStrikethroughRaw() ); setObfuscated( old.isObfuscatedRaw() ); + setInsertion( old.getInsertion() ); setClickEvent( old.getClickEvent() ); setHoverEvent( old.getHoverEvent() ); if ( old.getExtra() != null ) diff --git a/chat/src/main/java/net/md_5/bungee/api/chat/ClickEvent.java b/chat/src/main/java/net/md_5/bungee/api/chat/ClickEvent.java index 5de07519..1ced284f 100644 --- a/chat/src/main/java/net/md_5/bungee/api/chat/ClickEvent.java +++ b/chat/src/main/java/net/md_5/bungee/api/chat/ClickEvent.java @@ -45,6 +45,11 @@ public final class ClickEvent * {@link net.md_5.bungee.api.chat.ClickEvent#value} into the players * 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 } } diff --git a/chat/src/main/java/net/md_5/bungee/api/chat/HoverEvent.java b/chat/src/main/java/net/md_5/bungee/api/chat/HoverEvent.java index a8bfd789..1b76956a 100644 --- a/chat/src/main/java/net/md_5/bungee/api/chat/HoverEvent.java +++ b/chat/src/main/java/net/md_5/bungee/api/chat/HoverEvent.java @@ -18,6 +18,7 @@ final public class HoverEvent SHOW_TEXT, SHOW_ACHIEVEMENT, - SHOW_ITEM + SHOW_ITEM, + SHOW_ENTITY } } diff --git a/chat/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java b/chat/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java index cb1d24a2..9aed9c56 100644 --- a/chat/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java +++ b/chat/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java @@ -41,6 +41,10 @@ public class BaseComponentSerializer { component.setObfuscated( object.get( "obfuscated" ).getAsBoolean() ); } + if ( object.has( "insertion" ) ) + { + component.setInsertion( object.get( "insertion" ).getAsString() ); + } if ( object.has( "extra" ) ) { component.setExtra( Arrays.asList( context.deserialize( object.get( "extra" ), BaseComponent[].class ) ) ); @@ -108,6 +112,10 @@ public class BaseComponentSerializer { object.addProperty( "obfuscated", component.isObfuscatedRaw() ); } + if ( component.getInsertion() != null ) + { + object.addProperty( "insertion", component.getInsertion() ); + } if ( component.getExtra() != null ) {