Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tabs consistently with all other files. #7330

Merged
merged 3 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
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
Loading