Jump to content

[1.16.5] '\n' formating key unkown in String


bibouche_

Recommended Posts

Hey, umm, I created a new Menu, in which I ping to a server to get it's Motd, However, I have a '\n' to continue on a new line, but Minecraft displays it as an unknown character and put it on the same line.

The Motd in server.properties is 

         \u00A7ka\u00A7r \u00A73\u00A7nAlcanderia\u00A7r \u00A76Modded \u00A74Survival\u00A7r \u00A7ka\u00A7r\n                    \u00A76[\u00A721.\u00A7416\u00A7r.5\u00A76]

And in the code I get is as a TranslationTextComponent, and then display it with Screen#drawCenteredString()

 

How can I get it to continue on a new line with the '\n' ?

Link to comment
Share on other sites

if (!this.server.pinged) {
			this.server.pinged         = true;
			this.server.pingToServer   = -2L;
			this.server.serverMOTD     = new TranslationTextComponent("");
			this.server.populationInfo = new TranslationTextComponent("");
			EXECUTOR.submit(() -> {
				try {
					CustomMenu.this.serverPinger.ping(CustomMenu.this.server, () -> { });
				}
				catch (UnknownHostException unknownHostException) {
					CustomMenu.this.server.pingToServer = -1L;
					CustomMenu.this.server.serverMOTD   = new TranslationTextComponent(TextFormatting.DARK_RED + "Cannot resolve host's name");
				}
				catch (Exception exception) {
					CustomMenu.this.server.pingToServer = -1L;
					CustomMenu.this.server.serverMOTD   = new TranslationTextComponent(TextFormatting.DARK_RED + "Unable to connect to server");
				}
			});
		}
		
		if (this.server.pingToServer >= 1L) {
			drawCenteredString(matrixStack, this.font, this.server.serverMOTD, this.width / 2, (int) (this.height / 2 * 1.5) - 52, 14474460);
			drawString(matrixStack, this.font, TextFormatting.GOLD + this.server.populationInfo.getString() + TextFormatting.RESET + " " + new TranslationTextComponent("alcamenu.players").getString(), this.width / 2 - 65, (int) (this.height / 2 * 1.5) - 27, 14474460);
			drawString(matrixStack, this.font, TextFormatting.GOLD + String.valueOf(this.server.pingToServer) + TextFormatting.RESET + " ms", this.width / 2 + 30, (int) (this.height / 2 * 1.5) - 27, 14474460);
		}
		else {
			drawCenteredString(matrixStack, this.font, this.server.serverMOTD, this.width / 2, (int) (this.height / 2 * 1.5) - 52, 0x245791);
		}

 

Link to comment
Share on other sites

We are not getting any credentials at all, they can join with just a pseudo, and a login on the server (with AuthMePlugin), so that the password they enter is just for their profile on our server, we respect privacy and so they will not enter their credentials into the launcher. It's goal is just to verify for the mods and launch a minecraft instance

Edited by bibouche_
Link to comment
Share on other sites

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.