Events

ModuleTriggerEvent

com.kixmc.csapi.api.ModuleTriggerEvent
This event is fired by ChatSentry whenever any (supported) modules are triggered by a player. It is not cancellable. You can use the below methods to get related information to the event:
1
// get the violation/detection type
2
APIViolationType getType()
3
4
// get the context in which this event was triggered from (chat, command, etc)
5
APITriggerContext getContext()
6
7
// get the player who triggered this event
8
Player getPlayer()
9
10
// get the message before running through the module
11
String getOldContent()
12
13
// get the message after ran through the module
14
String getNewContent()
15
16
// get return the blocked content
17
String getBlockedContent()
Copied!

Violation types / supported modules

Any modules that have a violation/detection (APIViolationType) type associated with them are supported by this event. The below are valid detection types:
  • ON_COOLDOWN
  • LINK_OR_AD_BLOCK
  • MESSAGE_FILTER_BLOCK
  • WORD_REPLACER_REPLACE (legacy)
  • SPAM_BLOCK
  • UNICODE_CHARACTER_BLOCK
  • CAP_LIMITER_BLOCK
  • ANTI_PARROT_BLOCK
  • ANTI_CHAT_FLOOD_BLOCK
  • ANTI_STATUE_SPAMBOT_BLOCK
  • ANTI_JOIN_FLOOD_BLOCK
  • CHAT_MODIFIER_MODIFY (legacy)
  • CHAT_EXECUTOR_MATCH

Context types

Below are the valid APITriggerContext types:
  • CHAT
  • COMMAND
  • ANVIL
  • BOOK
  • SIGN
  • JOIN
  • OTHER (as of 4.2.0 this context is never used)

Code examples

For testing if everything is working properly
1
@EventHandler
2
public void onModuleTrigger(ModuleTriggerEvent e) {
3
Bukkit.broadcastMessage("Module trigger event fired! Details:");
4
Bukkit.broadcastMessage("Trigger player: " + e.getPlayer().getName());
5
Bukkit.broadcastMessage("Trigger type: " + e.getType().toString());
6
Bukkit.broadcastMessage("Trigger context: " + e.getContext());
7
Bukkit.broadcastMessage("Original msg: " + e.getOldContent());
8
Bukkit.broadcastMessage("New msg: " + e.getNewContent());
9
Bukkit.broadcastMessage("Blocked content: " + e.getBlockedContent());
10
}
Copied!
Checking contexts and types
1
@EventHandler
2
public void onModuleTrigger(ModuleTriggerEvent e) {
3
if (e.getContext() == APITriggerContext.BOOK && e.getType() == APIViolationType.UNICODE_CHARACTER_BLOCK) {
4
// do something only if context was a book and detection type was from the unicode remover
5
}
6
}
Copied!