Package Will11690.mod.MechaniCraft.Capes

Source Code of Will11690.mod.MechaniCraft.Capes.DevCapesVersionChecker

package Will11690.mod.MechaniCraft.Capes;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

import argo.jdom.JdomParser;

public class DevCapesVersionChecker implements Runnable {

  private static final String versionFileURL = "https://dl.dropboxusercontent.com/u/22865035/version.json";//"http://raw.github.com/Jadar/DeveloperCapesAPI/master/version";

  private byte result = 0;
 
  private static final byte ERROR = 0;
  private static final byte OLD = 1;
  private static final byte CURRENT = 2;

  @Override
  public void run() {

    try {

      URL url = new URL(versionFileURL);
      BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
      double version = Double.valueOf(new JdomParser().parse(reader).getStringValue("version"));
     
      if(version > DevCapesUtil.version)
        result = OLD;
      else if(version == DevCapesUtil.version)
        result = CURRENT;
      else
        result = ERROR;
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }

  public byte getResult() {
    return result;
  }
}
TOP

Related Classes of Will11690.mod.MechaniCraft.Capes.DevCapesVersionChecker

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.