UltraChat/src/me/ryandw11/ultrachat/api/MessageBuilder.java
Ryandw11 62df20ae69 Work on 2.5
- Implemented the API correctly.
 - Fixed hex color chatting.
 - New color gui system.
2020-06-25 19:13:07 -07:00

57 lines
1.3 KiB
Java

package me.ryandw11.ultrachat.api;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.ComponentBuilder.FormatRetention;
import net.md_5.bungee.api.chat.TextComponent;
/**
* Easy Builder to build several JSON sections into a single message.
* {@link JSONChatBuilder}
* @author Ryandw11
* @since 2.4
*
*/
public class MessageBuilder {
private ComponentBuilder component;
public MessageBuilder() {
component = new ComponentBuilder("");
}
/**
* Add a JSONChatBuilder to the message
* @param json the JSONChatBuilder to add
* @return The MessageBuilder to chain.
*/
public MessageBuilder addJSON(JSONChatBuilder json) {
component.append(json.build(), FormatRetention.NONE);
return this;
}
/**
* Add a string to the message
* @param s the string to add
* @return the builder to chain
*/
public MessageBuilder addString(String s) {
TextComponent tc = new TextComponent(s);
component.append(tc, FormatRetention.NONE);
return this;
}
/**
* Add a base component to the message
* @param bc the component to add
* @return The Buider to chain
*/
public MessageBuilder addBaseComponent(BaseComponent[] bc) {
component.append(bc, FormatRetention.NONE);
return this;
}
public BaseComponent[] build() {
return this.component.create();
}
}