use of net.minecraftforge.client.event.ClientChatReceivedEvent in project ct.js by ChatTriggers.
the class OnChatTrigger method trigger.
/**
* Argument 1 (String) The chat message received
* Argument 2 (ClientChatReceivedEvent) the chat event fired
* @param args list of arguments as described
*/
@Override
public void trigger(Object... args) {
if (!(args[0] instanceof String) || !(args[1] instanceof ClientChatReceivedEvent))
throw new IllegalArgumentException("Argument 1 must be a String, Argument 2 must be a ClientChatReceivedEvent");
ClientChatReceivedEvent chatEvent = (ClientChatReceivedEvent) args[1];
if (!this.triggerIfCanceled && chatEvent.isCanceled())
return;
String chatMessage = getChatMessage(chatEvent, (String) args[0]);
List<Object> variables = getVariables(chatMessage);
if (variables == null)
return;
variables.add(chatEvent);
recordBreadcrumb(chatMessage);
try {
CTJS.getInstance().getModuleManager().invokeFunction(methodName, variables.toArray(new Object[variables.size()]));
} catch (ScriptException | NoSuchMethodException e) {
Console.getConsole().printStackTrace(e, this);
TriggerType.CHAT.removeTrigger(this);
}
}
Aggregations