Skip to content

Commit

Permalink
v2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJeterLP committed Dec 26, 2022
2 parents 5cff162 + d29394b commit 3fa2c9d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Spigot-Updatechecker [![Build Status](https://github.com/TheJeterLP/Spigot-Updatechecker/actions/workflows/main.yml/badge.svg)](https://github.com/TheJeterLP/Spigot-Updatechecker/actions/workflows/main.yml)

Updatechecker for SpigotMC hosted plugins.

For usage see TheJeterLP/ChatEx
27 changes: 14 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.jeter</groupId>
<artifactId>Spigot-Updatechecker</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<scm>
<connection>scm:git:[email protected]:TheJeterLP/Spigot-Updatechecker.git</connection>
<url>scm:git:[email protected]:TheJeterLP/Spigot-Updatechecker.git</url>
<developerConnection>scm:git:[email protected]:TheJeterLP/Spigot-Updatechecker.git</developerConnection>
</scm>

<build>
<defaultGoal>clean install</defaultGoal>
<finalName>${project.name}</finalName>
Expand All @@ -27,27 +28,27 @@
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/</directory>
<includes>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</resources>
</build>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<version>1.19.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependency>
</dependencies>

</project>
11 changes: 11 additions & 0 deletions src/main/java/de/jeter/updatechecker/GitHubUpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class GitHubUpdateChecker extends UpdateChecker {
Expand Down Expand Up @@ -45,6 +46,16 @@ public String getUpdateMessage() {
return "Update found! Please consider downloading the newest version from " + url;
}

@Override
public URL getDownloadLink() {
try {
return new URL(url);
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
}
}

@Override
protected void checkForUpdate() {
try {
Expand Down
19 changes: 15 additions & 4 deletions src/main/java/de/jeter/updatechecker/SpigotUpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class SpigotUpdateChecker extends UpdateChecker {

private final JavaPlugin plugin;
private final int id;
private Result result = Result.NO_UPDATE;
private String version;
private static final String VERSIONS = "/versions/latest";
private static final String API_RESOURCE = "https://api.spiget.org/v2/resources/";
private final JavaPlugin plugin;
private final int id;
private final String USER_AGENT;
private final String url;
private Result result = Result.NO_UPDATE;
private String version;

public SpigotUpdateChecker(JavaPlugin plugin, int id) {
this.plugin = plugin;
Expand All @@ -44,6 +45,16 @@ public String getUpdateMessage() {
return "Update found! Please consider installing the latest version from " + url;
}

@Override
public URL getDownloadLink() {
try {
return new URL(url);
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
}
}

@Override
protected void checkForUpdate() {
try {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/de/jeter/updatechecker/UpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.bukkit.plugin.java.JavaPlugin;

import java.net.URL;

public abstract class UpdateChecker {

/**
Expand All @@ -26,6 +28,13 @@ public abstract class UpdateChecker {
*/
public abstract String getUpdateMessage();

/**
* Gets the URL where the new version can be downloaded
*
* @return
*/
public abstract URL getDownloadLink();

/**
* Runs the actual checker itself.
*/
Expand Down

0 comments on commit 3fa2c9d

Please sign in to comment.