@ -1,6 +1,5 @@
|
||||
package org.bukkit.fillr;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
@ -13,70 +12,68 @@ import org.json.simple.parser.ParseException;
|
||||
* Grabs the latest info for a given plugin from fill.bukkit.org
|
||||
*/
|
||||
public class FillReader {
|
||||
//TODO change this to what it will actually be...
|
||||
private static String baseUrl = "http://taylorkelly.me/pnfo.php";
|
||||
//TODO change this to what it will actually be...
|
||||
private static String baseUrl = "http://taylorkelly.me/pnfo.php";
|
||||
private String currVersion;
|
||||
private String file;
|
||||
private String name;
|
||||
private String notes;
|
||||
private boolean stable;
|
||||
|
||||
private String currVersion;
|
||||
private String file;
|
||||
private String name;
|
||||
private String notes;
|
||||
private boolean stable;
|
||||
|
||||
public FillReader(String name) {
|
||||
try {
|
||||
String result = "";
|
||||
try {
|
||||
URL url = new URL(baseUrl + "?name=" + name);
|
||||
System.out.println(baseUrl + "?name=" + name);
|
||||
URLConnection conn = url.openConnection();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(
|
||||
conn.getInputStream()));
|
||||
String line;
|
||||
while ((line = rd.readLine()) != null) {
|
||||
buf.append(line);
|
||||
}
|
||||
result = buf.toString();
|
||||
rd.close();
|
||||
JSONParser parser = new JSONParser();
|
||||
Object obj;
|
||||
obj = parser.parse(result);
|
||||
JSONObject jsonObj = (JSONObject) obj;
|
||||
this.currVersion = (String)jsonObj.get("plugin_version");
|
||||
this.name = (String)jsonObj.get("plugin_name");
|
||||
this.file = (String)jsonObj.get("plugin_file");
|
||||
this.stable = (Boolean)jsonObj.get("plugin_stable");
|
||||
this.notes = (String)jsonObj.get("plugin_notes");
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getCurrVersion() {
|
||||
return currVersion;
|
||||
}
|
||||
public FillReader(String name) {
|
||||
try {
|
||||
String result = "";
|
||||
try {
|
||||
URL url = new URL(baseUrl + "?name=" + name);
|
||||
System.out.println(baseUrl + "?name=" + name);
|
||||
URLConnection conn = url.openConnection();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(
|
||||
conn.getInputStream()));
|
||||
String line;
|
||||
while ((line = rd.readLine()) != null) {
|
||||
buf.append(line);
|
||||
}
|
||||
result = buf.toString();
|
||||
rd.close();
|
||||
JSONParser parser = new JSONParser();
|
||||
Object obj;
|
||||
obj = parser.parse(result);
|
||||
JSONObject jsonObj = (JSONObject) obj;
|
||||
this.currVersion = (String) jsonObj.get("plugin_version");
|
||||
this.name = (String) jsonObj.get("plugin_name");
|
||||
this.file = (String) jsonObj.get("plugin_file");
|
||||
this.stable = (Boolean) jsonObj.get("plugin_stable");
|
||||
this.notes = (String) jsonObj.get("plugin_notes");
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
public String getCurrVersion() {
|
||||
return currVersion;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setStable(boolean stable) {
|
||||
this.stable = stable;
|
||||
}
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public boolean isStable() {
|
||||
return stable;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setStable(boolean stable) {
|
||||
this.stable = stable;
|
||||
}
|
||||
|
||||
public boolean isStable() {
|
||||
return stable;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user