add say command

This commit is contained in:
Bella 2020-03-12 18:11:26 -04:00
parent 60380f2f98
commit a58b92f5c0
No known key found for this signature in database
GPG Key ID: 03B01AC937D1C89C
2 changed files with 35 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import me.zeroeightsix.kami.setting.Settings;
import me.zeroeightsix.kami.util.Wrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.launchwrapper.LogWrapper;
import net.minecraft.network.play.client.CPacketChatMessage;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentBase;
@ -60,6 +61,14 @@ public abstract class Command {
}
}
public static void sendServerMessage(String message) {
if (isSendable()) {
Wrapper.getPlayer().connection.sendPacket(new CPacketChatMessage(message));
} else {
LogWrapper.warning("Could not send server message: \"" + message + "\"");
}
}
public static boolean isSendable() {
return Minecraft.getMinecraft().player != null;
}

View File

@ -0,0 +1,26 @@
package me.zeroeightsix.kami.command.commands;
import me.zeroeightsix.kami.command.Command;
import me.zeroeightsix.kami.command.syntax.ChunkBuilder;
/**
* @author S-B99
* Created by S-B99 on 12/03/20
*/
public class SayCommand extends Command {
public SayCommand() {
super("say", new ChunkBuilder().append("message").build());
setDescription("Allows you to send any message, even with a prefix in it");
}
@Override
public void call(String[] args) {
StringBuilder message = new StringBuilder();
for (String arg : args) {
if (arg != null) {
message.append(" ").append(arg);
}
}
Command.sendServerMessage(message.toString());
}
}