diff options
author | Florian Rinke <develop@torui.de> | 2021-09-22 22:50:20 +0200 |
---|---|---|
committer | Florian Rinke <develop@torui.de> | 2021-09-22 22:50:20 +0200 |
commit | e5e0c9a3a4fd9b2c10464e0f129bcb60b2db0f19 (patch) | |
tree | 139bc2d1228387720672749a7adbaacc81558f08 /src/main/java/de/torui/coflsky/CoflSkyCommand.java | |
parent | de2ef874edada810845cf902402337cd8809dd12 (diff) | |
download | COFL-e5e0c9a3a4fd9b2c10464e0f129bcb60b2db0f19.tar.gz COFL-e5e0c9a3a4fd9b2c10464e0f129bcb60b2db0f19.tar.bz2 COFL-e5e0c9a3a4fd9b2c10464e0f129bcb60b2db0f19.zip |
.
Diffstat (limited to 'src/main/java/de/torui/coflsky/CoflSkyCommand.java')
-rw-r--r-- | src/main/java/de/torui/coflsky/CoflSkyCommand.java | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/main/java/de/torui/coflsky/CoflSkyCommand.java b/src/main/java/de/torui/coflsky/CoflSkyCommand.java index 77ac4d7..1a68cfc 100644 --- a/src/main/java/de/torui/coflsky/CoflSkyCommand.java +++ b/src/main/java/de/torui/coflsky/CoflSkyCommand.java @@ -1,5 +1,6 @@ package de.torui.coflsky; +import java.util.Arrays; import java.util.List; import de.torui.coflsky.core.Command; @@ -8,10 +9,10 @@ import net.minecraft.client.Minecraft; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; -import scala.actors.threadpool.Arrays; public class CoflSkyCommand extends CommandBase { @@ -24,41 +25,59 @@ public class CoflSkyCommand extends CommandBase { @Override public String getCommandName() { - return "coflsky"; + return "cofl"; } @Override public String getCommandUsage(ICommandSender sender) { - return "/coflsky token <token> to register\n/coflsky start to connect\n/coflsky stop to stop"; + return "/cofl token <token> to register\n/coflsky start to connect\n/coflsky stop to stop"; } @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { System.out.println(Arrays.toString(args)); - if(args.length == 1) { + if(args.length >= 1) { switch(args[0]) { case "start": //todo: start + CoflSky.Wrapper.start(); break; case "stop": + CoflSky.Wrapper.stop(); //todo: stop break; case "debug": - WSCommandHandler.HandleCommand(new Command(CommandType.Execute, "/say hewwo"), sender.getCommandSenderEntity()); - WSCommandHandler.HandleCommand(new Command(CommandType.WriteToChat, "{ \"text\": \"Clickable Texts are fun\", \"onClick\": \"/give @p minecraft:apple 1\"}"), sender.getCommandSenderEntity()); + //WSCommandHandler.HandleCommand(new Command(CommandType.Execute, "/say hewwo"), sender.getCommandSenderEntity()); + //WSCommandHandler.HandleCommand(new Command(CommandType.WriteToChat, "{ \"text\": \"Clickable Texts are fun\", \"onClick\": \"me Hello World\"}"), sender.getCommandSenderEntity()); break; case "callback": + CallbackCommand(args); break; default: sender.addChatMessage(new ChatComponentText("" + args[0] +"is not a valid subcommand!")); + System.out.println(args[0] +"is not a valid subcommand!"); return; } } - if(args.length == 2 && args[0].equals("token")) { + /*if(args.length == 2 && args[0].equals("token")) { //todo: send authorisation message - } + }*/ + + } + + public void CallbackCommand(String[] args) { + + String command = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); + 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)); + + System.out.println("Sent!"); + //}).start(); } |