/** * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the * window resizes, the buttonList is cleared beforehand. */ @Override public void initGui() { if (!hasCheckedForUpdates) { if (modButton != null) { for (ModContainer mod : Loader.instance().getModList()) { Status status = ForgeVersion.getResult(mod).status; if (status == Status.OUTDATED || status == Status.BETA_OUTDATED) { // TODO: Needs better visualization, maybe stacked icons // drawn in a terrace-like pattern? showNotification = Status.OUTDATED; } } } hasCheckedForUpdates = true; } }
@SubscribeEvent public void onPlayerLoggedIn(PlayerLoggedInEvent event) { EntityPlayer player = event.player; if (player != null) { if (ARKCraft.instance().isDebugger()) { player.sendMessage(new TextComponentString(ChatFormatting.RED + "You are running a decompiled version of ARKCraft!")); } else if (ARKCraft.versionCheckResult != null && ARKCraft.versionCheckResult.status == Status.OUTDATED || ARKCraft.versionCheckResult.status == Status.BETA_OUTDATED) { player.sendMessage(new TextComponentString(ChatFormatting.RED + I18n.translate("chat.notification.outdated"))); player.sendMessage(new TextComponentString(ChatFormatting.RED + I18n.format("chat.notification.outdatedversion", ARKCraft.instance().version()))); } else if (ARKCraft.versionCheckResult == null) { player.sendMessage(new TextComponentString(ChatFormatting.RED + "No Internet access")); } } }
public static void setUpdateStatus(String modId, Status status, ComparableVersion version) { try { ModContainer modContainer = FMLCommonHandler.instance().findContainerFor(modId); Map<ComparableVersion, String> changes = new HashMap<ComparableVersion, String>(); CheckResult result = ReflectionManager.newInstance(CheckResult.class, status, version, changes, ""); setUpdateStatus(modContainer, result); } catch (Exception e) { e.printStackTrace(); } }
/** * Checks the current version against the git-hub version. */ public static void checkVersion() { // Pull the repository information. ModContainer prefabMod = null; for (ModContainer modContainer : Loader.instance().getModList()) { if (modContainer.getName().toLowerCase().equals(Prefab.MODID.toLowerCase())) { prefabMod = modContainer; break; } } if (prefabMod != null) { CheckResult result = ForgeVersion.getResult(prefabMod); if (result != null && result.status == Status.OUTDATED) { // Current version is out dated, show the message when the user is logged in. UpdateChecker.messageToShow = "[Prefab] There is a new version available! New Version: [" + result.target.toString() + "] Your Version: [" + Prefab.VERSION + "]"; UpdateChecker.showMessage = true; } } }
private static boolean dontPrintMessage(@Nonnull final CheckResult result) { return result == null || result.status == null || result.target == null || result.url == null || result.status == Status.UP_TO_DATE || result.status == Status.AHEAD || result.status == Status.PENDING || result.status == Status.FAILED; }
@EventHandler public static void PostLoad(FMLPostInitializationEvent PostEvent) { log.info("Start Post Initialization"); long tM = System.currentTimeMillis(); proxy.postInit(); TomsModAPIMain.init(); log.info("Setting Max Stack Size of Minecarts to " + Config.minecartMaxStackSize + "."); Items.MINECART.setMaxStackSize(Config.minecartMaxStackSize); Items.CHEST_MINECART.setMaxStackSize(Config.minecartMaxStackSize); Items.TNT_MINECART.setMaxStackSize(Config.minecartMaxStackSize); Items.FURNACE_MINECART.setMaxStackSize(Config.minecartMaxStackSize); Items.HOPPER_MINECART.setMaxStackSize(Config.minecartMaxStackSize); versionCheckResult = ForgeVersion.getResult(mc); Logger vcLog = LogManager.getLogger(Configs.ModName + "] [Version Checker"); if (versionCheckResult.status == Status.OUTDATED) { vcLog.warn("****************************************"); vcLog.warn("* Tom's Mod is OUTDATED!!"); vcLog.warn("* Current version: " + Configs.version); vcLog.warn("* Online version: " + versionCheckResult.target.toString()); vcLog.warn("****************************************"); } else if (versionCheckResult.status == Status.AHEAD) { vcLog.warn("??? status == AHEAD ???"); vcLog.warn("?? Current version: " + Configs.version); } else if (versionCheckResult.status == Status.PENDING || versionCheckResult.status == Status.FAILED) { vcLog.warn("Tom's Mod version checking failed."); } else { vcLog.info("Tom's Mod is up to date"); } String[] tools = new String[]{"!_axe", "!_pickaxe", "!_shovel", "!_sword", "!_hoe"}; List<String> toNerf = new ArrayList<>(); if (Config.nerfedTools != null && Config.nerfedTools.length > 0) Stream.of(Config.nerfedTools).map(ResourceLocation::new).filter(Item.REGISTRY::containsKey).map(ResourceLocation::toString).forEach(toNerf::add); if (Config.disableWoodenTools) { log.info("Nerfing wooden tools"); Stream.of(tools).map(t -> t.replace("!", "wooden")).forEach(toNerf::add); } if (Config.disableStoneTools) { log.info("Nerfing stone tools"); Stream.of(tools).map(t -> t.replace("!", "stone")).forEach(toNerf::add); } if (Config.disableIronTools) { log.info("Nerfing iron tools"); Stream.of(tools).map(t -> t.replace("!", "iron")).forEach(toNerf::add); } if (Config.disableGoldTools) { log.info("Nerfing gold tools"); Stream.of(tools).map(t -> t.replace("!", "gold")).forEach(toNerf::add); } if (Config.disableDiamondTools) { log.info("Nerfing diamond tools"); Stream.of(tools).map(t -> t.replace("!", "diamond")).forEach(toNerf::add); } if (Config.enableHardModeStarting) { log.info("Overwriting Wood Harvest Levels"); hackedWood = new HackedWoodMaterial(); List<ItemStack> list = new ArrayList<>(OreDictionary.getOres("logWood")); list.addAll(OreDictionary.getOres("plankWood")); list.addAll(OreDictionary.getOres("slabWood")); list.addAll(OreDictionary.getOres("stairWood")); for (ItemStack stack : list) { Block block = Block.getBlockFromItem(stack.getItem()); if (block != Blocks.AIR) { block.setHarvestLevel("axe", 0); TomsModUtils.trySetFinalField(Block.class, Material.class, block, hackedWood, log, "Failed to set Material value for " + block.getUnlocalizedName()); } } } toNerf.stream().map(ResourceLocation::new).map(Item.REGISTRY::getObject).filter(i -> i != null).forEach(CoreInit::nerfTool); Config.initFluids(); Config.printWarnings(); long time = System.currentTimeMillis() - tM; log.info("Post Initialization took in " + time + " milliseconds"); }
public static void updateCheckResult() { CheckResult r = ForgeVersion.getResult(modContainer); if (r != null && r.status != Status.PENDING) versionCheckResult = r; }