Add an onSendChatMessage event

This commit is contained in:
Brady
2018-08-01 18:46:51 -07:00
parent 28c4636857
commit a36b223aab
6 changed files with 100 additions and 13 deletions

View File

@@ -1,14 +1,13 @@
package baritone.launch.mixins;
import baritone.util.ChatCommand;
import baritone.bot.Baritone;
import baritone.bot.event.events.ChatEvent;
import net.minecraft.client.entity.EntityPlayerSP;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.lang.reflect.InvocationTargetException;
/**
* @author Brady
* @since 8/1/2018 5:06 PM
@@ -22,11 +21,9 @@ public class MixinEntityPlayerSP {
cancellable = true
)
private void sendChatMessage(String msg, CallbackInfo ci) {
try {
if (ChatCommand.message(msg))
ci.cancel();
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
ChatEvent event = new ChatEvent(msg);
Baritone.INSTANCE.getGameEventHandler().onSendChatMessage(event);
if (event.isCancelled())
ci.cancel();
}
}