Skip to content

Commit

Permalink
Use tabs consistently with all other files. (#7330)
Browse files Browse the repository at this point in the history
* Use tabs consistently with all other files.

* Two spaces? In the four space factory?

* Finally, some good whitespace.
  • Loading branch information
Moderocky authored Dec 30, 2024
1 parent 86c4fcd commit 48d0bbe
Show file tree
Hide file tree
Showing 23 changed files with 478 additions and 485 deletions.
5 changes: 3 additions & 2 deletions src/main/java/ch/njol/skript/doc/DocumentationId.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DocumentationId {

public String value();

public String value();

}
7 changes: 4 additions & 3 deletions src/main/java/ch/njol/skript/doc/RequiredPlugins.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
* Provides a list of plugins other than Skript that the annotated
* element requires to be used. Non-Spigot server software can be considered
* to be plugins.
*
*
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RequiredPlugins {

String[] value();

String[] value();

}
100 changes: 52 additions & 48 deletions src/main/java/ch/njol/skript/update/GithubChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,63 +15,67 @@
* Uses Github API to check for updates.
*/
public class GithubChecker implements UpdateChecker {

/**
* Github API response for GSON deserialization.
*/
public static class ResponseEntry {

public String url;
public String assets_url;
public String upload_url;
public String html_url;
public int id;
public String tag_name;
public String target_commitish;
public String name;
public boolean draft;

public boolean prerelease;
public String created_at;
public String published_at;

public static class AssetsEntry {
public int size;
public int download_count;
public String browser_download_url;
}

public List<AssetsEntry> assets;
public String body; // Description of release

@Override
public String toString() {
return tag_name;
}

public static class Author {
public String login;
public int id;
}

public Author author;
public String assets_url;
public String upload_url;
public String html_url;
public int id;
public String tag_name;
public String target_commitish;
public String name;
public boolean draft;

public boolean prerelease;
public String created_at;
public String published_at;

public static class AssetsEntry {

public int size;
public int download_count;
public String browser_download_url;

}

public List<AssetsEntry> assets;
public String body; // Description of release

@Override
public String toString() {
return tag_name;
}

public static class Author {

public String login;
public int id;

}

public Author author;
}

/**
* Used for deserializing Github API output.
*/
private final Gson gson;

public GithubChecker() {
this.gson = new Gson();
}

private List<ResponseEntry> deserialize(String str) {
assert str != null : "Cannot deserialize null string";
@SuppressWarnings("serial")
Type listType = new TypeToken<List<ResponseEntry>>() {}.getType();
List<ResponseEntry> responses = gson.fromJson(str, listType);
assert responses != null;

return responses;
}

Expand All @@ -97,7 +101,7 @@ public CompletableFuture<UpdateManifest> check(ReleaseManifest manifest, Release
* Latest release in the channel we're using.
*/
ResponseEntry latest = null;

/**
* Current release, if found.
*/
Expand All @@ -107,32 +111,32 @@ public CompletableFuture<UpdateManifest> check(ReleaseManifest manifest, Release
for (ResponseEntry release : releases) {
String name = release.tag_name;
assert name != null;

// Check if this is a suitable latest release
if (latest == null && channel.check(name)) {
latest = release;
}

// Check whether this is a current release
if (manifest.id.equals(name)) {
current = release;
break; // Update can't be older than current release
}
}

if (latest == null) {
return null; // No updates for this channel available
}

if (current != null && latest.id == current.id) {
return null; // Already running latest in this channel
}

// Validate the latest release
if (latest.assets.isEmpty()) {
return null; // Update not (yet?) downloadable
}

try {
String name = latest.tag_name;
assert name != null;
Expand All @@ -146,7 +150,7 @@ public CompletableFuture<UpdateManifest> check(ReleaseManifest manifest, Release
} else {
download = new URL(latest.assets.get(0).browser_download_url);
}

return new UpdateManifest(name, createdAt, patchNotes, download);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
Expand All @@ -155,5 +159,5 @@ public CompletableFuture<UpdateManifest> check(ReleaseManifest manifest, Release
assert future != null;
return future;
}

}
Loading

0 comments on commit 48d0bbe

Please sign in to comment.