forked from RepoMirrors/kami-blue
add say command
This commit is contained in:
parent
60380f2f98
commit
a58b92f5c0
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue