On my journey to create a floating text particle plugin, I noticed that you can set title and text with setTitle and setText methods, but I'm trying set multiple lines (more than 2 basically). I assumed "\n" would break the line, but it doesn't break or add another line when using setText. So, my question is, how can this be achieved?
If you've already spawned the floating text, and then try using setText, you'll have to use level->addparticle again with the update object for it to show up.
First of all, I save the particle data within a JSON file. Code: { "test-particle": { "pos": [ 299.3842, 100.91329999999999, -82.5187, "world" ], "title": "\u00a7l\u00a7eTest", "text": "\u00a77It is supposed to break here\nbut it does not", } } Then, I create the floating text particle and save it into an array using the loadConfiguration method Code: private function loadConfigurations() { if(file_exists($this->plugin->getDataFolder() . "particle.json")) { $particleConfig = new Config($this->plugin->getDataFolder() . "particle.json", Config::JSON); foreach($particleConfig->getAll() as $k => $v) { $level = $this->server->getLevelByName($v["pos"][3]); $position = new Position($v["pos"][0], $v["pos"][1], $v["pos"][2], $level); $levelName = $v["pos"][3]; $this->particle[$levelName][$k] = new FloatingTextParticle($position, $v["text"], $v["title"]); } } } Then, when the player actually views the particle it shows "\n" as string and doesn't break the line. It could be due to the json format? I'm not really sure.
It definitely is odd. I tried the double slash, but still nothing. I even changed the format to YAML, it doesn't break it either. Code: YAML format --- default-tag: pos: - 321 - 101 - -83 - world title: title-example text: Floating Text \nUmmmm no ...
Not 100% sure with this but try searching the string and replacing it with PHP_EOL Edit: replacing the "\n" with PHP_EOL
That's YAML for you! Code: text: line1\nline2 will render as Code: line1\nline2 ---- Code: text: "line1\nline2" will render as Code: line1 line2