use of me.semx11.autotip.command.impl.CommandLimbo in project Hyperium by HyperiumClient.
the class Autotip method setup.
private void setup() {
try {
fileUtil = new FileUtil(this);
gson = new GsonBuilder().registerTypeAdapter(Config.class, new ConfigCreator(this)).registerTypeAdapter(StatsDaily.class, new StatsDailyCreator(this)).setExclusionStrategies(new AnnotationExclusionStrategy()).setPrettyPrinting().create();
config = new Config(this);
reloadGlobalSettings();
reloadLocale();
sessionManager = new SessionManager(this);
statsManager = new StatsManager(this);
migrationManager = new MigrationManager(this);
fileUtil.createDirectories();
config.load();
taskManager.getExecutor().execute(() -> migrationManager.migrateLegacyFiles());
registerEvents(new EventClientConnection(this), new EventChatReceived(this));
registerCommands(new CommandAutotip(this), new CommandLimbo(this));
Runtime.getRuntime().addShutdownHook(new Thread(sessionManager::logout));
initialized = true;
} catch (IOException e) {
messageUtil.send("Autotip is disabled because it couldn't create the required files.");
ErrorReport.reportException(e);
} catch (IllegalStateException e) {
messageUtil.send("Autotip is disabled because it couldn't connect to the API.");
ErrorReport.reportException(e);
}
}
use of me.semx11.autotip.command.impl.CommandLimbo 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