Faire telecharger mes dossier mods flan config a mon launcher perso 1.6.2


  • Aujourd’hui je me retourne vers vous car je ne comprends pas aprés un petit Xmilliéme de test je n’arrive toujours pas à faire téléchargé à mon launcheur les dossiers mods flan config et j’en passe pourtant j’ai suivit pas mal de membre ( sujet au dessus ) j’ai fais pas mal de recherche test à droite et à gauche pour en arriver à ne toujours pas comprendre pourquoi aprés le bon parametrage de mon launcher il ne télécharge pas les ressource voici toute mes classe

    coter launcher

    custom.class
    Citation
     ```java

    package custom;

    public class Custom
    {
    public final static String urlNews = “http://dermen-design.fr/newLauncher/news.php”; // “http://mcupdate.tumblr.com
    public final static String urlDownload = “http://waracraft-two.franceserv.com/launcher/waracraft.dowload/”; // url de download des versions
    public final static String urlDownloadResources = “http://waracraft-two.franceserv.com/launcher/waracraft.Resources/”; // facultatif : url de download des resources supplémentaires
    public final static String WindowName = “waracraft”; // “Minecraft Launcher 1.0.8”
    public final static String profileName = “(default)”; // nom du profil par défaut
    }

    versionmanager.class
    Citation

    package net.minecraft.launcher.updater;

    import java.io.File;
    import java.io.IOException;
    import java.net.Proxy;
    import java.net.URL;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.EnumMap;
    import java.util.HashMap;
    import java.util.HashSet;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    import java.util.Set;
    import java.util.concurrent.ThreadPoolExecutor;

    import javax.swing.SwingUtilities;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;

    import net.minecraft.launcher.Launcher;
    import net.minecraft.launcher.OperatingSystem;
    import net.minecraft.launcher.events.RefreshedVersionsListener;
    import net.minecraft.launcher.updater.download.DownloadJob;
    import net.minecraft.launcher.updater.download.Downloadable;
    import net.minecraft.launcher.versions.CompleteVersion;
    import net.minecraft.launcher.versions.ReleaseType;
    import net.minecraft.launcher.versions.Version;

    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;

    import custom.Custom;

    public class VersionManager
    {
    private final VersionList localVersionList;
    private final VersionList remoteVersionList;
    private final ThreadPoolExecutor executorService = new ExceptionalThreadPoolExecutor(8);
    private final List <refreshedversionslistener>refreshedVersionsListeners = Collections.synchronizedList(new ArrayList<refreshedversionslistener>());
    private final Object refreshLock = new Object();
    private boolean isRefreshing;

    public VersionManager(VersionList localVersionList, VersionList remoteVersionList)
    {
    this.localVersionList = localVersionList;
    this.remoteVersionList = remoteVersionList;
    }

    public void refreshVersions() throws IOException {
    synchronized (this.refreshLock) {
    this.isRefreshing = true;
    }
    try
    {
    this.localVersionList.refreshVersions();
    this.remoteVersionList.refreshVersions();
    } catch (IOException ex) {
    synchronized (this.refreshLock) {
    this.isRefreshing = false;
    }
    throw ex;
    }

    if ((this.localVersionList instanceof LocalVersionList)) {
    for (Version version : this.remoteVersionList.getVersions()) {
    String id = version.getId();
    if (this.localVersionList.getVersion(id) != null) {
    this.localVersionList.removeVersion(id);
    this.localVersionList.addVersion(this.remoteVersionList.getCompleteVersion(id));
    try
    {
    ((LocalVersionList)this.localVersionList).saveVersion(this.localVersionList.getCompleteVersion(id));
    } catch (IOException ex) {
    synchronized (this.refreshLock) {
    this.isRefreshing = false;
    }
    throw ex;
    }
    }
    }
    }

    synchronized (this.refreshLock) {
    this.isRefreshing = false;
    }

    final List <refreshedversionslistener>listeners = new ArrayList<refreshedversionslistener>(this.refreshedVersionsListeners);
    for (Iterator <refreshedversionslistener>iterator = listeners.iterator(); iterator.hasNext(); ) {
    RefreshedVersionsListener listener = (RefreshedVersionsListener)iterator.next();

    if (!listener.shouldReceiveEventsInUIThread()) {
    listener.onVersionsRefreshed(this);
    iterator.remove();
    }
    }

    if (!listeners.isEmpty())
    SwingUtilities.invokeLater(new Runnable()
    {
    public void run() {
    for (RefreshedVersionsListener listener : listeners)
    listener.onVersionsRefreshed(VersionManager.this);
    }
    });
    }

    public List <versionsyncinfo>getVersions()
    {
    return getVersions(null);
    }

    public List <versionsyncinfo>getVersions(VersionFilter filter) {
    synchronized (this.refreshLock) {
    if (this.isRefreshing) return new ArrayList<versionsyncinfo>();
    }

    List <versionsyncinfo>result = new ArrayList<versionsyncinfo>();
    Map <string, versionsyncinfo="">lookup = new HashMap<string, versionsyncinfo="">();
    Map <releasetype, integer="">counts = new EnumMap<releasetype, integer="">(ReleaseType.class);

    for (ReleaseType type : ReleaseType.values()) {
    counts.put(type, Integer.valueOf(0));
    }

    for (Version version : this.localVersionList.getVersions()) {
    if ((version.getType() != null) && (version.getUpdatedTime() != null))
    {
    VersionSyncInfo syncInfo = getVersionSyncInfo(version, this.remoteVersionList.getVersion(version.getId()));
    lookup.put(version.getId(), syncInfo);
    result.add(syncInfo);
    }
    }
    for (Version version : this.remoteVersionList.getVersions()) {
    if ((version.getType() != null) && (version.getUpdatedTime() != null) && (!lookup.containsKey(version.getId())) && ((filter == null) || ((filter.getTypes().contains(version.getType())) && (((Integer)counts.get(version.getType())).intValue() < filter.getMaxCount()))))
    {
    VersionSyncInfo syncInfo = getVersionSyncInfo(this.localVersionList.getVersion(version.getId()), version);
    lookup.put(version.getId(), syncInfo);
    result.add(syncInfo);

    if (filter != null) counts.put(version.getType(), Integer.valueOf(((Integer)counts.get(version.getType())).intValue() + 1));
    }
    }
    return result;
    }

    public VersionSyncInfo getVersionSyncInfo(Version version) {
    return getVersionSyncInfo(version.getId());
    }

    public VersionSyncInfo getVersionSyncInfo(String name) {
    return getVersionSyncInfo(this.localVersionList.getVersion(name), this.remoteVersionList.getVersion(name));
    }

    public VersionSyncInfo getVersionSyncInfo(Version localVersion, Version remoteVersion) {
    boolean installed = localVersion != null;
    boolean upToDate = installed;

    if ((installed) && (remoteVersion != null)) {
    upToDate = !remoteVersion.getUpdatedTime().after(localVersion.getUpdatedTime());
    }
    if ((localVersion instanceof CompleteVersion)) {
    upToDate &= this.localVersionList.hasAllFiles((CompleteVersion)localVersion, OperatingSystem.getCurrentPlatform());
    }

    return new VersionSyncInfo(localVersion, remoteVersion, installed, upToDate);
    }

    public List <versionsyncinfo>getInstalledVersions() {
    List <versionsyncinfo>result = new ArrayList<versionsyncinfo>();

    for (Version version : this.localVersionList.getVersions()) {
    if ((version.getType() == null) || (version.getUpdatedTime() == null))
    continue;
    VersionSyncInfo syncInfo = getVersionSyncInfo(version, this.remoteVersionList.getVersion(version.getId()));
    result.add(syncInfo);
    }

    return result;
    }

    public VersionList getRemoteVersionList() {
    return this.remoteVersionList;
    }

    public VersionList getLocalVersionList() {
    return this.localVersionList;
    }

    public CompleteVersion getLatestCompleteVersion(VersionSyncInfo syncInfo) throws IOException {
    if (syncInfo.getLatestSource() == VersionSyncInfo.VersionSource.REMOTE) {
    CompleteVersion result = null;
    IOException exception = null;
    try
    {
    result = this.remoteVersionList.getCompleteVersion(syncInfo.getLatestVersion());
    } catch (IOException e) {
    exception = e;
    try {
    result = this.localVersionList.getCompleteVersion(syncInfo.getLatestVersion());
    } catch (IOException localIOException1) {
    }
    }
    if (result != null) {
    return result;
    }
    throw exception;
    }

    return this.localVersionList.getCompleteVersion(syncInfo.getLatestVersion());
    }

    public DownloadJob downloadVersion(VersionSyncInfo syncInfo, DownloadJob job) throws IOException
    {
    if (!(this.localVersionList instanceof LocalVersionList)) throw new IllegalArgumentException(“Cannot download if local repo isn’t a LocalVersionList”);
    if (!(this.remoteVersionList instanceof RemoteVersionList)) throw new IllegalArgumentException(“Cannot download if local repo isn’t a RemoteVersionList”);
    CompleteVersion version = getLatestCompleteVersion(syncInfo);
    File baseDirectory = ((LocalVersionList)this.localVersionList).getBaseDirectory();
    Proxy proxy = ((RemoteVersionList)this.remoteVersionList).getProxy();

    job.addDownloadables(version.getRequiredDownloadables(OperatingSystem.getCurrentPlatform(), proxy, baseDirectory, false));

    String jarFile = “versions/” + version.getId() + “/” + version.getId() + “.jar”;
    String jarFileUri = jarFile.replaceAll(" ", “%20”);
    job.addDownloadables(new Downloadable[] { new Downloadable(proxy, new URL(Custom.urlDownload + jarFileUri), new File(baseDirectory, jarFile), false) });

    return job;
    }

    public DownloadJob downloadResources(DownloadJob job) throws IOException {
    File baseDirectory = ((LocalVersionList)this.localVersionList).getBaseDirectory();

    job.addDownloadables(getModFiles(((RemoteVersionList)this.remoteVersionList).getProxy(), baseDirectory));

    //A décommenter pour faire télécharger des fichiers supplémentaies sur un bucket Amazon S3

    job.addDownloadables(getModFiles(((RemoteVersionList)this.remoteVersionList).getProxy(), baseDirectory));

    //A décommenter pour faire télécharger des fichiers supplémentaies sur un bucket Amazon S3

    return job;
    }

    private Set <downloadable>getModFiles(Proxy proxy, File baseDirectory) {
    Set <downloadable>result = new HashSet<downloadable>();
    try
    {
    URL resourceUrl = new URL(Custom.urlDownloadResources);
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(resourceUrl.openStream());
    NodeList nodeLst = doc.getElementsByTagName(“Contents”);

    long start = System.nanoTime();
    for (int i = 0; i < nodeLst.getLength(); i++) {
    Node node = nodeLst.item(i);

    if (node.getNodeType() == 1) {
    Element element = (Element)node;
    String key = element.getElementsByTagName(“Key”).item(0).getChildNodes().item(0).getNodeValue();
    String etag = element.getElementsByTagName(“ETag”) != null ? element.getElementsByTagName(“ETag”).item(0).getChildNodes().item(0).getNodeValue() : “-”;
    long size = Long.parseLong(element.getElementsByTagName(“Size”).item(0).getChildNodes().item(0).getNodeValue());

    if (size > 0L) {
    File file = new File(baseDirectory, “/” + key);
    if (etag.length() > 1) {
    etag = Downloadable.getEtag(etag);
    if ((file.isFile()) && (file.length() == size)) {
    String localMd5 = Downloadable.getMD5(file);
    if (localMd5.equals(etag)) continue;
    }
    }
    Downloadable downloadable = new Downloadable(proxy, new URL(Custom.urlDownloadResources + key), file, false);
    downloadable.setExpectedSize(size);
    result.add(downloadable);
    }
    }
    }
    long end = System.nanoTime();
    long delta = end - start;
    Launcher.getInstance().println("Delta time to compare resources: " + delta / 1000000L + " ms ");
    } catch (Exception ex) {
    Launcher.getInstance().println(“Couldn’t download resources”, ex);
    }

    return result;
    }
    //ajout

    ///*A décommenter pour faire télécharger des fichiers supplémentaies sur un bucket Amazon S3
    //
    // private Set <downloadable>getModFiles(Proxy proxy, File baseDirectory) {
    // Set <downloadable>result = new HashSet<downloadable>();
    // try
    // {
    // URL resourceUrl = new URL(Custom.urlDownloadResources);
    // DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    // DocumentBuilder db = dbf.newDocumentBuilder();
    // Document doc = db.parse(resourceUrl.openStream());
    // NodeList nodeLst = doc.getElementsByTagName(“Contents”);
    //
    // long start = System.nanoTime();
    // for (int i = 0; i < nodeLst.getLength(); i++) {
    // Node node = nodeLst.item(i);
    //
    // if (node.getNodeType() == 1) {
    // Element element = (Element)node;
    // String key = element.getElementsByTagName(“Key”).item(0).getChildNodes().item(0).getNodeValue();
    // String etag = element.getElementsByTagName(“ETag”) != null ? element.getElementsByTagName(“ETag”).item(0).getChildNodes().item(0).getNodeValue() : “-”;
    // long size = Long.parseLong(element.getElementsByTagName(“Size”).item(0).getChildNodes().item(0).getNodeValue());
    //
    // if (size > 0L) {
    // File file = new File(baseDirectory, “/” + key);
    // if (etag.length() > 1) {
    // etag = Downloadable.getEtag(etag);
    // if ((file.isFile()) && (file.length() == size)) {
    // String localMd5 = Downloadable.getMD5(file);
    // if (localMd5.equals(etag)) continue;
    // }
    // }
    // Downloadable downloadable = new Downloadable(proxy, new URL(Custom.urlDownloadResources + key), file, false);
    // downloadable.setExpectedSize(size);
    // result.add(downloadable);
    // }
    // }
    // }
    // long end = System.nanoTime();
    // long delta = end - start;
    // Launcher.getInstance().println("Delta time to compare resources: " + delta / 1000000L + " ms ");
    // } catch (Exception ex) {
    // Launcher.getInstance().println(“Couldn’t download resources”, ex);
    // }
    //
    // return result;
    // }
    //
    ///*A décommenter pour faire télécharger des fichiers supplémentaies sur un bucket Amazon S3

    public ThreadPoolExecutor getExecutorService() {
    return this.executorService;
    }

    public void addRefreshedVersionsListener(RefreshedVersionsListener listener) {
    this.refreshedVersionsListeners.add(listener);
    }

    public void removeRefreshedVersionsListener(RefreshedVersionsListener listener) {
    this.refreshedVersionsListeners.remove(listener);
    }
    }

    
    dowloadjob.class
    
    Citation
     ```java
    
    package net.minecraft.launcher.updater.download;
    
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Collections;
    import java.util.List;
    import java.util.Queue;
    import java.util.concurrent.ConcurrentLinkedQueue;
    import java.util.concurrent.ThreadPoolExecutor;
    import java.util.concurrent.atomic.AtomicInteger;
    import net.minecraft.launcher.Launcher;
    
    @SuppressWarnings({ "unchecked", "rawtypes", "unused"})
    public class DownloadJob
    {
    private static final int MAX_ATTEMPTS_PER_FILE = 5;
    private static final int ASSUMED_AVERAGE_FILE_SIZE = 5242880;
    private final Queue <downloadable>remainingFiles = new ConcurrentLinkedQueue();
    private final List <downloadable>allFiles = Collections.synchronizedList(new ArrayList());
    private final List <downloadable>failures = Collections.synchronizedList(new ArrayList());
    private final List <downloadable>successful = Collections.synchronizedList(new ArrayList());
    private final List <progresscontainer>progressContainers = Collections.synchronizedList(new ArrayList());
    private final DownloadListener listener;
    private final String name;
    private final boolean ignoreFailures;
    private final AtomicInteger remainingThreads = new AtomicInteger();
    private boolean started;
    
    public DownloadJob(String name, boolean ignoreFailures, DownloadListener listener, Collection <downloadable>files)
    {
    this.name = name;
    this.ignoreFailures = ignoreFailures;
    this.listener = listener;
    if (files != null) addDownloadables(files);
    }
    
    public DownloadJob(String name, boolean ignoreFailures, DownloadListener listener)
    {
    this(name, ignoreFailures, listener, null);
    }
    
    public void addDownloadables(Collection <downloadable>downloadables) {
    if (this.started) throw new IllegalStateException("Cannot add to download job that has already started");
    
    this.allFiles.addAll(downloadables);
    this.remainingFiles.addAll(downloadables);
    
    for (Downloadable downloadable : downloadables) {
    this.progressContainers.add(downloadable.getMonitor());
    if (downloadable.getExpectedSize() == 0L)
    downloadable.getMonitor().setTotal(5242880L);
    else {
    downloadable.getMonitor().setTotal(downloadable.getExpectedSize());
    }
    downloadable.getMonitor().setJob(this);
    }
    }
    
    public void addDownloadables(Downloadable[] downloadables) {
    if (this.started) throw new IllegalStateException("Cannot add to download job that has already started");
    
    for (Downloadable downloadable : downloadables) {
    this.allFiles.add(downloadable);
    this.remainingFiles.add(downloadable);
    this.progressContainers.add(downloadable.getMonitor());
    if (downloadable.getExpectedSize() == 0L)
    downloadable.getMonitor().setTotal(5242880L);
    else {
    downloadable.getMonitor().setTotal(downloadable.getExpectedSize());
    }
    downloadable.getMonitor().setJob(this);
    }
    }
    
    public void startDownloading(ThreadPoolExecutor executorService) {
    if (this.started) throw new IllegalStateException("Cannot start download job that has already started");
    this.started = true;
    
    if (this.allFiles.isEmpty()) {
    Launcher.getInstance().println("Download job '" + this.name + "' skipped as there are no files to download");
    this.listener.onDownloadJobFinished(this);
    } else {
    int threads = executorService.getMaximumPoolSize();
    this.remainingThreads.set(threads);
    Launcher.getInstance().println("Download job '" + this.name + "' started (" + threads + " threads, " + this.allFiles.size() + " files)");
    for (int i = 0; i < threads; i++)
    executorService.submit(new Runnable()
    {
    public void run() {
    DownloadJob.this.popAndDownload();
    }
    });
    }
    }
    
    private void popAndDownload()
    {
    Downloadable downloadable;
    while ((downloadable = (Downloadable)this.remainingFiles.poll()) != null) {
    if (downloadable.getNumAttempts() > 5) {
    if (!this.ignoreFailures) this.failures.add(downloadable);
    Launcher.getInstance().println("Gave up trying to download " + downloadable.getUrl() + " for job '" + this.name + "'");
    continue;
    }
    try
    {
    String result = downloadable.download();
    this.successful.add(downloadable);
    Launcher.getInstance().println("Finished downloading " + downloadable.getTarget() + " for job '" + this.name + "'" + ": " + result);
    } catch (Throwable t) {
    Launcher.getInstance().println("Couldn't download " + downloadable.getUrl() + " for job '" + this.name + "'", t);
    this.remainingFiles.add(downloadable);
    }
    }
    
    if (this.remainingThreads.decrementAndGet() <= 0)
    this.listener.onDownloadJobFinished(this);
    }
    
    public boolean shouldIgnoreFailures()
    {
    return this.ignoreFailures;
    }
    
    public boolean isStarted() {
    return this.started;
    }
    
    public boolean isComplete() {
    return (this.started) && (this.remainingFiles.isEmpty()) && (this.remainingThreads.get() == 0);
    }
    
    public int getFailures() {
    return this.failures.size();
    }
    
    public int getSuccessful() {
    return this.successful.size();
    }
    
    public String getName() {
    return this.name;
    }
    
    public void updateProgress() {
    this.listener.onDownloadJobProgressChanged(this);
    }
    
    public float getProgress() {
    float current = 0.0F;
    float total = 0.0F;
    
    synchronized (this.progressContainers) {
    for (ProgressContainer progress : this.progressContainers) {
    total += (float)progress.getTotal();
    current += (float)progress.getCurrent();
    }
    }
    
    float result = -1.0F;
    if (total > 0.0F) result = current / total;
    return result;
    }
    }
    
    

    dowloadable.class

    Citation
     ```java

    package net.minecraft.launcher.updater.download;

    import java.io.Closeable;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.math.BigInteger;
    import java.net.HttpURLConnection;
    import java.net.Proxy;
    import java.net.URL;
    import java.security.DigestInputStream;
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;

    public class Downloadable
    {
    private final URL url;
    private final File target;
    private final boolean forceDownload;
    private final Proxy proxy;
    private final ProgressContainer monitor;
    private int numAttempts;
    private long expectedSize = 0L;

    public Downloadable(Proxy proxy, URL remoteFile, File localFile, boolean forceDownload) {
    this.proxy = proxy;
    this.url = remoteFile;
    this.target = localFile;
    this.forceDownload = forceDownload;
    this.monitor = new ProgressContainer();
    }

    public ProgressContainer getMonitor() {
    return this.monitor;
    }

    public long getExpectedSize() {
    return this.expectedSize;
    }

    public void setExpectedSize(long expectedSize) {
    this.expectedSize = expectedSize;
    }

    public String download() throws IOException
    {
    String localMd5 = null;
    this.numAttempts += 1;

    if ((this.target.getParentFile() != null) && (!this.target.getParentFile().isDirectory())) {
    this.target.getParentFile().mkdirs();
    }
    if ((!this.forceDownload) && (this.target.isFile())) {
    localMd5 = getMD5(this.target);
    }

    if ((this.target.isFile()) && (!this.target.canWrite())) {
    throw new RuntimeException(“Do not have write permissions for " + this.target + " - aborting!”);
    }
    try
    {
    HttpURLConnection connection = makeConnection(localMd5);
    int status = connection.getResponseCode();

    if (status == 304)
    return “Used own copy as it matched etag”;
    if (status / 100 == 2) {
    if (this.expectedSize == 0L)
    this.monitor.setTotal(connection.getContentLength());
    else {
    this.monitor.setTotal(this.expectedSize);
    }

    InputStream inputStream = new MonitoringInputStream(connection.getInputStream(), this.monitor);
    FileOutputStream outputStream = new FileOutputStream(this.target);
    String md5 = copyAndDigest(inputStream, outputStream);
    String etag = getEtag(connection);

    if (etag.contains("-"))
    {
    return “Didn’t have etag so assuming our copy is good”;
    }if (etag.equalsIgnoreCase(md5))
    {
    return “Downloaded successfully and etag matched”;
    }
    throw new RuntimeException(String.format(“E-tag did not match downloaded MD5 (ETag was %s, downloaded %s)”, new Object[] { etag, md5 }));
    }
    if (this.target.isFile()) {
    return "Couldn’t connect to server (responded with " + status + “) but have local file, assuming it’s good”;
    }
    throw new RuntimeException("Server responded with " + status);
    }
    catch (IOException e) {
    if (this.target.isFile()) {
    return “Couldn’t connect to server (” + e.getClass().getSimpleName() + “: '” + e.getMessage() + “’) but have local file, assuming it’s good”;
    }
    throw e;
    } catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(“Missing Digest.MD5”, e);
    }

    }

    protected HttpURLConnection makeConnection(String localMd5) throws IOException
    {
    HttpURLConnection connection = (HttpURLConnection)this.url.openConnection(this.proxy);

    connection.setUseCaches(false);
    connection.setDefaultUseCaches(false);
    connection.setRequestProperty(“Cache-Control”, “no-store,max-age=0,no-cache”);
    connection.setRequestProperty(“Expires”, “0”);
    connection.setRequestProperty(“Pragma”, “no-cache”);
    if (localMd5 != null) connection.setRequestProperty(“If-None-Match”, localMd5);

    connection.connect();

    return connection;
    }

    public URL getUrl() {
    return this.url;
    }

    public File getTarget() {
    return this.target;
    }

    public boolean shouldIgnoreLocal() {
    return this.forceDownload;
    }

    public int getNumAttempts() {
    return this.numAttempts;
    }

    public Proxy getProxy() {
    return this.proxy;
    }

    public static String getMD5(File file) {
    DigestInputStream stream = null;
    int read;
    try
    {
    stream = new DigestInputStream(new FileInputStream(file), MessageDigest.getInstance(“MD5”));
    byte[] buffer = new byte[65536];

    read = stream.read(buffer);
    while (read >= 1)
    read = stream.read(buffer);
    }
    catch (Exception ignored) {
    return null;
    }
    finally
    {
    closeSilently(stream);
    }

    return String.format("%1$032x", new Object[] { new BigInteger(1, stream.getMessageDigest().digest()) });
    }

    public static void closeSilently(Closeable closeable) {
    if (closeable != null)
    try {
    closeable.close();
    }
    catch (IOException localIOException) {
    }
    }

    public static String copyAndDigest(InputStream inputStream, OutputStream outputStream) throws IOException, NoSuchAlgorithmException {
    MessageDigest digest = MessageDigest.getInstance(“MD5”);
    byte[] buffer = new byte[65536];
    try
    {
    int read = inputStream.read(buffer);
    while (read >= 1) {
    digest.update(buffer, 0, read);
    outputStream.write(buffer, 0, read);
    read = inputStream.read(buffer);
    }
    } finally {
    closeSilently(inputStream);
    closeSilently(outputStream);
    }

    return String.format("%1$032x", new Object[] { new BigInteger(1, digest.digest()) });
    }

    public static String getEtag(HttpURLConnection connection) {
    return getEtag(connection.getHeaderField(“ETag”));
    }

    public static String getEtag(String etag) {
    if (etag == null)
    etag = “-”;
    else if ((etag.startsWith(""")) && (etag.endsWith(""")))
    {
    etag = etag.substring(1, etag.length() - 1);
    }

    return etag;
    }
    }

    et du coter bootstrap.jar
    
    dowloadable.class
    
    Citation
     ```java
    
    package net.minecraft.bootstrap;
    
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.math.BigInteger;
    import java.net.BindException;
    import java.net.HttpURLConnection;
    import java.net.Proxy;
    import java.net.URL;
    import java.security.MessageDigest;
    import java.util.concurrent.CountDownLatch;
    import java.util.concurrent.atomic.AtomicBoolean;
    
    import javax.net.ssl.SSLHandshakeException;
    
    import custom.Custom;
    
    public class Downloader implements Runnable
    {
    @SuppressWarnings("unused")
    private static final int MAX_RETRIES = 10;
    private final Proxy proxy;
    private final String currentMd5;
    private final File targetFile;
    private final Controller controller;
    private Bootstrap bootstrap;
    
    public Downloader(Controller controller, Bootstrap bootstrap, Proxy proxy, String currentMd5, File targetFile)
    {
    this.controller = controller;
    this.bootstrap = bootstrap;
    this.proxy = proxy;
    this.currentMd5 = currentMd5;
    this.targetFile = targetFile;
    }
    
    public void run()
    {
    int retries = 0;
    while (true)
    {
    retries++; if (retries > 10) break;
    try
    {
    URL url = new URL(Custom.urlLauncher);
    
    HttpURLConnection connection = getConnection(url);
    
    connection.setUseCaches(false);
    connection.setDefaultUseCaches(false);
    connection.setRequestProperty("Cache-Control", "no-store,max-age=0,no-cache");
    connection.setRequestProperty("Expires", "0");
    connection.setRequestProperty("Pragma", "no-cache");
    if (this.currentMd5 != null)
    {
    connection.setRequestProperty("If-None-Match", this.currentMd5.toLowerCase());
    }
    
    connection.setConnectTimeout(30000);
    connection.setReadTimeout(10000);
    
    log(new StringBuilder().append("Downloading: " + Custom.urlLauncher).append(retries > 1 ? String.format(" (try %d/%d)", new Object[] { Integer.valueOf(retries), Integer.valueOf(10) }) : "").toString());
    long start = System.nanoTime();
    connection.connect();
    long elapsed = System.nanoTime() - start;
    log(new StringBuilder().append("Got reply in: ").append(elapsed / 1000000L).append("ms").toString());
    
    int code = connection.getResponseCode() / 100;
    
    if (code == 2)
    {
    String eTag = connection.getHeaderField("ETag");
    
    if (eTag == null)
    {
    eTag = "-";
    }
    else
    {
    eTag = eTag.substring(1, eTag.length() - 1);
    }
    
    this.controller.foundUpdate.set(true);
    this.controller.foundUpdateLatch.countDown();
    
    InputStream inputStream = connection.getInputStream();
    FileOutputStream outputStream = new FileOutputStream(this.targetFile);
    
    MessageDigest digest = MessageDigest.getInstance("MD5");
    
    long startDownload = System.nanoTime();
    long bytesRead = 0L;
    byte[] buffer = new byte[65536];
    try
    {
    int read = inputStream.read(buffer);
    while (read >= 1)
    {
    bytesRead += read;
    digest.update(buffer, 0, read);
    outputStream.write(buffer, 0, read);
    read = inputStream.read(buffer);
    }
    }
    finally
    {
    inputStream.close();
    outputStream.close();
    }
    long elapsedDownload = System.nanoTime() - startDownload;
    
    float elapsedSeconds = (float)(1L + elapsedDownload) / 1.0E+009F;
    float kbRead = (float)bytesRead / 1024.0F;
    log(String.format("Downloaded %.1fkb in %ds at %.1fkb/s", new Object[] { Float.valueOf(kbRead), Integer.valueOf((int)elapsedSeconds), Float.valueOf(kbRead / elapsedSeconds) }));
    
    String md5sum = String.format("%1$032x", new Object[] { new BigInteger(1, digest.digest()) });
    if ((!eTag.contains("-")) && (!eTag.equalsIgnoreCase(md5sum)))
    {
    log("After downloading, the MD5 hash didn't match. Retrying");
    }
    else
    {
    this.controller.hasDownloadedLatch.countDown();
    return;
    }
    }
    else if (code == 4)
    {
    log("Remote file not found.");
    }
    else
    {
    this.controller.foundUpdate.set(false);
    this.controller.foundUpdateLatch.countDown();
    log("No update found.");
    return;
    }
    }
    catch (Exception e)
    {
    log(new StringBuilder().append("Exception: ").append(e.toString()).toString());
    suggestHelp(e);
    }
    }
    
    log("Unable to download remote file. Check your internet connection/proxy settings.");
    }
    
    public void suggestHelp(Throwable t)
    {
    if ((t instanceof BindException))
    log("Recognized exception: the likely cause is a broken ipv4/6 stack. Check your TCP/IP settings.");
    else if ((t instanceof SSLHandshakeException))
    log("Recognized exception: the likely cause is a set of broken/missing root-certificates. Check your java install and perhaps reinstall it.");
    }
    
    public void log(String str)
    {
    this.bootstrap.println(str);
    }
    
    public HttpURLConnection getConnection(URL url) throws IOException
    {
    return (HttpURLConnection)url.openConnection(this.proxy);
    }
    
    public static class Controller
    {
    public final CountDownLatch foundUpdateLatch = new CountDownLatch(1);
    public final AtomicBoolean foundUpdate = new AtomicBoolean(false);
    public final CountDownLatch hasDownloadedLatch = new CountDownLatch(1);
    }
    }
    
    

    et custom.class
    Citation
     ```java

    package custom;

    public class Custom
    {
    public static String folder = “waracraftwo”; // nom du dossier (.MonServer)
    public static String urlLauncher = “http://waracraft-two.franceserv.com/launcher/launcher/launcher.jar”; // url de téléchargement du launcher
    public static String name = “launcher”; // nom du launcher.jar (CustomName.jar)
    public static String nameLauncher = “Minecraft CustomLauncher”; // nom du launcher updater
    }

    
    voila je vous ai tous mis se que j'ai modifier et sa ne marche pas pour voir ma composition c'est ici : http://waracraft-two…v.com/launcher/
    
    aidez moi je vous en supplit
    
    je déprime ^^
    
    cordialement
    
    si vous arriver pas a lire j'ai creer un zutre sujet sur se forum pour voir les code des class : http://forum.ironcraft.fr/topic/8922-telechargement-de-mes-dossier-mods-config-flan-162/</downloadable></downloadable></progresscontainer></downloadable></downloadable></downloadable></downloadable></downloadable></downloadable></downloadable></downloadable></downloadable></downloadable></versionsyncinfo></versionsyncinfo></versionsyncinfo></releasetype,></releasetype,></string,></string,></versionsyncinfo></versionsyncinfo></versionsyncinfo></versionsyncinfo></versionsyncinfo></refreshedversionslistener></refreshedversionslistener></refreshedversionslistener></refreshedversionslistener></refreshedversionslistener>
  • Modérateurs

    S’il te plait, utilise [java][/java], sans les *.


  • voila j’ai modifier les balise ^^

  • Administrateurs Rédacteurs Moddeurs confirmés

    J’ai déplacé dans la section du support pour les moddeurs, qui est plus approprié pour ce genre de problème.
    Je n’es pas encore étudié le code du nouveau launcher, donc je sais pas vraiment comment il fonctionne.
    Le plus simple reste de télécharger une archive et la faire extraire directement dans le dossier du launcher, comme je l’avais fait pour mon launcher 1.4.7.


  • Décommente les lignes a décommenter dans ton versionmanager.java