use of dev.hypnotic.event.events.EventSendPacket 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