use of me.semx11.autotip.chat.MessageUtil in project Hyperium by HyperiumClient.
the class Autotip method init.
public void init() {
ErrorReport.setAutotip(this);
RequestHandler.setAutotip(this);
UniversalUtil.setAutotip(this);
minecraft = Minecraft.getMinecraft();
mcVersion = UniversalUtil.getMinecraftVersion();
version = new Version(VERSION);
messageUtil = new MessageUtil(this);
registerEvents(new EventClientTick(this));
taskManager = new TaskManager();
taskManager.schedule(this::setup, 0);
}
use of me.semx11.autotip.chat.MessageUtil in project Hyperium by HyperiumClient.
the class CommandAutotip method onExecute.
@Override
public void onExecute(String[] args) {
Config config = autotip.getConfig();
MessageUtil messageUtil = autotip.getMessageUtil();
TaskManager taskManager = autotip.getTaskManager();
SessionManager manager = autotip.getSessionManager();
StatsManager stats = autotip.getStatsManager();
GlobalSettings settings = autotip.getGlobalSettings();
if (args.length <= 0) {
messageUtil.sendKey("command.usage");
return;
}
switch(args[0].toLowerCase()) {
case "s":
case "stats":
LocalDate now = LocalDate.now();
if (args.length <= 1) {
stats.get(now).print();
return;
}
String param = args[1].toLowerCase();
switch(param) {
case "d":
case "day":
case "daily":
case "today":
stats.get(now).print();
break;
case "yd":
case "yesterday":
stats.get(now.minusDays(1)).print();
break;
case "w":
case "week":
case "weekly":
stats.getRange(now.with(DayOfWeek.MONDAY), now.with(DayOfWeek.SUNDAY)).print();
break;
case "m":
case "month":
case "monthly":
stats.getRange(now.withDayOfMonth(1), now.withDayOfMonth(now.lengthOfMonth())).print();
break;
case "y":
case "year":
case "yearly":
stats.getRange(now.withDayOfYear(1), now.withDayOfYear(now.lengthOfYear())).print();
break;
case "a":
case "all":
case "total":
case "life":
case "lifetime":
stats.getAll().print();
break;
default:
if (param.contains("-")) {
List<LocalDate> dates = Arrays.stream(param.split("-")).map(string -> {
try {
return LocalDate.parse(string, DATE_FORMAT);
} catch (DateTimeParseException e) {
return null;
}
}).filter(Objects::nonNull).limit(2).sorted().collect(Collectors.toList());
if (dates.size() != 2) {
messageUtil.sendKey("command.stats.invalidRange");
return;
}
stats.getRange(dates.get(0), dates.get(1)).print();
} else if (param.contains("/")) {
try {
LocalDate date = LocalDate.parse(param, DATE_FORMAT);
stats.get(date).print();
} catch (DateTimeParseException e) {
messageUtil.sendKey("command.stats.invalidDate");
}
} else {
messageUtil.sendKey("command.stats.usage");
}
break;
}
break;
case "?":
case "info":
StatsDaily today = stats.get();
messageUtil.getKeyHelper("command.info").separator().sendKey("version", autotip.getVersion()).withKey("credits", context -> context.getBuilder().setHover(context.getKey("creditsHover")).send()).sendKey("status." + (config.isEnabled() ? "enabled" : "disabled")).sendKey("messages", config.getMessageOption()).sendKey("tipsSent", today.getTipsSent()).sendKey("tipsReceived", today.getTipsReceived()).sendKey("statsCommand").separator();
break;
case "m":
case "messages":
try {
if (args.length > 1) {
MessageOption option = MessageOption.valueOfIgnoreCase(args[1]);
config.setMessageOption(option).save();
} else {
config.nextMessageOption().save();
}
messageUtil.sendKey("command.messages.next", config.getMessageOption());
} catch (IllegalArgumentException e) {
messageUtil.sendKey("command.messages.error", args.length > 1 ? args[1] : null);
}
break;
case "t":
case "toggle":
if (!manager.isOnHypixel()) {
config.toggleEnabled().save();
messageUtil.getKeyHelper("command.toggle").sendKey(config.isEnabled() ? "enabled" : "disabled");
return;
}
if (!config.isEnabled()) {
if (!manager.isLoggedIn()) {
taskManager.executeTask(TaskType.LOGIN, manager::login);
config.setEnabled(true).save();
messageUtil.sendKey("command.toggle.enabled");
} else {
messageUtil.sendKey("command.toggle.error");
}
} else {
if (manager.isLoggedIn()) {
taskManager.executeTask(TaskType.LOGOUT, manager::logout);
config.setEnabled(false).save();
messageUtil.sendKey("command.toggle.disabled");
} else {
messageUtil.sendKey("command.toggle.error");
}
}
break;
case "w":
case "wave":
if (!config.isEnabled()) {
messageUtil.sendKey("error.disabled");
return;
}
if (!manager.isOnHypixel()) {
messageUtil.sendKey("error.disabledHypixel");
return;
}
if (manager.getNextTipWave() == 0) {
messageUtil.sendKey("command.wave.error");
return;
}
long t = System.currentTimeMillis();
String next = LocalTime.MIN.plusSeconds((manager.getNextTipWave() - t) / 1000 + 1).format(WAVE_FORMAT);
String last = LocalTime.MIN.plusSeconds((t - manager.getLastTipWave()) / 1000).format(WAVE_FORMAT);
messageUtil.getKeyHelper("command.wave").separator().sendKey("nextWave", next).sendKey("lastWave", last).separator();
break;
case "changelog":
messageUtil.getKeyHelper("command.changelog").separator().sendKey("version", autotip.getVersion()).withKey("entry", context -> settings.getVersionInfo(autotip.getVersion()).getChangelog().forEach(context::send)).separator();
break;
case "debug":
EventClientConnection event = autotip.getEvent(EventClientConnection.class);
Object header = event.getHeader();
messageUtil.getKeyHelper("command.debug").separator().sendKey("serverIp", event.getServerIp()).sendKey("mcVersion", autotip.getMcVersion()).sendKey("header." + (header == null ? "none" : "present"), UniversalUtil.getUnformattedText(header)).separator();
break;
case "reload":
try {
autotip.reloadGlobalSettings();
autotip.reloadLocale();
messageUtil.sendKey("command.reload.success");
} catch (IllegalStateException e) {
messageUtil.sendKey("command.reload.error");
}
break;
default:
messageUtil.send(getUsage());
break;
}
}
use of me.semx11.autotip.chat.MessageUtil in project Hyperium by HyperiumClient.
the class Stats method print.
public void print() {
MessageUtil messageUtil = autotip.getMessageUtil();
messageUtil.separator();
gameStatistics.entrySet().stream().sorted(Map.Entry.<String, Coins>comparingByValue().reversed()).forEach(entry -> {
String game = entry.getKey();
Coins coins = entry.getValue();
messageUtil.getKeyHelper("command.stats").withKey("coins", context -> context.getBuilder(game, coins.getTotal()).setHover(context.getKey("coinsHover"), game, coins.getSent(), coins.getReceived()).send());
});
messageUtil.getKeyHelper("command.stats").withKey("tips", context -> context.getBuilder(getTipsTotal()).setHover(context.getKey("tipsHover"), getTipsSent(), getTipsReceived()).send()).withKey("xp", context -> context.getBuilder(getXpTotal()).setHover(context.getKey("xpHover"), getXpSent(), getXpReceived()).send());
if (this instanceof StatsDaily) {
messageUtil.sendKey("command.stats.date", ((StatsDaily) this).getDateString());
} else if (this instanceof StatsRange) {
StatsRange range = (StatsRange) this;
messageUtil.sendKey("command.stats.dateRange", range.getStartString(), range.getEndString());
}
messageUtil.separator();
}
use of me.semx11.autotip.chat.MessageUtil in project Hyperium by HyperiumClient.
the class CommandLimbo method onExecute.
@Override
public void onExecute(String[] args) throws CommandException {
MessageUtil messageUtil = autotip.getMessageUtil();
if (autotip.getSessionManager().isOnHypixel()) {
executed = true;
messageUtil.sendCommand("/achat \u00a7c");
} else {
messageUtil.send("&cYou must be on Hypixel to use this command!");
}
}
Aggregations