mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 15:46:01 +00:00
Fix indentation and remove trailing whitespace
This patch provides common/mekanism/*.java with standardized indentation (tabs) and also removes trailing whitespace.
This commit is contained in:
1 parent
9d8a6c9e4c
commit
e5a6eadc45
468 files changed
+25218
-25218
No files matched your search
@@ -30,69 +30,69 @@ public class ThreadClientUpdate extends Thread
|
||||
private int bytesDownloaded;
|
||||
private int lastBytesDownloaded;
|
||||
private byte[] buffer = new byte[10240];
|
||||
|
||||
|
||||
private static File modsDir = new File(Mekanism.proxy.getMinecraftDir(), "mods");
|
||||
private static File tempDir = new File(modsDir, "temp");
|
||||
private static URL zipUrl = createURL();
|
||||
|
||||
|
||||
public static boolean hasUpdated;
|
||||
|
||||
|
||||
public ThreadClientUpdate()
|
||||
{
|
||||
setDaemon(false);
|
||||
start();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
{
|
||||
try {
|
||||
deleteTemp();
|
||||
createTemp();
|
||||
|
||||
|
||||
File download = new File(tempDir, "builds.zip");
|
||||
|
||||
|
||||
prepareForDownload();
|
||||
download.createNewFile();
|
||||
|
||||
|
||||
GuiCredits.updateInfo("Downloading...");
|
||||
|
||||
|
||||
FileOutputStream outputStream = new FileOutputStream(download.getAbsolutePath());
|
||||
InputStream stream = zipUrl.openStream();
|
||||
|
||||
|
||||
while((lastBytesDownloaded = stream.read(buffer)) > 0)
|
||||
{
|
||||
outputStream.write(buffer, 0, lastBytesDownloaded);
|
||||
buffer = new byte[10240];
|
||||
bytesDownloaded += lastBytesDownloaded;
|
||||
}
|
||||
|
||||
|
||||
outputStream.close();
|
||||
stream.close();
|
||||
|
||||
|
||||
if(Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1)
|
||||
{
|
||||
ZipInputStream zip = new ZipInputStream(new FileInputStream(download));
|
||||
deployEntry(zip, "Mekanism-");
|
||||
zip.close();
|
||||
}
|
||||
|
||||
|
||||
for(IModule module : Mekanism.modulesLoaded)
|
||||
{
|
||||
if(module.getVersion().comparedState(Version.get(Mekanism.latestVersionNumber)) == -1)
|
||||
{
|
||||
{
|
||||
ZipInputStream zip = new ZipInputStream(new FileInputStream(download));
|
||||
deployEntry(zip, "Mekanism" + module.getName());
|
||||
zip.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
deleteTemp();
|
||||
|
||||
|
||||
hasUpdated = true;
|
||||
GuiCredits.updateInfo("Update installed, reboot Minecraft for changes.");
|
||||
System.out.println("[Mekanism] Successfully updated to latest version (" + Mekanism.latestVersionNumber + ").");
|
||||
|
||||
|
||||
finalize();
|
||||
} catch(Throwable t) {
|
||||
GuiCredits.updateInfo(EnumColor.DARK_RED + "Error updating.");
|
||||
@@ -101,48 +101,48 @@ public class ThreadClientUpdate extends Thread
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void deployEntry(ZipInputStream zip, String filePrefix) throws IOException
|
||||
{
|
||||
byte[] zipBuffer = new byte[1024];
|
||||
ZipEntry entry = zip.getNextEntry();
|
||||
|
||||
|
||||
while(entry != null)
|
||||
{
|
||||
if(entry.isDirectory())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(entry.getName().contains(filePrefix))
|
||||
{
|
||||
File modFile = new File(modsDir, entry.getName().replace("output/", ""));
|
||||
|
||||
|
||||
if(modFile.exists())
|
||||
{
|
||||
modFile.delete();
|
||||
}
|
||||
|
||||
|
||||
modFile.createNewFile();
|
||||
|
||||
|
||||
FileOutputStream outStream = new FileOutputStream(modFile);
|
||||
|
||||
int len;
|
||||
|
||||
while((len = zip.read(zipBuffer)) > 0)
|
||||
{
|
||||
outStream.write(zipBuffer, 0, len);
|
||||
}
|
||||
|
||||
zip.closeEntry();
|
||||
|
||||
int len;
|
||||
|
||||
while((len = zip.read(zipBuffer)) > 0)
|
||||
{
|
||||
outStream.write(zipBuffer, 0, len);
|
||||
}
|
||||
|
||||
zip.closeEntry();
|
||||
outStream.close();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
entry = zip.getNextEntry();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createTemp() throws IOException
|
||||
{
|
||||
if(!tempDir.exists())
|
||||
@@ -150,7 +150,7 @@ public class ThreadClientUpdate extends Thread
|
||||
tempDir.mkdir();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void deleteTemp() throws IOException
|
||||
{
|
||||
if(tempDir.exists())
|
||||
@@ -158,7 +158,7 @@ public class ThreadClientUpdate extends Thread
|
||||
clearFiles(tempDir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void clearFiles(File file)
|
||||
{
|
||||
if(file.isDirectory())
|
||||
@@ -168,14 +168,14 @@ public class ThreadClientUpdate extends Thread
|
||||
clearFiles(sub);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
file.delete();
|
||||
}
|
||||
|
||||
|
||||
private void prepareForDownload()
|
||||
{
|
||||
File[] modsList = new File(new StringBuilder().append(Mekanism.proxy.getMinecraftDir()).append(File.separator + "mods").toString()).listFiles();
|
||||
|
||||
|
||||
if(Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1)
|
||||
{
|
||||
for(File file : modsList)
|
||||
@@ -186,7 +186,7 @@ public class ThreadClientUpdate extends Thread
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(IModule module : Mekanism.modulesLoaded)
|
||||
{
|
||||
for(File file : modsList)
|
||||
@@ -197,16 +197,16 @@ public class ThreadClientUpdate extends Thread
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
System.out.println("[Mekanism] Preparing to update...");
|
||||
}
|
||||
|
||||
|
||||
private static URL createURL()
|
||||
{
|
||||
try {
|
||||
return new URL("http://ci.aidancbrady.com/job/Mekanism/Recommended/artifact/*zip*/archive.zip");
|
||||
} catch(Exception e) {}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user