Skip to content

Instantly share code, notes, and snippets.

@Waterpicker
Created August 26, 2016 03:59
Show Gist options
  • Save Waterpicker/357a39c3b9f0eb47ac8f996c858eef1b to your computer and use it in GitHub Desktop.
Save Waterpicker/357a39c3b9f0eb47ac8f996c858eef1b to your computer and use it in GitHub Desktop.
private static Text text = Text.builder().color(TextColors.GRAY).append(Text.of("Please reconsider your usage of the All Caps Rage.")).build();
public void onPlayerChat(MessageChannelEvent.Chat event) {
Optional<Player> player = event.getCause().first(Player.class);
if(player.isPresent()) {
Stream<Character> stream = event.getRawMessage().toPlain().chars().mapToObj(i -> (char)i);
if(stream.filter(c -> Character.isUpperCase(c)).count()/stream.count() > 0.5) {
player.get().sendMessage(text);
event.setMessageCancelled(true);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment