• Trong thời gian này, bạn không thể tạo bài mới, đăng comment, hay tạo tài nguyên mới để diễn đàn dọn dẹp nội dung.
    Diễn đàn sẽ sớm mở trở lại, chi tiết hãy theo dõi tại Discord
JunoMC

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

  • Người tạo chủ đề Người tạo chủ đề JunoMC
  • Ngày gửi Ngày gửi

JunoMC

DEVELOPER
- 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
 
Nội dung tương tự Xem nhiều nhất Xem thêm

Thống kê nội dung

Tạo
JunoMC,
Trả lời lần cuối từ
JunoMC,
Trả lời
10
Lượt xem
1,076
Quay lại
Trên cùng