use of com.velocitypowered.api.event.player.PlayerChatEvent in project ChatRegulator by 4drian3d.
the class ChatListener method onChat.
/**
* Chat Listener for detections
* @param event the chat event
* @param continuation the event cycle
*/
@Subscribe(order = PostOrder.FIRST)
public void onChat(final PlayerChatEvent event, final Continuation continuation) {
if (!event.getResult().isAllowed()) {
continuation.resume();
return;
}
final Player player = event.getPlayer();
final AtomicReference<String> message = new AtomicReference<String>(event.getMessage());
final InfractionPlayer infractor = InfractionPlayer.get(player);
final EventWrapper<PlayerChatEvent> wrapper = new ChatWrapper(event, continuation);
if (unicode(infractor, message, wrapper, plugin) || caps(infractor, message, wrapper, plugin) || flood(infractor, message, wrapper, plugin) || regular(infractor, message, wrapper, plugin) || spam(infractor, message, wrapper, plugin)) {
return;
}
if (Configuration.getConfig().getFormatConfig().enabled()) {
message.set(Replacer.applyFormat(message.get()));
event.setResult(ChatResult.message(message.get()));
}
infractor.lastMessage(message.get());
continuation.resume();
}
Aggregations