Java Code Examples for org.spongepowered.api.text.Text#EMPTY

The following examples show how to use org.spongepowered.api.text.Text#EMPTY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LineDrawingContext.java    From ChatUI with MIT License 6 votes vote down vote up
Text[] render() {
    int lastNonNull = 0;
    Text[] lines = new Text[this.lines.length];
    for (int i = 0; i < lines.length; i++) {
        Line line = this.lines[i];
        if (line == null) {
            lines[i] = Text.EMPTY;
            continue;
        }
        lastNonNull = i;
        lines[i] = line.toText();
    }
    if (lastNonNull < lines.length - 1) {
        Text[] newLines = new Text[lastNonNull + 1];
        System.arraycopy(lines, 0, newLines, 0, lastNonNull + 1);
        lines = newLines;
    }
    return lines;
}
 
Example 2
Source File: SpongeUtil.java    From GriefDefender with MIT License 5 votes vote down vote up
public static Text getSpongeText(Component component) {
    if (component == null) {
        return Text.EMPTY;
    }
    //return Text.of(LegacyComponentSerializer.legacy().serialize((Component) component, '&'));
    return TextSerializers.JSON.deserialize(GsonComponentSerializer.INSTANCE.serialize(component));
}
 
Example 3
Source File: LineDrawingContext.java    From ChatUI with MIT License 5 votes vote down vote up
public Text toText() {
    if (this.characters.isEmpty()) {
        return Text.EMPTY;
    }
    StringBuilder string = new StringBuilder();
    Text.Builder rootBuilder = Text.builder();
    PixelMetadata prevData = null;
    for (int i = 0; i <= this.currentMax; i++) {
        PixelMetadata data = this.metadata.get(i);
        char c = this.characters.get(i);
        if (data == null) {
            data = this.emptyData;
            c = this.emptyChar;
        }
        if (prevData == null) {
            prevData = data;
        }
        if (!prevData.equals(data)) {
            rootBuilder.append(prevData.toText(string.toString()));
            string = new StringBuilder();
            prevData = data;
        }
        string.append(c);
    }
    if (string.length() > 0 && prevData != null) {
        rootBuilder.append(prevData.toText(string.toString()));
    }
    return rootBuilder.build();
}
 
Example 4
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static Text getLoginMessage(String playerName)
{
	CommentedConfigurationNode node = Configs.getConfig(mainConfig).getNode("message", "login");
	String message;

	if (configManager.getString(node).isPresent())
	{
		message = node.getString();
	}
	else
	{
		setLoginMessage("");
		message = "";
	}

	if (message.isEmpty())
	{
		return Text.EMPTY;
	}

	message = message.replaceAll("@p", playerName);

	if ((message.contains("https://")) || (message.contains("http://")))
	{
		return Utils.getURL(message);
	}

	return TextSerializers.FORMATTING_CODE.deserialize(message);
}
 
Example 5
Source File: NationNameElement.java    From Nations with MIT License 4 votes vote down vote up
public Text getUsage(CommandSource src)
{
	return Text.EMPTY;
}
 
Example 6
Source File: WorldNameElement.java    From Nations with MIT License 4 votes vote down vote up
public Text getUsage(CommandSource src)
{
	return Text.EMPTY;
}
 
Example 7
Source File: CitizenNameElement.java    From Nations with MIT License 4 votes vote down vote up
public Text getUsage(CommandSource src)
{
	return Text.EMPTY;
}
 
Example 8
Source File: AccountOwnerElement.java    From Nations with MIT License 4 votes vote down vote up
public Text getUsage(CommandSource src)
{
	return Text.EMPTY;
}
 
Example 9
Source File: PlayerNameElement.java    From Nations with MIT License 4 votes vote down vote up
public Text getUsage(CommandSource src)
{
	return Text.EMPTY;
}