#2905: HoverEvent getValue compat method
This commit is contained in:
parent
94c4fcbad7
commit
0af4bfdbdf
@ -13,6 +13,7 @@ import net.md_5.bungee.api.chat.hover.content.Content;
|
|||||||
import net.md_5.bungee.api.chat.hover.content.Entity;
|
import net.md_5.bungee.api.chat.hover.content.Entity;
|
||||||
import net.md_5.bungee.api.chat.hover.content.Item;
|
import net.md_5.bungee.api.chat.hover.content.Item;
|
||||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||||
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@ -70,6 +71,22 @@ public final class HoverEvent
|
|||||||
this.legacy = true;
|
this.legacy = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public BaseComponent[] getValue()
|
||||||
|
{
|
||||||
|
Content content = contents.get( 0 );
|
||||||
|
if ( content instanceof Text && ( (Text) content ).getValue() instanceof BaseComponent[] )
|
||||||
|
{
|
||||||
|
return (BaseComponent[]) ( (Text) content ).getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
TextComponent component = new TextComponent( ComponentSerializer.toString( content ) );
|
||||||
|
return new BaseComponent[]
|
||||||
|
{
|
||||||
|
component
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a content to this hover event.
|
* Adds a content to this hover event.
|
||||||
*
|
*
|
||||||
|
@ -59,6 +59,11 @@ public class ComponentSerializer implements JsonDeserializer<BaseComponent>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String toString(Object object)
|
||||||
|
{
|
||||||
|
return gson.toJson( object );
|
||||||
|
}
|
||||||
|
|
||||||
public static String toString(BaseComponent component)
|
public static String toString(BaseComponent component)
|
||||||
{
|
{
|
||||||
return gson.toJson( component );
|
return gson.toJson( component );
|
||||||
|
Loading…
Reference in New Issue
Block a user