Search in sources :

Example 1 with ChatFilterResult

use of me.xmrvizzy.skyblocker.chat.ChatFilterResult in project Skyblocker by LifeIsAParadox.

the class ChatHudListenerMixin method onMessage.

@Inject(method = "onChatMessage", at = @At("HEAD"), cancellable = true)
public void onMessage(MessageType messageType, Text message, UUID senderUuid, CallbackInfo ci) {
    if (!Utils.isOnSkyblock)
        return;
    String asString = message.getString();
    ChatFilterResult result = ChatMessageListener.EVENT.invoker().onMessage(message, asString);
    switch(result) {
        case ACTION_BAR:
            ClientPlayerEntity player = client.player;
            // Couldn't have received original message if client was null
            assert player != null;
            player.sendMessage(message, true);
        case FILTER:
            ci.cancel();
    }
}
Also used : ChatFilterResult(me.xmrvizzy.skyblocker.chat.ChatFilterResult) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

ChatFilterResult (me.xmrvizzy.skyblocker.chat.ChatFilterResult)1 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1