• Chào bạn, hãy đăng ký hoặc đăng nhập để tham gia cùng bọn mình và sử dụng được đầy đủ chức năng của diễn đàn :).
JunoMC

Hướng dẫn Kết nối, lấy version của plugin từ api forum!

JunoMC

DEVELOPER
THÀNH VIÊN
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 :D


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());
}
 
:v Khá giống kiểu báo bản update mới bên spigot
 
là sao cho nó ra cái tb là có update
 
Similar content Most view Xem thêm
Back
Top Bottom