use of net.minecraftforge.common.ForgeVersion.CheckResult in project MC-Prefab by Brian-Wuest.
the class UpdateChecker method checkVersion.
/**
* 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;
}
}
}
use of net.minecraftforge.common.ForgeVersion.CheckResult in project DynamicSurroundings by OreCruncher.
the class VersionChecker method getUpdateMessage.
@Nullable
private String getUpdateMessage(@Nonnull final String modId) {
final ModContainer mod = ForgeUtils.findModContainer(modId);
if (mod == null)
return null;
final CheckResult result = ForgeVersion.getResult(mod);
if (dontPrintMessage(result))
return null;
final String t = result.target.toString();
final String u = result.url.toString();
return Localization.format(this.messageId, mod.getName(), t, u);
}
use of net.minecraftforge.common.ForgeVersion.CheckResult in project ImmersiveEngineering by BluSunrize.
the class ClientProxy method addChangelogToManual.
public void addChangelogToManual() {
FontRenderer fr = ManualHelper.getManual().fontRenderer;
boolean isUnicode = fr.getUnicodeFlag();
fr.setUnicodeFlag(true);
SortedMap<ComparableVersion, Pair<String, IManualPage[]>> allChanges = new TreeMap<>(Comparator.reverseOrder());
ComparableVersion currIEVer = new ComparableVersion(ImmersiveEngineering.VERSION);
// Included changelog
try (InputStream in = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(ImmersiveEngineering.MODID, "changelog.json")).getInputStream()) {
JsonElement ele = new JsonParser().parse(new InputStreamReader(in));
JsonObject upToCurrent = ele.getAsJsonObject();
for (Entry<String, JsonElement> entry : upToCurrent.entrySet()) {
ComparableVersion version = new ComparableVersion(entry.getKey());
Pair<String, IManualPage[]> manualEntry = addVersionToManual(currIEVer, version, entry.getValue().getAsString(), false);
if (manualEntry != null)
allChanges.put(version, manualEntry);
}
} catch (IOException x) {
x.printStackTrace();
}
// Changelog from update JSON
CheckResult result = ForgeVersion.getResult(Loader.instance().activeModContainer());
if (result.status != Status.PENDING && result.status != Status.FAILED)
for (Entry<ComparableVersion, String> e : result.changes.entrySet()) allChanges.put(e.getKey(), addVersionToManual(currIEVer, e.getKey(), e.getValue(), true));
for (Pair<String, IManualPage[]> entry : allChanges.values()) ManualHelper.addEntry(entry.getLeft(), ManualHelper.CAT_UPDATE, entry.getRight());
fr.setUnicodeFlag(isUnicode);
}
use of net.minecraftforge.common.ForgeVersion.CheckResult in project MinecraftForge by MinecraftForge.
the class GuiModList method updateCache.
private void updateCache() {
configModButton.visible = false;
disableModButton.visible = false;
modInfo = null;
if (selectedMod == null)
return;
ResourceLocation logoPath = null;
Dimension logoDims = new Dimension(0, 0);
List<String> lines = new ArrayList<String>();
CheckResult vercheck = ForgeVersion.getResult(selectedMod);
String logoFile = selectedMod.getMetadata().logoFile;
if (!logoFile.isEmpty()) {
TextureManager tm = mc.getTextureManager();
IResourcePack pack = FMLClientHandler.instance().getResourcePackFor(selectedMod.getModId());
try {
BufferedImage logo = null;
if (pack != null) {
logo = pack.getPackImage();
} else {
InputStream logoResource = getClass().getResourceAsStream(logoFile);
if (logoResource != null)
logo = ImageIO.read(logoResource);
}
if (logo != null) {
logoPath = tm.getDynamicTextureLocation("modlogo", new DynamicTexture(logo));
logoDims = new Dimension(logo.getWidth(), logo.getHeight());
}
} catch (IOException e) {
}
}
if (!selectedMod.getMetadata().autogenerated) {
disableModButton.visible = true;
disableModButton.enabled = true;
disableModButton.packedFGColour = 0;
Disableable disableable = selectedMod.canBeDisabled();
if (disableable == Disableable.RESTART) {
disableModButton.packedFGColour = 0xFF3377;
} else if (disableable != Disableable.YES) {
disableModButton.enabled = false;
}
IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(selectedMod);
configModButton.visible = true;
configModButton.enabled = guiFactory != null && guiFactory.mainConfigGuiClass() != null;
lines.add(selectedMod.getMetadata().name);
lines.add(String.format("Version: %s (%s)", selectedMod.getDisplayVersion(), selectedMod.getVersion()));
lines.add(String.format("Mod ID: '%s' Mod State: %s", selectedMod.getModId(), Loader.instance().getModState(selectedMod)));
if (!selectedMod.getMetadata().credits.isEmpty()) {
lines.add("Credits: " + selectedMod.getMetadata().credits);
}
lines.add("Authors: " + selectedMod.getMetadata().getAuthorList());
lines.add("URL: " + selectedMod.getMetadata().url);
if (selectedMod.getMetadata().childMods.isEmpty())
lines.add("No child mods for this mod");
else
lines.add("Child mods: " + selectedMod.getMetadata().getChildModList());
if (vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED)
lines.add("Update Available: " + (vercheck.url == null ? "" : vercheck.url));
lines.add(null);
lines.add(selectedMod.getMetadata().description);
} else {
lines.add(WHITE + selectedMod.getName());
lines.add(WHITE + "Version: " + selectedMod.getVersion());
lines.add(WHITE + "Mod State: " + Loader.instance().getModState(selectedMod));
if (vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED)
lines.add("Update Available: " + (vercheck.url == null ? "" : vercheck.url));
lines.add(null);
lines.add(RED + "No mod information found");
lines.add(RED + "Ask your mod author to provide a mod mcmod.info file");
}
if ((vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED) && vercheck.changes.size() > 0) {
lines.add(null);
lines.add("Changes:");
for (Entry<ComparableVersion, String> entry : vercheck.changes.entrySet()) {
lines.add(" " + entry.getKey() + ":");
lines.add(entry.getValue());
lines.add(null);
}
}
modInfo = new Info(this.width - this.listWidth - 30, lines, logoPath, logoDims);
}
use of net.minecraftforge.common.ForgeVersion.CheckResult in project MinecraftForge by MinecraftForge.
the class GuiSlotModList method drawSlot.
@Override
protected void drawSlot(int idx, int right, int top, int height, Tessellator tess) {
ModContainer mc = mods.get(idx);
String name = StringUtils.stripControlCodes(mc.getName());
String version = StringUtils.stripControlCodes(mc.getDisplayVersion());
FontRenderer font = this.parent.getFontRenderer();
CheckResult vercheck = ForgeVersion.getResult(mc);
if (Loader.instance().getModState(mc) == ModState.DISABLED) {
font.drawString(font.trimStringToWidth(name, listWidth - 10), this.left + 3, top + 2, 0xFF2222);
font.drawString(font.trimStringToWidth(version, listWidth - (5 + height)), this.left + 3, top + 12, 0xFF2222);
font.drawString(font.trimStringToWidth("DISABLED", listWidth - 10), this.left + 3, top + 22, 0xFF2222);
} else {
font.drawString(font.trimStringToWidth(name, listWidth - 10), this.left + 3, top + 2, 0xFFFFFF);
font.drawString(font.trimStringToWidth(version, listWidth - (5 + height)), this.left + 3, top + 12, 0xCCCCCC);
font.drawString(font.trimStringToWidth(mc.getMetadata() != null ? mc.getMetadata().getChildModCountString() : "Metadata not found", listWidth - 10), this.left + 3, top + 22, 0xCCCCCC);
if (vercheck.status.shouldDraw()) {
//TODO: Consider adding more icons for visualization
Minecraft.getMinecraft().getTextureManager().bindTexture(VERSION_CHECK_ICONS);
GlStateManager.color(1, 1, 1, 1);
GlStateManager.pushMatrix();
Gui.drawModalRectWithCustomSizedTexture(right - (height / 2 + 4), top + (height / 2 - 4), vercheck.status.getSheetOffset() * 8, (vercheck.status.isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
GlStateManager.popMatrix();
}
}
}
Aggregations