Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spigot 1.7.10 - \n cartridge return? #70

Open
CyberSecGuy opened this issue May 14, 2016 · 2 comments
Open

Spigot 1.7.10 - \n cartridge return? #70

CyberSecGuy opened this issue May 14, 2016 · 2 comments

Comments

@CyberSecGuy
Copy link

CyberSecGuy commented May 14, 2016

Hi! I love Fanciful, and currently use it in a plugin of mine.

I'm using the following code to run a multi-lined reply, while keeping them all wrapped as 1 long line.

public FancyMessage linkNMS(Player player, String platform) {
    String line1 = ChatColor.STRIKETHROUGH + "                     " + ChatColor.RESET + " " + Main.Tag + ChatColor.RESET + " " + ChatColor.STRIKETHROUGH + "                     ";
    String line2 = "+ " + ChatColor.BLUE + "Update your URL using the command:";
    String line3 = "+ " + ChatColor.GREEN + "/yt " + ChatColor.RED + platform + ChatColor.GOLD + " <your link> " + ChatColor.AQUA + "[Click Me!]";
    String lb = "\n";
    String cmd = "";
    String tooltip = "";

    if (Main.Strummer.containsKey(player.getName())) {
        Streamer strum = Main.Strummer.get(player.getName());

        if (platform.equals("youtube")) {
            tooltip = "Current Link: " + strum.youtube;
            cmd = "/yt " + platform + " http://www.youtube.com/";
        }

        if (platform.equals("twitch")) {
            tooltip = "Current Link: " + strum.twitch;
            cmd = "/yt " + platform + " http://www.twitch.tv/";
        }

        if (platform.equals("twitter")) {
            tooltip = "Current Link: " + strum.twitter;
            cmd = "/yt " + platform + " http://www.twitter.com/";
        }
    }

    return new FancyMessage(line1).suggest(cmd).tooltip(tooltip).then(lb).then(line2).suggest(cmd).tooltip(tooltip).then(lb).then(line3).suggest(cmd).tooltip(tooltip);
}

In spigot 1.9.4 - the \n works perfectly fine as a line-break option, however when trying to support a 1.7.10 server, it prints a cartridge return. As seen below:

1.7.10 - http://i.imgur.com/shPUcNt.png
1.9.4 - http://i.imgur.com/vWwkRB9.png

These are from the exact same Jar file on both servers.
Additionally to test if it is 1.7.10 Spigot I ran the following command as a debug

if (args[0].equals("fancy")) {
    Bukkit.getServer().broadcastMessage("This is a test \nAnother test?" + '\n' + "Cookies");                       
}

and it works just fine.

I'd rather not send back multiple fanciful messages, as it's pretty cool to have 1 big block that's clickable anywhere on the text, acting as 1 fanciful message, so my questions are the following:

Is there a better way to do this?
Is there a built in line-break option for Fanciful API?
Any idea why I'm getting a cartridge return on 1.7.10 but not 1.9.4?

@mkremins
Copy link
Owner

That's odd. Using \n is the canonical "right way" to insert linebreaks into the message text; I have no idea why it's behaving differently on two different Spigot versions.

Could you send me the JSON string of the FancyMessage on both Spigot versions? You can use FancyMessage.toJSONString() to get the JSON string and then print the result to the console.

@Sir-Will
Copy link

Sir-Will commented Sep 8, 2017

Same issue here, even /tellraw SirWill {"text":"test\n123"} causes this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants