From 4a1beb8260ef8bc95dce820889b26128c49eef5f Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Tue, 29 Sep 2020 17:13:21 +0800 Subject: [PATCH] No-longer use Github API Former-commit-id: fceac81c589f2c7d683bee76f3348850bd2c0299 --- .../quickshop/util/github/GithubAPI.java | 86 ++++----- .../util/github/ReleaseJsonContainer.java | 172 +++++++++--------- 2 files changed, 129 insertions(+), 129 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/util/github/GithubAPI.java b/src/main/java/org/maxgamer/quickshop/util/github/GithubAPI.java index 0418e2ac8..f06194169 100644 --- a/src/main/java/org/maxgamer/quickshop/util/github/GithubAPI.java +++ b/src/main/java/org/maxgamer/quickshop/util/github/GithubAPI.java @@ -19,46 +19,46 @@ package org.maxgamer.quickshop.util.github; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import org.jetbrains.annotations.Nullable; -import org.maxgamer.quickshop.nonquickshopstuff.com.sk89q.worldedit.util.net.HttpRequest; - -import java.io.IOException; -import java.net.URL; - -public class GithubAPI { - private final Gson gson = new GsonBuilder().disableHtmlEscaping().create(); - - @Nullable - public ReleaseJsonContainer.AssetsBean getLatestRelease() throws IOException { - String json = - HttpRequest.get( - new URL( - "https://api.github.com/repos/Ghost-chu/QuickShop-Reremake/releases/latest")) - .execute() - .returnContent() - .asString("UTF-8"); - ReleaseJsonContainer result = gson.fromJson(json, ReleaseJsonContainer.class); - for (ReleaseJsonContainer.AssetsBean asset : result.getAssets()) { - if (asset.getName().contains("original-")) { - continue; - } - if (asset.getName().contains("-javadoc")) { - continue; - } - if (asset.getName().contains("-sources")) { - continue; - } - if (asset.getName().contains("-shaded")) { - continue; - } - if (asset.getName().contains("Document") || asset.getName().contains("document")) { - continue; - } - return asset; - } - return null; - } - -} +//import com.google.gson.Gson; +//import com.google.gson.GsonBuilder; +//import org.jetbrains.annotations.Nullable; +//import org.maxgamer.quickshop.nonquickshopstuff.com.sk89q.worldedit.util.net.HttpRequest; +// +//import java.io.IOException; +//import java.net.URL; +// +//public class GithubAPI { +// private final Gson gson = new GsonBuilder().disableHtmlEscaping().create(); +// +// @Nullable +// public ReleaseJsonContainer.AssetsBean getLatestRelease() throws IOException { +// String json = +// HttpRequest.get( +// new URL( +// "https://api.github.com/repos/Ghost-chu/QuickShop-Reremake/releases/latest")) +// .execute() +// .returnContent() +// .asString("UTF-8"); +// ReleaseJsonContainer result = gson.fromJson(json, ReleaseJsonContainer.class); +// for (ReleaseJsonContainer.AssetsBean asset : result.getAssets()) { +// if (asset.getName().contains("original-")) { +// continue; +// } +// if (asset.getName().contains("-javadoc")) { +// continue; +// } +// if (asset.getName().contains("-sources")) { +// continue; +// } +// if (asset.getName().contains("-shaded")) { +// continue; +// } +// if (asset.getName().contains("Document") || asset.getName().contains("document")) { +// continue; +// } +// return asset; +// } +// return null; +// } +// +//} diff --git a/src/main/java/org/maxgamer/quickshop/util/github/ReleaseJsonContainer.java b/src/main/java/org/maxgamer/quickshop/util/github/ReleaseJsonContainer.java index b58cc4342..2727b65cf 100644 --- a/src/main/java/org/maxgamer/quickshop/util/github/ReleaseJsonContainer.java +++ b/src/main/java/org/maxgamer/quickshop/util/github/ReleaseJsonContainer.java @@ -18,89 +18,89 @@ */ package org.maxgamer.quickshop.util.github; - -import java.util.List; - -public class ReleaseJsonContainer { - /** - * url : https://api.github.com/repos/octocat/Hello-World/releases/1 html_url : - * https://github.com/octocat/Hello-World/releases/v1.0.0 assets_url : - * https://api.github.com/repos/octocat/Hello-World/releases/1/assets upload_url : - * https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label} tarball_url - * : https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0 zipball_url : - * https://api.github.com/repos/octocat/Hello-World/zipball/v1.0.0 id : 1 node_id : - * MDc6UmVsZWFzZTE= tag_name : v1.0.0 target_commitish : master name : v1.0.0 body : Description - * of the release draft : false prerelease : false created_at : 2013-02-27T19:35:32Z published_at - * : 2013-02-27T19:35:32Z author : - * {"login":"octocat","id":1,"node_id":"MDQ6VXNlcjE=","avatar_url":"https://github.com/images/error/octocat_happy.gif","gravatar_id":"","url":"https://api.github.com/users/octocat","html_url":"https://github.com/octocat","followers_url":"https://api.github.com/users/octocat/followers","following_url":"https://api.github.com/users/octocat/following{/other_user}","gists_url":"https://api.github.com/users/octocat/gists{/gist_id}","starred_url":"https://api.github.com/users/octocat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octocat/subscriptions","organizations_url":"https://api.github.com/users/octocat/orgs","repos_url":"https://api.github.com/users/octocat/repos","events_url":"https://api.github.com/users/octocat/events{/privacy}","received_events_url":"https://api.github.com/users/octocat/received_events","type":"User","site_admin":false} - * assets : - * [{"url":"https://api.github.com/repos/octocat/Hello-World/releases/assets/1","browser_download_url":"https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip","id":1,"node_id":"MDEyOlJlbGVhc2VBc3NldDE=","name":"example.zip","label":"short - * description","state":"uploaded","content_type":"application/zip","size":1024,"download_count":42,"created_at":"2013-02-27T19:35:32Z","updated_at":"2013-02-27T19:35:32Z","uploader":{"login":"octocat","id":1,"node_id":"MDQ6VXNlcjE=","avatar_url":"https://github.com/images/error/octocat_happy.gif","gravatar_id":"","url":"https://api.github.com/users/octocat","html_url":"https://github.com/octocat","followers_url":"https://api.github.com/users/octocat/followers","following_url":"https://api.github.com/users/octocat/following{/other_user}","gists_url":"https://api.github.com/users/octocat/gists{/gist_id}","starred_url":"https://api.github.com/users/octocat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octocat/subscriptions","organizations_url":"https://api.github.com/users/octocat/orgs","repos_url":"https://api.github.com/users/octocat/repos","events_url":"https://api.github.com/users/octocat/events{/privacy}","received_events_url":"https://api.github.com/users/octocat/received_events","type":"User","site_admin":false}}] - */ - private int id; - - private String name; - - private List assets; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public List getAssets() { - return assets; - } - - public static class AssetsBean { - /** - * url : https://api.github.com/repos/octocat/Hello-World/releases/assets/1 browser_download_url - * : https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip id : 1 node_id - * : MDEyOlJlbGVhc2VBc3NldDE= name : example.zip label : short description state : uploaded - * content_type : application/zip size : 1024 download_count : 42 created_at : - * 2013-02-27T19:35:32Z updated_at : 2013-02-27T19:35:32Z uploader : - * {"login":"octocat","id":1,"node_id":"MDQ6VXNlcjE=","avatar_url":"https://github.com/images/error/octocat_happy.gif","gravatar_id":"","url":"https://api.github.com/users/octocat","html_url":"https://github.com/octocat","followers_url":"https://api.github.com/users/octocat/followers","following_url":"https://api.github.com/users/octocat/following{/other_user}","gists_url":"https://api.github.com/users/octocat/gists{/gist_id}","starred_url":"https://api.github.com/users/octocat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octocat/subscriptions","organizations_url":"https://api.github.com/users/octocat/orgs","repos_url":"https://api.github.com/users/octocat/repos","events_url":"https://api.github.com/users/octocat/events{/privacy}","received_events_url":"https://api.github.com/users/octocat/received_events","type":"User","site_admin":false} - */ - private String browser_download_url; - - private String name; - - private int size; - - public AssetsBean() { - } - - public String getBrowser_download_url() { - return browser_download_url; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getSize() { - return size; - } - - public void setSize(int size) { - this.size = size; - } - - } - -} +// +//import java.util.List; +// +//public class ReleaseJsonContainer { +// /** +// * url : https://api.github.com/repos/octocat/Hello-World/releases/1 html_url : +// * https://github.com/octocat/Hello-World/releases/v1.0.0 assets_url : +// * https://api.github.com/repos/octocat/Hello-World/releases/1/assets upload_url : +// * https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label} tarball_url +// * : https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0 zipball_url : +// * https://api.github.com/repos/octocat/Hello-World/zipball/v1.0.0 id : 1 node_id : +// * MDc6UmVsZWFzZTE= tag_name : v1.0.0 target_commitish : master name : v1.0.0 body : Description +// * of the release draft : false prerelease : false created_at : 2013-02-27T19:35:32Z published_at +// * : 2013-02-27T19:35:32Z author : +// * {"login":"octocat","id":1,"node_id":"MDQ6VXNlcjE=","avatar_url":"https://github.com/images/error/octocat_happy.gif","gravatar_id":"","url":"https://api.github.com/users/octocat","html_url":"https://github.com/octocat","followers_url":"https://api.github.com/users/octocat/followers","following_url":"https://api.github.com/users/octocat/following{/other_user}","gists_url":"https://api.github.com/users/octocat/gists{/gist_id}","starred_url":"https://api.github.com/users/octocat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octocat/subscriptions","organizations_url":"https://api.github.com/users/octocat/orgs","repos_url":"https://api.github.com/users/octocat/repos","events_url":"https://api.github.com/users/octocat/events{/privacy}","received_events_url":"https://api.github.com/users/octocat/received_events","type":"User","site_admin":false} +// * assets : +// * [{"url":"https://api.github.com/repos/octocat/Hello-World/releases/assets/1","browser_download_url":"https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip","id":1,"node_id":"MDEyOlJlbGVhc2VBc3NldDE=","name":"example.zip","label":"short +// * description","state":"uploaded","content_type":"application/zip","size":1024,"download_count":42,"created_at":"2013-02-27T19:35:32Z","updated_at":"2013-02-27T19:35:32Z","uploader":{"login":"octocat","id":1,"node_id":"MDQ6VXNlcjE=","avatar_url":"https://github.com/images/error/octocat_happy.gif","gravatar_id":"","url":"https://api.github.com/users/octocat","html_url":"https://github.com/octocat","followers_url":"https://api.github.com/users/octocat/followers","following_url":"https://api.github.com/users/octocat/following{/other_user}","gists_url":"https://api.github.com/users/octocat/gists{/gist_id}","starred_url":"https://api.github.com/users/octocat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octocat/subscriptions","organizations_url":"https://api.github.com/users/octocat/orgs","repos_url":"https://api.github.com/users/octocat/repos","events_url":"https://api.github.com/users/octocat/events{/privacy}","received_events_url":"https://api.github.com/users/octocat/received_events","type":"User","site_admin":false}}] +// */ +// private int id; +// +// private String name; +// +// private List assets; +// +// public int getId() { +// return id; +// } +// +// public void setId(int id) { +// this.id = id; +// } +// +// public String getName() { +// return name; +// } +// +// public void setName(String name) { +// this.name = name; +// } +// +// public List getAssets() { +// return assets; +// } +// +// public static class AssetsBean { +// /** +// * url : https://api.github.com/repos/octocat/Hello-World/releases/assets/1 browser_download_url +// * : https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip id : 1 node_id +// * : MDEyOlJlbGVhc2VBc3NldDE= name : example.zip label : short description state : uploaded +// * content_type : application/zip size : 1024 download_count : 42 created_at : +// * 2013-02-27T19:35:32Z updated_at : 2013-02-27T19:35:32Z uploader : +// * {"login":"octocat","id":1,"node_id":"MDQ6VXNlcjE=","avatar_url":"https://github.com/images/error/octocat_happy.gif","gravatar_id":"","url":"https://api.github.com/users/octocat","html_url":"https://github.com/octocat","followers_url":"https://api.github.com/users/octocat/followers","following_url":"https://api.github.com/users/octocat/following{/other_user}","gists_url":"https://api.github.com/users/octocat/gists{/gist_id}","starred_url":"https://api.github.com/users/octocat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octocat/subscriptions","organizations_url":"https://api.github.com/users/octocat/orgs","repos_url":"https://api.github.com/users/octocat/repos","events_url":"https://api.github.com/users/octocat/events{/privacy}","received_events_url":"https://api.github.com/users/octocat/received_events","type":"User","site_admin":false} +// */ +// private String browser_download_url; +// +// private String name; +// +// private int size; +// +// public AssetsBean() { +// } +// +// public String getBrowser_download_url() { +// return browser_download_url; +// } +// +// public String getName() { +// return name; +// } +// +// public void setName(String name) { +// this.name = name; +// } +// +// public int getSize() { +// return size; +// } +// +// public void setSize(int size) { +// this.size = size; +// } +// +// } +// +//}