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
44 changes: 41 additions & 3 deletions src/main/java/me/adarsh/autoupdate/UpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,53 @@ public class UpdateChecker implements Runnable {
public static final long CHECK_UPDATE_FREQUENCY = 10*60; // 10 minutes

/** The url to the jenkins last build information */
public static final String LAST_BUILD_URL = "https://ci.viaversion.com/job/ViaVersion/lastBuild/api/json?random=%f";
public static final String LAST_BUILD_URL_VV = "https://ci.viaversion.com/job/ViaVersion/lastBuild/api/json?random=%f";

/** The url to the jenkins last build information */
public static final String LAST_BUILD_URL_VB = "https://ci.viaversion.com/job/ViaBackwards/lastBuild/api/json?random=%f";

/** The url to the jenkins last build information */
public static final String LAST_BUILD_URL_VR = "https://ci.viaversion.com/job/ViaRewind/lastBuild/api/json?random=%f";


/** The url to download the viaversion jar from */
public static final String DOWNLOAD_URL = "https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/%s";
public static final String DOWNLOAD_URL_VV = "https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/%s";

/** The url to download the viabackwards jar from */
public static final String DOWNLOAD_URL_VB = "https://ci.viaversion.com/job/ViaBackwards/lastBuild/artifact/%s";

/** The url to download the viarewind jar from */
public static final String DOWNLOAD_URL_VR = "https://ci.viaversion.com/job/ViaRewind/lastBuild/artifact/%s";

/** The url to the jeskins last build information */
private final String LAST_BUILD_URL;

/** The url to the target download */
private final String DOWNLOAD_URL;

private ViaVersionAutoUpdate viaVersionAutoUpdate;

public UpdateChecker(ViaVersionAutoUpdate viaVersionAutoUpdate) {
public UpdateChecker(ViaVersionAutoUpdate viaVersionAutoUpdate, String type) {
this.viaVersionAutoUpdate = viaVersionAutoUpdate;
switch (type) {
case "VV": {
DOWNLOAD_URL = DOWNLOAD_URL_VV;
LAST_BUILD_URL = LAST_BUILD_URL_VV;
break;
}
case "VB": {
DOWNLOAD_URL = DOWNLOAD_URL_VB;
LAST_BUILD_URL = LAST_BUILD_URL_VB;
break;
}
case "VR": {
DOWNLOAD_URL = DOWNLOAD_URL_VR;
LAST_BUILD_URL = LAST_BUILD_URL_VR;
break;
}
default:
throw new IllegalArgumentException("Invalid type: " + type);
}
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/me/adarsh/autoupdate/ViaVersionAutoUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public ViaVersionAutoUpdate(IPlugin plugin) {
this.plugin = plugin;

// Check for an update on startup,
new UpdateChecker(this).run();
new UpdateChecker(this, "VV").run(); // ViaVerison
new UpdateChecker(this, "VB").run(); // ViaBackwards
new UpdateChecker(this, "VR").run(); // ViaRewind
}

/**
Expand Down