diff options
author | Florian Rinke <develop@torui.de> | 2021-10-03 00:04:21 +0200 |
---|---|---|
committer | Florian Rinke <develop@torui.de> | 2021-10-03 00:04:21 +0200 |
commit | 3fe65d7aa4854f902ec0d6cd18917659873e6ab2 (patch) | |
tree | 53c895a597d5e4ca960acaf472fae220db4e2199 /src | |
parent | 95200b244614e946226828f1924f368add400332 (diff) | |
download | COFL-3fe65d7aa4854f902ec0d6cd18917659873e6ab2.tar.gz COFL-3fe65d7aa4854f902ec0d6cd18917659873e6ab2.tar.bz2 COFL-3fe65d7aa4854f902ec0d6cd18917659873e6ab2.zip |
everything is now json encoded
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/torui/coflsky/CoflSkyCommand.java | 9 | ||||
-rw-r--r-- | src/main/java/de/torui/coflsky/WSCommandHandler.java | 4 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/de/torui/coflsky/CoflSkyCommand.java b/src/main/java/de/torui/coflsky/CoflSkyCommand.java index 6b8ae07..0cee4cb 100644 --- a/src/main/java/de/torui/coflsky/CoflSkyCommand.java +++ b/src/main/java/de/torui/coflsky/CoflSkyCommand.java @@ -6,6 +6,7 @@ import java.util.List; import de.torui.coflsky.core.Command; import de.torui.coflsky.core.CommandType; import de.torui.coflsky.core.StringCommand; +import de.torui.coflsky.websocket.WSClient; import net.minecraft.client.Minecraft; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; @@ -75,7 +76,7 @@ public class CoflSkyCommand extends CommandBase { case "debug": // WSCommandHandler.HandleCommand(new Command(CommandType.Execute, "/me hewwo"), sender.getCommandSenderEntity()); // WSCommandHandler.HandleCommand(new Command(CommandType.WriteToChat, "{ \"text\": \"Clickable Texts are fun\", \"onClick\": \"me Hello World\"}"), sender.getCommandSenderEntity()); - WSCommandHandler.HandleCommand(new Command(CommandType.PlaySound, "random.explode"), sender.getCommandSenderEntity()); + WSCommandHandler.HandleCommand(new Command(CommandType.PlaySound, "\"minecraft:random.explode\""), sender.getCommandSenderEntity()); break; case "callback": CallbackCommand(args); @@ -108,7 +109,7 @@ public class CoflSkyCommand extends CommandBase { public void CommandNotRecognized(String[] args, ICommandSender sender) { String command = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); - StringCommand sc = new StringCommand(args[0], command); + StringCommand sc = new StringCommand(args[0], WSClient.gson.toJson(command)); if(CoflSky.Wrapper.isRunning) { CoflSky.Wrapper.SendMessage(sc); @@ -130,8 +131,8 @@ public class CoflSkyCommand extends CommandBase { System.out.println("CallbackData: " + command); //new Thread(()->{ System.out.println("Callback: " + command); - WSCommandHandler.HandleCommand(new Command(CommandType.Execute, command), Minecraft.getMinecraft().thePlayer); - CoflSky.Wrapper.SendMessage(new Command(CommandType.Clicked, command)); + WSCommandHandler.HandleCommand(new Command(CommandType.Execute, WSClient.gson.toJson(command)), Minecraft.getMinecraft().thePlayer); + CoflSky.Wrapper.SendMessage(new Command(CommandType.Clicked, WSClient.gson.toJson(command))); System.out.println("Sent!"); //}).start(); diff --git a/src/main/java/de/torui/coflsky/WSCommandHandler.java b/src/main/java/de/torui/coflsky/WSCommandHandler.java index 03dd686..b3cb1e4 100644 --- a/src/main/java/de/torui/coflsky/WSCommandHandler.java +++ b/src/main/java/de/torui/coflsky/WSCommandHandler.java @@ -50,7 +50,7 @@ public class WSCommandHandler { SoundHandler handler = Minecraft.getMinecraft().getSoundHandler(); //random.explode - PositionedSoundRecord psr = PositionedSoundRecord.create(new ResourceLocation(cmd.getData())); + PositionedSoundRecord psr = PositionedSoundRecord.create(new ResourceLocation(WSClient.gson.fromJson(cmd.getData(), String.class))); handler.playSound(psr); } @@ -59,7 +59,7 @@ public class WSCommandHandler { //Minecraft.getMinecraft().thePlayer.sendChatMessage(cmd.getData()); System.out.println("Execute: " + cmd.getData() + " sender:" + sender); - Minecraft.getMinecraft().thePlayer.sendChatMessage(cmd.getData()); + Minecraft.getMinecraft().thePlayer.sendChatMessage(WSClient.gson.fromJson(cmd.getData(), String.class)); //ICommandManager manager = MinecraftServer.getServer().getCommandManager(); //System.out.println("CommandManager: " + manager); |