use of net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket in project BleachHack by BleachDrinker420.
the class BetterChat method onPacketSend.
@BleachSubscribe
public void onPacketSend(EventPacket.Send event) {
if (event.getPacket() instanceof ChatMessageC2SPacket) {
ChatMessageC2SPacket packet = (ChatMessageC2SPacket) event.getPacket();
String prefix = "";
String text = packet.getChatMessage();
if (text.startsWith("/r ") || text.startsWith("/reply ")) {
String[] split = text.split(" ");
prefix = split[0] + " ";
text = text.substring(prefix.length());
} else if (text.startsWith("/msg ") || text.startsWith("/tell ") || text.startsWith("/w ") || text.startsWith("/whisper ") || text.startsWith("/pm ")) {
String[] split = text.split(" ");
if (split.length >= 3) {
prefix = split[0] + " " + split[1] + " ";
text = text.substring(prefix.length());
}
} else if (text.startsWith("/") || text.startsWith("!")) {
return;
}
if (getSetting(0).asToggle().getState()) {
text = fonts.get(getSetting(0).asToggle().getChild(0).asMode().getMode()).replace(text);
}
if (getSetting(1).asToggle().getState()) {
text = this.prefix + text;
}
if (getSetting(2).asToggle().getState()) {
text = text + this.suffix;
}
if (getSetting(5).asToggle().getState()) {
String key = getRandomString(4);
text = encrypt(text, key) + "\u00ff" + key;
}
if (!text.equals(packet.getChatMessage())) {
packet.chatMessage = prefix + text;
}
}
}
use of net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket in project BleachHack by BleachDrinker420.
the class MixinClientConnection method send.
@Inject(method = "send(Lnet/minecraft/network/Packet;Lio/netty/util/concurrent/GenericFutureListener;)V", at = @At("HEAD"), cancellable = true)
private void send(Packet<?> packet, GenericFutureListener<? extends Future<? super Void>> packetCallback, CallbackInfo callback) {
if (packet instanceof ChatMessageC2SPacket) {
if (!CommandManager.allowNextMsg) {
ChatMessageC2SPacket pack = (ChatMessageC2SPacket) packet;
if (pack.getChatMessage().startsWith(Command.getPrefix())) {
CommandManager.callCommand(pack.getChatMessage().substring(Command.getPrefix().length()));
callback.cancel();
}
}
CommandManager.allowNextMsg = false;
}
EventPacket.Send event = new EventPacket.Send(packet);
BleachHack.eventBus.post(event);
if (event.isCancelled()) {
callback.cancel();
}
}
use of net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket in project KiwiClient by TangyKiwi.
the class FF method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
Utils.mc.getNetworkHandler().sendPacket(new ChatMessageC2SPacket("I'm gonna FF, gg go next."));
Utils.mc.player.networkHandler.getConnection().disconnect(new LiteralText("Literally just FFed."));
return SINGLE_SUCCESS;
});
}
use of net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket in project BleachHack by BleachDrinker420.
the class CmdSay method onCommand.
@Override
public void onCommand(String alias, String[] args) throws Exception {
CommandManager.allowNextMsg = true;
mc.player.networkHandler.sendPacket(new ChatMessageC2SPacket(String.join(" ", args)));
}
use of net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket in project Hypnotic-Client by Hypnotic-Development.
the class ClientConnectionMixin method send.
@Inject(method = "send(Lnet/minecraft/network/Packet;Lio/netty/util/concurrent/GenericFutureListener;)V", at = @At("HEAD"), cancellable = true)
public void send(Packet<?> packet, GenericFutureListener<? extends Future<? super Void>> callback, CallbackInfo ci) {
// Call commands if the prefix is sent
if (packet instanceof ChatMessageC2SPacket && ((ChatMessageC2SPacket) packet).getChatMessage().startsWith(CommandManager.INSTANCE.getPrefix())) {
try {
CommandManager.INSTANCE.dispatch(((ChatMessageC2SPacket) packet).getChatMessage().substring(CommandManager.INSTANCE.getPrefix().length()));
} catch (CommandSyntaxException e) {
e.printStackTrace();
ChatUtils.tellPlayer(e.getMessage());
}
ci.cancel();
}
EventSendPacket event = new EventSendPacket(packet);
event.call();
if (event.isCancelled())
ci.cancel();
}
Aggregations