use of me.semx11.autotip.message.StatsMessageMatcher in project Hyperium by HyperiumClient.
the class EventChatReceived method onChat.
@InvokeEvent
public void onChat(ServerChatEvent event) {
Config config = autotip.getConfig();
if (!autotip.getSessionManager().isOnHypixel()) {
return;
}
String msg = UniversalUtil.getUnformattedText(event);
CommandLimbo limboCommand = autotip.getCommand(CommandLimbo.class);
if (limboCommand.hasExecuted()) {
if (msg.startsWith("A kick occurred in your connection")) {
event.setCancelled(true);
} else if (msg.startsWith("Illegal characters in chat")) {
event.setCancelled(true);
limboCommand.setExecuted(false);
}
}
if (!config.isEnabled())
return;
GlobalSettings settings = autotip.getGlobalSettings();
MessageOption option = config.getMessageOption();
for (Message message : settings.getMessages()) {
MessageMatcher matcher = message.getMatcherFor(msg);
if (matcher.matches()) {
event.setCancelled(message.shouldHide(option));
return;
}
}
String hover = UniversalUtil.getHoverText(event);
settings.getStatsMessages().forEach(message -> {
StatsMessageMatcher matcher = message.getMatcherFor(msg);
if (!matcher.matches())
return;
StatsDaily stats = getStats();
matcher.applyStats(stats);
message.applyHoverStats(hover, stats);
event.setCancelled(message.shouldHide(option));
});
}
Aggregations