- Tham gia
- 02/03/2019
- Bài viết
- 277
- bài viết nhằm hướng dẫn cho những ai chưa biết sử dụng api của forum để lấy version mới nhất của forum
- bạn chưa biết gì về api đó? Click
- còn lại bạn tự tìm hiểu thoi
- bạn chưa biết gì về api đó? Click
- còn lại bạn tự tìm hiểu thoi

Java:
private static String read(InputStream inputStream) throws IOException {
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) != -1) {
result.write(buffer, 0, length);
}
return result.toString("UTF-8");
}
public static String LastestVersion(long id) throws MalformedURLException, IOException {
//id là số id của plugin! chưa biết thì lên link đây xem hướng dẫn: https://minecraftvn.net/api-lay-phien-ban-tai-nguyen-moi-nhat.t22729/
HttpURLConnection connection = (HttpURLConnection) new URL("https://minecraftvn.net/resource_version.api?id=" + id).openConnection();
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
connection.setRequestProperty("User-Agent", "Mozilla/65");
connection.setDoOutput(true);
connection.connect();
return read(connection.getInputStream());
}





Khá giống kiểu báo bản update mới bên spigot