Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.mattyhd0</groupId>
<artifactId>ChatColor</artifactId>
<version>2.7.11</version>
<version>2.7.12</version>
<packaging>jar</packaging>

<properties>
Expand All @@ -19,7 +19,7 @@
<!-- PlaceholderAPI Repo -->
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
<url>https://repo.extendedclip.com/releases/</url>
</repository>
<!-- Spigot Repo -->
<repository>
Expand All @@ -41,18 +41,17 @@
<version>1.20.6-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- XSeries -->
<!-- https://mvnrepository.com/artifact/com.github.cryptomorin/XSeries -->
<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId>
<version>11.3.0</version>
<scope>compile</scope>
<version>13.2.0</version>
</dependency>
<!-- PlaceholderAPI -->
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.3</version>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
<!-- bStats -->
Expand All @@ -73,8 +72,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
<scope>provided</scope>
<version>2.13.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
Expand Down
21 changes: 5 additions & 16 deletions src/main/java/me/mattyhd0/chatcolor/updatechecker/SpigotAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,23 @@

public class SpigotAPI {

public static SpigotResource getSpigotResource(int id){

public static SpigotResource getSpigotResource(int id) {
StringBuilder response = new StringBuilder();

try {

URL urlObject = new URL("https://api.spigotmc.org/simple/0.2/index.php?action=getResource&id="+id);
URL urlObject = new URL("https://api.spigotmc.org/simple/0.2/index.php?action=getResource&id=" + id);
URLConnection urlConnection = urlObject.openConnection();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String line;

while ((line = bufferedReader.readLine()) != null) {

response.append(line);

}
while ((line = bufferedReader.readLine()) != null) response.append(line);

bufferedReader.close();

} catch (IOException e){
return null;
} catch (IOException e) {
throw null;
}


Gson gson = new Gson();
return gson.fromJson(response.toString(), SpigotResource.class);

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class SpigotResource {
private Stats stats;
private String description;

private static class Author{
private static class Author {

private int id;
private String username;
Expand All @@ -26,10 +26,9 @@ public int getId(){
public String getUsername(){
return username;
}

}

private static class Premium{
private static class Premium {

private String price;
private String currency;
Expand All @@ -41,15 +40,14 @@ public String getPrice(){
public String getCurrency(){
return currency;
}

}

private static class Stats{
private static class Stats {

private int downloads;
private int updates;
private Reviews reviews;
private int rating;
private double rating;

public int getDownloads() {
return downloads;
Expand All @@ -63,11 +61,11 @@ public Reviews getReviews() {
return reviews;
}

public int getRating() {
public double getRating() {
return rating;
}

private static class Reviews{
private static class Reviews {

private int unique;
private int total;
Expand Down Expand Up @@ -113,16 +111,10 @@ public String getIconLink() {

public Author getAuthor() { return author; }

//public int getAuthorId() { return author.id; }

//public String getAuthorUsername() { return author.username; }

public boolean isPremium(){
return !(premium.price.equals("0.00") && premium.currency.equals(""));
return !(premium.price.equals("0.00") && premium.currency.isEmpty());
}

//public Premium getPremium() { return premium; }

public String getPrice(){
return premium.price;
}
Expand All @@ -139,23 +131,18 @@ public String getDescription() {
return description;
}

public String getDownloadUrl(){
public String getDownloadUrl() {

String url = ("https://www.spigotmc.org/resources/"+title+"."+id+"/").replaceAll(" ", "-");
String url = ("https://www.spigotmc.org/resources/" + title + "." + id + "/").replaceAll(" ", "-");
String validChars = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:/.-_";
StringBuilder validUrl = new StringBuilder();

for(int i = 0; i < url.length(); i++){

for (int i = 0; i < url.length(); i++) {
String c = Character.toString(url.charAt(i));

if(validChars.contains(c)){
validUrl.append(c);
}

if (validChars.contains(c)) validUrl.append(c);
}

return validUrl.toString();
}

}