Skip to content

Commit

Permalink
console output don't need to b e translated. Also make log muted, use…
Browse files Browse the repository at this point in the history
… -Dfr.minecraftforgefrance.installer.debug=true to enable it
  • Loading branch information
robin4002 committed Jun 5, 2016
1 parent fcadd4e commit d642afc
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
compile 'com.google.guava:guava:14.0'
compile 'org.tukaani:xz:1.3'
compile 'net.minecraft:launchwrapper:1.12'
compile 'utybo:minkj:1.0'
compile 'utybo:minkj:1.1'
}

task fatJar(type: Jar, dependsOn: jar) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/fr/minecraftforgefrance/common/DownloadUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public static boolean checksumValid(File libPath, List<String> checksums)

public static boolean validateJar(File libPath, byte[] data, List<String> checksums) throws IOException
{
System.out.println(LANG.getTranslation("proc.checkingchecksum").replace("$p", libPath.getAbsolutePath()));
Logger.info(String.format("Checking %s internal checksums", libPath.getAbsolutePath()));

HashMap<String, String> files = new HashMap<String, String>();
String[] hashes = null;
Expand Down Expand Up @@ -250,11 +250,11 @@ public static boolean validateJar(File libPath, byte[] data, List<String> checks
boolean failed = !checksums.contains(files.get("checksums.sha1"));
if(failed)
{
System.err.println(LANG.getTranslation("err.checksumvalidation"));
System.err.println("Failed checksums.sha1 validation!");
}
else
{
System.out.println(LANG.getTranslation("file.checksumvalidation.success"));
Logger.info("Successfully validated checksums.sha1");
for(String hash : hashes)
{
if(hash.trim().equals("") || !hash.contains(" "))
Expand All @@ -279,14 +279,14 @@ else if(!checksum.equals(validChecksum))

if(!failed)
{
System.out.println(LANG.getTranslation("jar.validated.success"));
Logger.info("Jar contents validated successfully");
}

return !failed;
}
else
{
System.out.println(LANG.getTranslation("err.checksumnotfound"));
Logger.info("checksums.sha1 was not found, validation failed");
return false; // Missing checksums
}
}
Expand Down Expand Up @@ -322,7 +322,7 @@ public static void unpackLibrary(File output, byte[] data) throws IOException
String end = new String(decompressed, decompressed.length - 4, 4);
if(!end.equals("SIGN"))
{
System.err.println(LANG.getTranslation("err.missingsignature") + " : " + end);
System.err.println("Unpacking failed, missing signature : " + end);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public class Localization

public static void init()
{
if(!Logger.DEBUG)
{
LANG.mute();
}

try
{
LANG.loadTranslationsFromFile(Locale.FRENCH, Localization.class.getResourceAsStream("/langs/FR.lang"));
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/fr/minecraftforgefrance/common/Logger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package fr.minecraftforgefrance.common;

public class Logger
{
public final static boolean DEBUG = Boolean.valueOf(System.getProperty("fr.minecraftforgefrance.installer.debug", "false"));

public static void info(String info)
{
if(DEBUG)
{
System.out.println(info);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void deleteDeprecated()
File f = new File(this.modPackDir, entry.getPath());
if(f.delete())
{
System.out.println(String.format(LANG.getTranslation("file.removed.md5.success"), f.getPath(), entry.getMd5()));
Logger.info(String.format("%1$s was removed. Its md5 was : %2$s", f.getPath(), entry.getMd5()));
}
else
{
Expand Down Expand Up @@ -166,7 +166,7 @@ public String apply(JsonNode node)
}));
}

System.out.println(String.format(LANG.getTranslation("proc.consideringlib"), libName));
Logger.info(String.format("Considering library %s", libName));
String[] nameparts = Iterables.toArray(Splitter.on(':').split(libName), String.class);
nameparts[0] = nameparts[0].replace('.', '/');
String jarName = nameparts[1] + '-' + nameparts[2] + ".jar";
Expand Down Expand Up @@ -243,7 +243,7 @@ public void downloadMod()
f.getParentFile().mkdirs();
}
this.changeCurrentDownloadText(entry.getPath());
System.out.println(String.format(LANG.getTranslation("proc.downloadingfile"), entry.getUrl().toString(), f.getPath(), entry.getMd5()));
Logger.info(String.format("Downloading file %1$s to %2$s (its md5 is %3$s)", entry.getUrl().toString(), f.getPath(), entry.getMd5()));
if(!DownloadUtils.downloadFile(entry.getUrl(), f, this.installFrame))
{
this.installFrame.dispose();
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/fr/minecraftforgefrance/updater/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import fr.minecraftforgefrance.common.FileChecker;
import fr.minecraftforgefrance.common.IInstallRunner;
import fr.minecraftforgefrance.common.Localization;
import fr.minecraftforgefrance.common.Logger;
import fr.minecraftforgefrance.common.ProcessInstall;
import fr.minecraftforgefrance.common.RemoteInfoReader;
import joptsimple.OptionParser;
Expand All @@ -38,7 +39,7 @@ public static void main(String[] args)
public Updater(String[] args)
{
long start = System.currentTimeMillis();
System.out.println("Starting updater !");
Logger.info("Starting updater !");
final OptionParser parser = new OptionParser();
parser.allowsUnrecognizedOptions();
final OptionSpec<File> gameDirOption = parser.accepts("gameDir", "The game directory").withRequiredArg().ofType(File.class);
Expand Down Expand Up @@ -90,9 +91,7 @@ public Updater(String[] args)
FileChecker checker = new FileChecker(mcDir);
if(!shouldUpdate(jsonProfileData.getStringValue("forge"), checker))
{
System.out.println(LANG.getTranslation("no.update.found"));
long end = System.currentTimeMillis();
System.out.println(String.format(LANG.getTranslation("update.checked.in"), (end - start)));
Logger.info("No update found, launching Minecraft !");
runMinecraft(args);
}
else
Expand All @@ -108,6 +107,9 @@ public Updater(String[] args)
ProcessInstall install = new ProcessInstall(checker, this, mcDir, null);
install.createFrame();
}
long end = System.currentTimeMillis();
Logger.info(String.format("Update checked in %d ms", (end - start)));

}

public boolean shouldUpdate(String forgeVersion, FileChecker checker)
Expand All @@ -126,6 +128,7 @@ public boolean shouldUpdate(String forgeVersion, FileChecker checker)

public void runMinecraft(String[] args)
{
Logger.info("Lauching Minecraft ...");
Launch.main(args);
}

Expand Down
11 changes: 0 additions & 11 deletions src/main/resources/langs/EN.lang
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
###############################
# Errors
err.invalidurl=Invalid URL : %s
err.checksumvalidation=Failed checksums.sha1 validation!
err.checksumnotfound=checksums.sha1 was not found, validation failed
err.missingsignature=Unpacking failed, missing signature
err.mcdirmissing=The Minecraft dir is missing, please run the official Minecraft launcher
err.mcprofilemissing=Minecraft launcher profile not found, please run the official Minecraft launcher
err.mcprofilecorrupted=The launcher profile file is corrupted. Please re-run the minecraft launcher to fix it!
Expand All @@ -42,21 +39,13 @@ err.runminecraft=can't run the game, run it manually

# Tasks done
file.unpacked.success=Successfully unpacked %s
file.removed.md5.success=%1$s was removed. Its md5 was : %2$s
file.checksumvalidation.success=Successfully validated checksums.sha1
jar.validated.success=Jar contents validated successfully
installation.success=Installation finished !
no.update.found=No update found, launching Minecraft !
update.checked.in=Update checked in %d ms
update.finished.success=Update finished successfully, please restart the game !

# Processes running
proc.unpackingfile=Unpacking packed file
proc.downloadinglib=Downloading library %s
proc.consideringlib=Considering library %s
proc.downloadingfile=Downloading file %1$s to %2$s (its md5 is %3$s)
proc.downloadingmods=Downloading mods and config files...
proc.checkingchecksum=Checking "$p" internal checksums
proc.startingupdater=Starting the Updater...
proc.verifyfiles=Checking files ...

Expand Down
10 changes: 0 additions & 10 deletions src/main/resources/langs/FR.lang
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
########################################
# Erreurs
err.invalidurl=URL invalide : %s
err.checksumvalidation=Échec de la vérification du checksums.sha1
err.checksumnotfound=checksums.sha1 introuvable, la validation a échoué!
err.missingsignature=Décompression échouée, signature manquante
err.mcdirmissing=Le dossier de Minecraft est introuvable, veuillez lancer le launcher officiel!
err.mcprofilemissing=Le profile du launcher officiel est introuvable, veuillez lancer le launcher officiel!
err.mcprofilecorrupted=Le fichier du profil est corrompu. Veuillez relancer le launcher officiel pour le réparer!
Expand All @@ -42,21 +39,14 @@ err.runminecraft=Impossible de lancer Minecraft, lancez-le manuellement

# Tâches effectuées
file.unpacked.success=%s à été décompressé
file.removed.md5.success=%1$s a été supprimé. Son MD5 était %2$s
file.checksumvalidation.success=checksums.sha1 correctement validé
jar.validated.success=Contenu du .jar vérifié avec succès
installation.success=Installation terminée !
no.update.found=Aucune mise à jour trouvée, lancement de Minecraft !
update.checked.in=Présence de mise à jour vérifiée en %d ms
update.finished.success=Mise à jour terminée avec succès, veuillez relancer Minecraft !

# Processus
proc.unpackingfile=Décompression du fichier
proc.downloadinglib=Téléchargement de la bibliothèque %s
proc.consideringlib=Examination de la bibliothèque %s
proc.downloadingfile=Téléchargement du fichier %1$s vers %2$s (MD : %3$s)
proc.downloadingmods=Téléchargement des mods et des fichiers de configuration...
proc.checkingchecksum=Vérification des signatures internes "$p"
proc.startingupdater=Démarrage de l'utilitaire de mise à jour..
proc.verifyfiles=Vérification des fichiers ...

Expand Down

0 comments on commit d642afc

Please sign in to comment.