feat: remove stupid version checker

This commit is contained in:
Timo Ley 2022-12-18 11:37:51 +01:00
parent a9fb9dce44
commit 4a32f463f9
5 changed files with 2 additions and 158 deletions

View file

@ -55,7 +55,6 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ClientTickHandler
{
public boolean hasNotified = false;
public boolean initHoliday = false;
public boolean preloadedSounds = false;
@ -87,12 +86,6 @@ public class ClientTickHandler
{
MekanismClient.ticksPassed++;
if(!hasNotified && mc.theWorld != null && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null)
{
MekanismUtils.checkForUpdates(mc.thePlayer);
hasNotified = true;
}
if(!Mekanism.proxy.isPaused())
{
for(Iterator<IClientTicker> iter = tickingSet.iterator(); iter.hasNext();)

View file

@ -22,7 +22,6 @@ public class GuiCredits extends GuiScreen
buttonList.clear();
buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 72 + 12, "Update"));
buttonList.add(new GuiButton(1, width / 2 - 100, height / 4 + 96 + 12, "Cancel"));
((GuiButton)buttonList.get(0)).enabled = !MekanismUtils.noUpdates() && !ThreadClientUpdate.hasUpdated;
}
public static void updateInfo(String info)
@ -35,16 +34,7 @@ public class GuiCredits extends GuiScreen
{
if(guibutton.id == 0)
{
if(!MekanismUtils.noUpdates())
{
updateProgress = "Preparing to update...";
guibutton.enabled = false;
new ThreadClientUpdate();
}
else {
updateProgress = "You already have the latest version.";
}
updateProgress = "You already have the latest version.";
}
else if(guibutton.id == 1)
{

View file

@ -83,16 +83,7 @@ public class CommandMekanism extends CommandBase
}
else if(params[0].equalsIgnoreCase("version"))
{
if(!MekanismUtils.checkForUpdates((EntityPlayer)sender))
{
if(general.updateNotifications || Mekanism.latestVersionNumber == null || Mekanism.recentNews == null || Mekanism.latestVersionNumber.equals("null"))
{
sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Minecraft is in offline mode, could not check for updates."));
}
else {
sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Your client is up to date."));
}
}
sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Your client is up to date."));
}
else if(params[0].equalsIgnoreCase("news"))
{

View file

@ -1,47 +0,0 @@
package mekanism.common;
import java.util.List;
import mekanism.common.util.MekanismUtils;
import cpw.mods.fml.relauncher.FMLInjectionData;
/**
* Thread used to retrieve data from the Mekanism server.
* @author AidanBrady
*
*/
public class ThreadGetData extends Thread
{
public ThreadGetData()
{
setDaemon(true);
start();
}
@Override
public void run()
{
List<String> ret = MekanismUtils.getHTML("https://raw.githubusercontent.com/maggi373/files/main/mekanism/Mekanism.txt");
Mekanism.latestVersionNumber = "null";
Mekanism.recentNews = "null";
for(String s : ret)
{
String[] text = s.split(":");
if(text.length == 3 && !text[0].contains("UTF-8") && !text[0].contains("HTML") && !text[0].contains("http"))
{
if(Version.get(text[0]) != null && Version.get(text[0]).equals(Version.get((String)FMLInjectionData.data()[4])))
{
Mekanism.latestVersionNumber = text[1];
Mekanism.recentNews = text[2];
break;
}
}
}
MekanismUtils.updateDonators();
}
}

View file

@ -104,62 +104,6 @@ public final class MekanismUtils
public static final Map<String, Class<?>> classesFound = new HashMap<String, Class<?>>();
/**
* Checks for a new version of Mekanism.
*/
public static boolean checkForUpdates(EntityPlayer entityplayer)
{
try {
if(general.updateNotifications && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null)
{
if(!Mekanism.latestVersionNumber.equals("null"))
{
ArrayList<IModule> list = new ArrayList<IModule>();
for(IModule module : Mekanism.modulesLoaded)
{
if(Version.get(Mekanism.latestVersionNumber).comparedState(module.getVersion()) == 1)
{
list.add(module);
}
}
if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1 || !list.isEmpty())
{
entityplayer.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------"));
entityplayer.addChatMessage(new ChatComponentText(EnumColor.GREY + " " + LangUtils.localize("update.outdated") + "."));
if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1)
{
entityplayer.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " Mekanism: " + EnumColor.DARK_RED + Mekanism.versionNumber));
}
for(IModule module : list)
{
entityplayer.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " Mekanism" + module.getName() + ": " + EnumColor.DARK_RED + module.getVersion()));
}
entityplayer.addChatMessage(new ChatComponentText(EnumColor.GREY + " " + LangUtils.localize("update.consider") + " " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber));
entityplayer.addChatMessage(new ChatComponentText(EnumColor.GREY + " " + LangUtils.localize("update.newFeatures") + ": " + EnumColor.INDIGO + Mekanism.recentNews));
entityplayer.addChatMessage(new ChatComponentText(EnumColor.GREY + " " + LangUtils.localize("update.visit") + " " + EnumColor.DARK_GREY + "https://thorfusion.com" + EnumColor.GREY + " " + LangUtils.localize("update.toDownload") + "."));
entityplayer.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------"));
return true;
}
else if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == -1)
{
entityplayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("update.devBuild") + " " + EnumColor.DARK_GREY + Mekanism.versionNumber));
return true;
}
}
else {
Mekanism.logger.info("Minecraft is in offline mode, could not check for updates.");
}
}
} catch(Exception e) {}
return false;
}
/**
* Updates the donator list by retrieving the most recent information from a foreign document.
*/
@ -216,33 +160,6 @@ public final class MekanismUtils
return builder.toString();
}
/**
* Checks if the mod doesn't need an update.
* @return if mod doesn't need an update
*/
public static boolean noUpdates()
{
if(Mekanism.latestVersionNumber.contains("null"))
{
return true;
}
if(Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1)
{
return false;
}
for(IModule module : Mekanism.modulesLoaded)
{
if(module.getVersion().comparedState(Version.get(Mekanism.latestVersionNumber)) == -1)
{
return false;
}
}
return true;
}
/**
* Checks if Minecraft is running in offline mode.
* @return if mod is running in offline mode.