diff options
Diffstat (limited to 'src/main')
4 files changed, 69 insertions, 55 deletions
diff --git a/src/main/java/de/cowtipper/cowlection/Cowlection.java b/src/main/java/de/cowtipper/cowlection/Cowlection.java index f4c1602..332d08e 100644 --- a/src/main/java/de/cowtipper/cowlection/Cowlection.java +++ b/src/main/java/de/cowtipper/cowlection/Cowlection.java @@ -36,6 +36,7 @@ public class Cowlection { public static final String VERSION = "@VERSION@"; public static final String MODNAME = "@MODNAME@"; public static final String GITURL = "@GITURL@"; + public static final String INVITE_URL = "https://discord.gg/fU2tFPf"; public static KeyBinding[] keyBindings; private static Cowlection instance; private File modsDir; diff --git a/src/main/java/de/cowtipper/cowlection/command/MooCommand.java b/src/main/java/de/cowtipper/cowlection/command/MooCommand.java index 7a67a0d..7c7a6c6 100644 --- a/src/main/java/de/cowtipper/cowlection/command/MooCommand.java +++ b/src/main/java/de/cowtipper/cowlection/command/MooCommand.java @@ -152,55 +152,9 @@ public class MooCommand extends CommandBase { long year = ((System.currentTimeMillis() - 1560275700000L) / (TimeUnit.HOURS.toMillis(124))) + 1; main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, "It is SkyBlock year " + EnumChatFormatting.GOLD + year + EnumChatFormatting.YELLOW + "."); } else if (args[0].equalsIgnoreCase("worldage") || args[0].equalsIgnoreCase("serverage")) { - if (args.length == 2) { - boolean enable; - switch (args[1]) { - case "on": - case "enable": - enable = true; - break; - case "off": - case "disable": - enable = false; - break; - default: - main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Command usage: /" + getCommandName() + " worldage [on|off]"); - return; - } - MooConfig.notifyServerAge = enable; - main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "✔ " + (enable ? EnumChatFormatting.DARK_GREEN + "Enabled" : EnumChatFormatting.RED + "Disabled") + EnumChatFormatting.GREEN + " world age notifications."); - main.getConfig().syncFromFields(); - } else { - long worldTime = Minecraft.getMinecraft().theWorld.getWorldTime(); - new TickDelay(() -> { - WorldClient world = Minecraft.getMinecraft().theWorld; - if (world == null) { - return; - } - String msgPrefix; - long worldTime2 = world.getWorldTime(); - if (worldTime > worldTime2 || (worldTime2 - worldTime) < 15) { - // time is frozen - worldTime2 = world.getTotalWorldTime(); - msgPrefix = "World time seems to be frozen at around " + worldTime + " ticks. "; - if (worldTime2 > 24 * 60 * 60 * 20) { - // total world time >24h - main.getChatHelper().sendMessage(EnumChatFormatting.GOLD, msgPrefix + "However, how long this world is loaded cannot be determined."); - return; - } - msgPrefix += "However, this world is probably"; - } else { - msgPrefix = "This world is"; - } - long days = worldTime2 / 24000L + 1; - long minutes = days * 20; - long hours = minutes / 60; - minutes -= hours * 60; - - main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, msgPrefix + " loaded around " + EnumChatFormatting.GOLD + days + " ingame days " - + EnumChatFormatting.YELLOW + "(= less than" + EnumChatFormatting.GOLD + (hours > 0 ? " " + hours + " hours" : "") + (minutes > 0 ? " " + minutes + " mins" : "") + ")"); - }, 20); - } + handleWorldAge(args); + } else if (args[0].equalsIgnoreCase("discord")) { + main.getChatHelper().sendMessage(new MooChatComponent("➜ Need help with " + EnumChatFormatting.GOLD + Cowlection.MODNAME + EnumChatFormatting.GREEN + "? Do you have any questions, suggestions or other feedback? " + EnumChatFormatting.GOLD + "Join the Cowshed discord!").green().setUrl(Cowlection.INVITE_URL)); } //endregion //region sub-commands: update mod @@ -1098,6 +1052,58 @@ public class MooCommand extends CommandBase { } } } + + private void handleWorldAge(String[] args) { + if (args.length == 2) { + boolean enable; + switch (args[1]) { + case "on": + case "enable": + enable = true; + break; + case "off": + case "disable": + enable = false; + break; + default: + main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Command usage: /" + getCommandName() + " worldage [on|off]"); + return; + } + MooConfig.notifyServerAge = enable; + main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "✔ " + (enable ? EnumChatFormatting.DARK_GREEN + "Enabled" : EnumChatFormatting.RED + "Disabled") + EnumChatFormatting.GREEN + " world age notifications."); + main.getConfig().syncFromFields(); + } else { + long worldTime = Minecraft.getMinecraft().theWorld.getWorldTime(); + new TickDelay(() -> { + WorldClient world = Minecraft.getMinecraft().theWorld; + if (world == null) { + return; + } + String msgPrefix; + long worldTime2 = world.getWorldTime(); + if (worldTime > worldTime2 || (worldTime2 - worldTime) < 15) { + // time is frozen + worldTime2 = world.getTotalWorldTime(); + msgPrefix = "World time seems to be frozen at around " + worldTime + " ticks. "; + if (worldTime2 > 24 * 60 * 60 * 20) { + // total world time >24h + main.getChatHelper().sendMessage(EnumChatFormatting.GOLD, msgPrefix + "However, how long this world is loaded cannot be determined."); + return; + } + msgPrefix += "However, this world is probably"; + } else { + msgPrefix = "This world is"; + } + long days = worldTime2 / 24000L + 1; + long minutes = days * 20; + long hours = minutes / 60; + minutes -= hours * 60; + + main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, msgPrefix + " loaded around " + EnumChatFormatting.GOLD + days + " ingame days " + + EnumChatFormatting.YELLOW + "(= less than" + EnumChatFormatting.GOLD + (hours > 0 ? " " + hours + " hours" : "") + (minutes > 0 ? " " + minutes + " mins" : "") + ")"); + }, 20); + } + } //endregion //region sub-commands: update mod @@ -1167,12 +1173,14 @@ public class MooCommand extends CommandBase { .appendSibling(createCmdHelpEntry("guiScale", "Change GUI scale")) .appendSibling(createCmdHelpEntry("rr", "Alias for /r without auto-replacement to /msg")) .appendSibling(createCmdHelpEntry("shrug", "¯\\_(ツ)_/¯")) + .appendSibling(createCmdHelpEntry("discord", "Need help? Join the Cowshed discord")) .appendSibling(createCmdHelpSection(4, "Update mod")) .appendSibling(createCmdHelpEntry("update", "Check for new mod updates")) .appendSibling(createCmdHelpEntry("updateHelp", "Show mod update instructions")) .appendSibling(createCmdHelpEntry("version", "View results of last mod update check")) .appendSibling(createCmdHelpEntry("directory", "Open Minecraft's mods directory")) - .appendFreshSibling(new MooChatComponent("➡ /commandslist " + EnumChatFormatting.YELLOW + "to list all commands added by your installed mods.").lightPurple().setSuggestCommand("/commandslist")); + .appendFreshSibling(new MooChatComponent("➡ /commandslist " + EnumChatFormatting.YELLOW + "to list all commands added by your installed mods.").lightPurple().setSuggestCommand("/commandslist")) + .appendFreshSibling(new MooChatComponent("➜ Need help with " + EnumChatFormatting.GOLD + Cowlection.MODNAME + EnumChatFormatting.GREEN + "? Do you have any questions, suggestions or other feedback? " + EnumChatFormatting.GOLD + "Join the Cowshed discord!").green().setUrl(Cowlection.INVITE_URL)); sender.addChatMessage(usage); } @@ -1199,7 +1207,7 @@ public class MooCommand extends CommandBase { /* main */ "help", "config", /* Best friends, friends & other players */ "stalk", "add", "remove", "list", "online", "nameChangeCheck", /* SkyBlock */ "stalkskyblock", "skyblockstalk", "chestAnalyzer", "analyzeChests", "analyzeIsland", "waila", "whatAmILookingAt", "dungeon", - /* miscellaneous */ "search", "worldage", "serverage", "guiscale", "rr", "shrug", "apikey", + /* miscellaneous */ "search", "worldage", "serverage", "guiscale", "rr", "shrug", "apikey", "discord", /* update mod */ "update", "updateHelp", "version", "directory", /* rarely used aliases */ "askPolitelyWhereTheyAre", "askPolitelyAboutTheirSkyBlockProgress", "year", "whatyearisit"); } else if (args.length == 2 && (args[0].equalsIgnoreCase("waila") || args[0].equalsIgnoreCase("whatAmILookingAt"))) { diff --git a/src/main/java/de/cowtipper/cowlection/partyfinder/RuleEditorGui.java b/src/main/java/de/cowtipper/cowlection/partyfinder/RuleEditorGui.java index f9d27c5..23b725b 100644 --- a/src/main/java/de/cowtipper/cowlection/partyfinder/RuleEditorGui.java +++ b/src/main/java/de/cowtipper/cowlection/partyfinder/RuleEditorGui.java @@ -147,7 +147,7 @@ public class RuleEditorGui extends GuiScreen { guiDefaultAll.setButtonDelay(60); mc.displayGuiScreen(guiDefaultAll); } else if (button == btnHelp) { - GuiConfirmOpenLink guiHelp = new GuiConfirmOpenLink(this, "https://discord.gg/fU2tFPf", 50000000, true); + GuiConfirmOpenLink guiHelp = new GuiConfirmOpenLink(this, Cowlection.INVITE_URL, 50000000, true); guiHelp.disableSecurityWarning(); mc.displayGuiScreen(guiHelp); } else if (button == btnClose) { @@ -199,9 +199,9 @@ public class RuleEditorGui extends GuiScreen { rules.resetToDefault(); } else if (id == 50000000) { try { - Desktop.getDesktop().browse(new URI("https://discord.gg/fU2tFPf")); + Desktop.getDesktop().browse(new URI(Cowlection.INVITE_URL)); } catch (Throwable throwable) { - Cowlection.getInstance().getLogger().error("Couldn't open link https://discord.gg/fU2tFPf", throwable); + Cowlection.getInstance().getLogger().error("Couldn't open link " + Cowlection.INVITE_URL, throwable); } } else if (id < 9000000) { // user confirmed rule deletion diff --git a/src/main/java/de/cowtipper/cowlection/util/VersionChecker.java b/src/main/java/de/cowtipper/cowlection/util/VersionChecker.java index 4fd465e..ea313c0 100644 --- a/src/main/java/de/cowtipper/cowlection/util/VersionChecker.java +++ b/src/main/java/de/cowtipper/cowlection/util/VersionChecker.java @@ -116,7 +116,12 @@ public class VersionChecker { .setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/moo directory")) .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Open mods directory with command " + EnumChatFormatting.GOLD + "/moo directory\n➜ Click to open mods directory")))); - statusMsg = text.appendSibling(download).appendSibling(spacer).appendSibling(changelog).appendSibling(spacer).appendSibling(updateInstructions).appendSibling(spacer).appendSibling(openModsDirectory); + IChatComponent discord = new ChatComponentText("[Cowshed Discord]").setChatStyle(new ChatStyle() + .setColor(EnumChatFormatting.AQUA).setBold(true) + .setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, Cowlection.INVITE_URL)) + .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Need help? Join the Cowshed discord!")))); + + statusMsg = text.appendSibling(download).appendSibling(spacer).appendSibling(changelog).appendSibling(spacer).appendSibling(updateInstructions).appendSibling(spacer).appendSibling(openModsDirectory).appendSibling(spacer).appendSibling(discord); } if (statusMsg != null) { |