@@ -0,0 +1,31 @@
|
|||||||
|
package skybot.controller.task;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
|
||||||
|
/** Runs a Minecraft command (e.g. "/help"), the same as typing it in chat. */
|
||||||
|
public class RunCommandTask implements Task {
|
||||||
|
private final String command;
|
||||||
|
private boolean ran = false;
|
||||||
|
|
||||||
|
public RunCommandTask(String command) {
|
||||||
|
this.command = command.startsWith("/") ? command.substring(1) : command;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
if (client.player != null) {
|
||||||
|
client.player.networkHandler.sendChatCommand(command);
|
||||||
|
}
|
||||||
|
ran = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDone() {
|
||||||
|
return ran;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user