This MCP code is not working? Why?

Pa
5

Have a code written that if you enter in the chat #help that then a message should come. But it always crashed then.

Code:

package en.Neotastical;

import net.minecraft.client.Minecraft;

import net.minecraft.util.IChatComponent;

public class hashtagHELP {

public static void showMessage (String message) {

Minecraft.getMinecraft (). ThePlayer.addChatMessage (IChatComponent.Serializer.jsonToComponent ("{\" text \ ": \" "+ message +));

}

public static void onCommand (String [] args) {

if (args [0] .equalsIgnoreCase ("# help"))

showMessage ( "Hi");

else

showMessage ( "Error");

}

}

Code from GuiChat:

if (s.length ()> 0)

{

if (s.startsWith ("#")) {

HashtagHELP.onCommand (s.split (""));

}

else

{

this.sendChatMessage (s);

}

this.mc.displayGuiScreen ((GuiScreen) null);

}

}

}

Error: In the next message

Pa

---- Minecraft Crash Report ----

// Do not do that.

Time: 21.09.19 12:39

Description: Updating screen events

com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Subtitled string at line 1 column 12

at com.google.gson.internal.Streams.parse (Streams.java:56)

at com.google.gson.TreeTypeAdapter.read (TreeTypeAdapter.java:54)

at com.google.gson.Gson.fromJson (Gson.java:803)

at com.google.gson.Gson.fromJson (Gson.java:768)

at com.google.gson.Gson.fromJson (Gson.java:717)

at com.google.gson.Gson.fromJson (Gson.java:689)

at net.minecraft.util.IChatComponent $ Serializer.jsonToComponent (IChatComponent.java:282)

at.enotastisch.HashtagHELP.showMessage (HashtagHELP.java:9)

at en.Neotastisch.HashtagHELP.onCommand (HashtagHELP.java:15)

at net.minecraft.client.gui.GuiChat.keyTyped (GuiChat.java:137)

at net.minecraft.client.gui.GuiScreen.handleKeyboardInput (GuiScreen.java:625)

at net.minecraft.client.gui.GuiScreen.handleInput (GuiScreen.java:576)

at net.minecraft.client.Minecraft.runTick (Minecraft.java:1772)

at net.minecraft.client.Minecraft.runGameLoop (Minecraft.java:1099)

at net.minecraft.client.Minecraft.run (Minecraft.java:418)

at net.minecraft.client.main.Main.main (Main.java:113)

at Start.main (Start.java:11)

Caused by: com.google.gson.stream.MalformedJsonException: Subtitled string at line 1 column 12

at com.google.gson.stream.JsonReader.syntaxError (JsonReader.java:1505)

at com.google.gson.stream.JsonReader.nextQuotedValue (JsonReader.java:1006)

at com.google.gson.stream.JsonReader.nextString (JsonReader.java:811)

at com.google.gson.internal.bind.TypeAdapters $ 25.read (TypeAdapters.java:646)

at com.google.gson.internal.bind.TypeAdapters $ 25.read (TypeAdapters.java:667)

at com.google.gson.internal.bind.TypeAdapters $ 25.read (TypeAdapters.java:642)

at com.google.gson.internal.Streams.parse (Streams.java:44)

… 16 more

A detailed walkthrough of the error, its code path and all known details is as follows:

-------------------------------------------------- -------------------------------------

- Head -

Stack trace:

at com.google.gson.internal.Streams.parse (Streams.java:56)

at com.google.gson.TreeTypeAdapter.read (TreeTypeAdapter.java:54)

at com.google.gson.Gson.fromJson (Gson.java:803)

at com.google.gson.Gson.fromJson (Gson.java:768)

at com.google.gson.Gson.fromJson (Gson.java:717)

at com.google.gson.Gson.fromJson (Gson.java:689)

at net.minecraft.util.IChatComponent $ Serializer.jsonToComponent (IChatComponent.java:282)

at.enotastisch.HashtagHELP.showMessage (HashtagHELP.java:9)

at en.Neotastisch.HashtagHELP.onCommand (HashtagHELP.java:15)

at net.minecraft.client.gui.GuiChat.keyTyped (GuiChat.java:137)

at net.minecraft.client.gui.GuiScreen.handleKeyboardInput (GuiScreen.java:625)

at net.minecraft.client.gui.GuiScreen.handleInput (GuiScreen.java:576)

- Affected screen -

details:

Screen name: net.minecraft.client.gui.GuiChat

- Affected level -

details:

Level name: MpServer

All players: 1 total; [EntityPlayerSP ['Player258' / 406, l = 'MpServer', x = 239.56, y = 64.00, z = 286.82]]

Chunk stats: MultiplayerChunkCache: 579, 579

Level seed: 0

Level generator: ID 00 - default, ver 1. Features enabled: false

Level generator options:

Level spawn location: 232,00,64,00,252.00 - World: (232,64,252), Chunk: (at 8,4,12 in 14,15; contains blocks 224,0,240 to 239,255,255), Region: (0, 0, contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

Level time: 4920 game time, 4920 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

Forced entities: 91 total; [EntityCow ['Cow' / 266, l = 'MpServer', x = 274.50, y = 67.00, z = 212.50], EntityCow ['Cow' / 267, l = 'MpServer', x = 272.50, y = 67.00, z = 213.50], EntityCow ['Cow' / 268, l = 'MpServer', x = 282.50, y = 67.00, z = 212.50], EntityCow ['Cow' / 269, l = 'MpServer', x = 283.97, y = 68.00, z = 212.88], EntityPig ['Pig' / 270, l = 'MpServer', x = 285 , 25, y = 68.00, z = 211.97], EntityCow ['Cow' / 271, l = 'MpServer', x = 280.50, y = 71.00, z = 295.50], EntityCow ['Cow' / 272, l = 'MpServer', x = 280.50, y = 71.00, z = 293.50], EntityCow ['Cow' / 273, l = 'MpServer', x = 288, 19, y = 71.00, z = 302.75], EntityCow ['Cow' / 274, l = 'MpServer', x = 287.69, y = 71.00, z = 298.13], EntityItem [ 'item.item.seeds' / 275, l = 'MpServer', x = 275.44, y = 71.00, z = 321.75], EntityBat ['Bat' / 149, l = 'MpServer', x = 177.50, y = 24.00, z = 369.44]

Dr

What's in line 9 and 15 of his HashtagHelp class?

Pa

Minecraft.getMinecraft (). ThePlayer.addChatMessage (IChatComponent.Serializer.jsonToComponent ("{\" text \ ": \" "+ message +)) so that I can send a message to the client at the client

showMessage ( "Hi"); triggers this variable

Dr

You have an opening curly bracket there. Does not this have to be closed?

Pa

Thanks!