@Override public TranslatableComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { TranslatableComponent component = new TranslatableComponent(); JsonObject object = json.getAsJsonObject(); deserialize( object, component, context ); component.setTranslate( object.get( "translate" ).getAsString() ); if ( object.has( "with" ) ) { component.setWith( Arrays.asList( (BaseComponent[]) context.deserialize( object.get( "with" ), BaseComponent[].class ) ) ); } return component; }
/** * Creates a translatable component with the passed substitutions * * @see #translate * @see #setWith(java.util.List) * @param translate the translation key * @param with the {@link java.lang.String}s and * {@link net.md_5.bungee.api.chat.BaseComponent}s to use into the * translation */ public TranslatableComponent(String translate, Object... with) { setTranslate( translate ); if ( with != null && with.length != 0 ) { List<BaseComponent> temp = new ArrayList<BaseComponent>(); for ( Object w : with ) { if ( w instanceof BaseComponent ) { temp.add( (BaseComponent) w ); } else { temp.add( new TextComponent( String.valueOf( w ) ) ); } } setWith( temp ); } }
/** * Creates a translatable component from the original to clone it. * * @param original the original for the new translatable component. */ public TranslatableComponent(TranslatableComponent original) { super( original ); setTranslate( original.getTranslate() ); if ( original.getWith() != null ) { List<BaseComponent> temp = new ArrayList<BaseComponent>(); for ( BaseComponent baseComponent : original.getWith() ) { temp.add( baseComponent.duplicate() ); } setWith( temp ); } }
@Override public TranslatableComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { TranslatableComponent component = new TranslatableComponent(); JsonObject object = json.getAsJsonObject(); deserialize( object, component, context ); component.setTranslate( object.get( "translate" ).getAsString() ); if ( object.has( "with" ) ) { component.setWith( Arrays.asList( (BaseComponent[]) context.deserialize( object.get( "with" ), BaseComponent[].class ) ) ); } return component; }
/** * Creates a translatable component with the passed substitutions * * @see #translate * @see #setWith(java.util.List) * @param translate the translation key * @param with the {@link java.lang.String}s and * {@link net.md_5.bungee.api.chat.BaseComponent}s to use into the * translation */ public TranslatableComponent(String translate, Object... with) { setTranslate( translate ); List<BaseComponent> temp = new ArrayList<BaseComponent>(); for ( Object w : with ) { if ( w instanceof String ) { temp.add( new TextComponent( (String) w ) ); } else { temp.add( (BaseComponent) w ); } } setWith( temp ); }
/** * Creates a translatable component from the original to clone it. * * @param original the original for the new translatable component. */ public TranslatableComponent(TranslatableComponent original) { super( original ); setTranslate( original.getTranslate() ); if ( original.getWith() != null ) { List<BaseComponent> temp = new ArrayList<BaseComponent>(); for ( BaseComponent baseComponent : original.getWith() ) { temp.add( baseComponent.duplicate() ); } setWith( temp ); } }