Skip to content

Commit 8457671

Browse files
Refactor plugin update system, using maven repo instead
1 parent 30759ed commit 8457671

File tree

7 files changed

+318
-220
lines changed

7 files changed

+318
-220
lines changed

src/main/java/org/maxgamer/quickshop/BuildInfo.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ public class BuildInfo {
3838
private final int buildId;
3939
private final String buildTag;
4040
private final String buildUrl;
41+
@Nullable
4142
private final String jobUrl;
4243
private final String gitCommit;
4344
private final String gitBranch;
4445
private final String pomGroupId;
4546
private final String pomArtifactId;
47+
48+
private final String pomBuildNumber;
4649
private final String jobName;
4750
private static final String UNKNOWN = "Unknown";
4851

@@ -56,7 +59,8 @@ public BuildInfo(@Nullable InputStream inputStream) {
5659
pomGroupId = UNKNOWN;
5760
pomArtifactId = UNKNOWN;
5861
jobName = UNKNOWN;
59-
jobUrl = "https://ci.codemc.io/job/PotatoCraft-Studio/job/QuickShop-Reremake/";
62+
pomBuildNumber = UNKNOWN;
63+
jobUrl = null;
6064
return;
6165
}
6266
YamlConfiguration buildInfo = YamlConfiguration.loadConfiguration(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
@@ -67,8 +71,9 @@ public BuildInfo(@Nullable InputStream inputStream) {
6771
gitBranch = buildInfo.getString("git-branch", "Unknown");
6872
pomGroupId = buildInfo.getString("pom-groupid", "Unknown");
6973
pomArtifactId = buildInfo.getString("pom-artifactid", "Unknown");
70-
jobUrl = buildInfo.getString("job-url", "https://ci.codemc.io/job/PotatoCraft-Studio/job/QuickShop-Reremake/");
74+
jobUrl = buildInfo.getString("job-url");
7175
jobName = buildInfo.getString("job-name", "Unknown");
76+
pomBuildNumber = buildInfo.getString("pom-buildNumber", "1");
7277
try {
7378
inputStream.close();
7479
} catch (IOException ignored) {

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Update.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.maxgamer.quickshop.api.command.CommandHandler;
2929
import org.maxgamer.quickshop.util.MsgUtil;
3030
import org.maxgamer.quickshop.util.updater.QuickUpdater;
31-
import org.maxgamer.quickshop.util.updater.VersionType;
3231

3332
import java.util.logging.Level;
3433

@@ -47,8 +46,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String commandLabe
4746
return;
4847
}
4948
QuickUpdater updater = plugin.getUpdateWatcher().getUpdater();
50-
VersionType versionType = updater.getCurrentRunning();
51-
if (updater.isLatest(versionType)) {
49+
if (updater.isLatest()) {
5250
MsgUtil.sendDirectMessage(sender, ChatColor.GREEN + "You're running the latest version!");
5351
return;
5452
}
@@ -60,7 +58,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String commandLabe
6058
}
6159
MsgUtil.sendDirectMessage(sender, ChatColor.YELLOW + "Downloading update! This may take a while...");
6260
try {
63-
updater.install(updater.update(versionType));
61+
updater.installUpdate();
6462
} catch (Exception e) {
6563
MsgUtil.sendDirectMessage(sender, ChatColor.RED + "Update failed! Please check your console for more information.");
6664
plugin.getSentryErrorReporter().ignoreThrow();

src/main/java/org/maxgamer/quickshop/util/reporter/error/RollbarErrorReporter.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@
3636

3737
import java.io.IOException;
3838
import java.net.ProtocolException;
39-
import java.util.*;
39+
import java.util.ArrayList;
40+
import java.util.Arrays;
41+
import java.util.LinkedHashMap;
42+
import java.util.List;
43+
import java.util.Map;
4044
import java.util.logging.Filter;
4145
import java.util.logging.Level;
4246
import java.util.logging.LogRecord;
@@ -200,7 +204,7 @@ public boolean canReport(@NotNull Throwable throwable) {
200204
if (plugin.getUpdateWatcher() == null) {
201205
return false;
202206
}
203-
if (!plugin.getUpdateWatcher().getUpdater().isLatest(plugin.getUpdateWatcher().getUpdater().getCurrentRunning())) { // We only receive latest reports.
207+
if (!plugin.getUpdateWatcher().getUpdater().isLatest()) { // We only receive latest reports.
204208
return false;
205209
}
206210
if (!GameVersion.get(ReflectFactory.getServerVersion()).isCoreSupports()) { // Ignore errors if user install quickshop on unsupported

src/main/java/org/maxgamer/quickshop/util/updater/QuickUpdater.java

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,37 +41,19 @@ public interface QuickUpdater {
4141
@NotNull String getRemoteServerVersion();
4242

4343
/**
44-
* Gets the build id on remote server
44+
* Check specified type of version is the latest version on remote version
4545
*
46-
* @return BuildId on remote server
46+
* @return is the latest build
4747
*/
48-
int getRemoteServerBuildId();
49-
50-
/**
51-
* Check specified type of version is latest version on remote version
52-
*
53-
* @param versionType The version type needs to check
54-
* @return is latest build
55-
*/
56-
boolean isLatest(@NotNull VersionType versionType);
57-
58-
/**
59-
* Download update from remote server
60-
*
61-
* @param versionType The version type to download
62-
* @return The binary array that downloads
63-
* @throws IOException IOException will throws if downloading fails
64-
*/
65-
byte[] update(@NotNull VersionType versionType) throws IOException;
48+
boolean isLatest();
6649

6750
/**
6851
* Install updates to server
6952
* * Warning: It is unstable, recommend to restart server *
7053
*
71-
* @param bytes The bytes will write to jar file
72-
* @throws IOException IOException will throws if copying failed
54+
* @throws IOException IOException will throw if copying failed
7355
*/
74-
void install(byte[] bytes) throws IOException;
56+
void installUpdate() throws IOException;
7557

7658
/**
7759
* Return the updated jar

src/main/java/org/maxgamer/quickshop/util/updater/impl/JenkinsUpdater.java

Lines changed: 0 additions & 185 deletions
This file was deleted.

0 commit comments

Comments
 (0)